Home | History | Annotate | Download | only in cat
      1 /*
      2  * Copyright (C) 2007 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.internal.telephony.cat;
     18 
     19 import android.graphics.Bitmap;
     20 
     21 /**
     22  * Container class for proactive command parameters.
     23  *
     24  */
     25 class CommandParams {
     26     CommandDetails mCmdDet;
     27 
     28     CommandParams(CommandDetails cmdDet) {
     29         mCmdDet = cmdDet;
     30     }
     31 
     32     AppInterface.CommandType getCommandType() {
     33         return AppInterface.CommandType.fromInt(mCmdDet.typeOfCommand);
     34     }
     35 
     36     boolean setIcon(Bitmap icon) { return true; }
     37 
     38     @Override
     39     public String toString() {
     40         return mCmdDet.toString();
     41     }
     42 }
     43 
     44 class DisplayTextParams extends CommandParams {
     45     TextMessage mTextMsg;
     46 
     47     DisplayTextParams(CommandDetails cmdDet, TextMessage textMsg) {
     48         super(cmdDet);
     49         mTextMsg = textMsg;
     50     }
     51 
     52     @Override
     53     boolean setIcon(Bitmap icon) {
     54         if (icon != null && mTextMsg != null) {
     55             mTextMsg.icon = icon;
     56             return true;
     57         }
     58         return false;
     59     }
     60 }
     61 
     62 class LaunchBrowserParams extends CommandParams {
     63     TextMessage mConfirmMsg;
     64     LaunchBrowserMode mMode;
     65     String mUrl;
     66 
     67     LaunchBrowserParams(CommandDetails cmdDet, TextMessage confirmMsg,
     68             String url, LaunchBrowserMode mode) {
     69         super(cmdDet);
     70         mConfirmMsg = confirmMsg;
     71         mMode = mode;
     72         mUrl = url;
     73     }
     74 
     75     @Override
     76     boolean setIcon(Bitmap icon) {
     77         if (icon != null && mConfirmMsg != null) {
     78             mConfirmMsg.icon = icon;
     79             return true;
     80         }
     81         return false;
     82     }
     83 }
     84 
     85 class PlayToneParams extends CommandParams {
     86     TextMessage mTextMsg;
     87     ToneSettings mSettings;
     88 
     89     PlayToneParams(CommandDetails cmdDet, TextMessage textMsg,
     90             Tone tone, Duration duration, boolean vibrate) {
     91         super(cmdDet);
     92         mTextMsg = textMsg;
     93         mSettings = new ToneSettings(duration, tone, vibrate);
     94     }
     95 
     96     @Override
     97     boolean setIcon(Bitmap icon) {
     98         if (icon != null && mTextMsg != null) {
     99             mTextMsg.icon = icon;
    100             return true;
    101         }
    102         return false;
    103     }
    104 }
    105 
    106 class CallSetupParams extends CommandParams {
    107     TextMessage mConfirmMsg;
    108     TextMessage mCallMsg;
    109 
    110     CallSetupParams(CommandDetails cmdDet, TextMessage confirmMsg,
    111             TextMessage callMsg) {
    112         super(cmdDet);
    113         mConfirmMsg = confirmMsg;
    114         mCallMsg = callMsg;
    115     }
    116 
    117     @Override
    118     boolean setIcon(Bitmap icon) {
    119         if (icon == null) {
    120             return false;
    121         }
    122         if (mConfirmMsg != null && mConfirmMsg.icon == null) {
    123             mConfirmMsg.icon = icon;
    124             return true;
    125         } else if (mCallMsg != null && mCallMsg.icon == null) {
    126             mCallMsg.icon = icon;
    127             return true;
    128         }
    129         return false;
    130     }
    131 }
    132 
    133 class SelectItemParams extends CommandParams {
    134     Menu mMenu = null;
    135     boolean mLoadTitleIcon = false;
    136 
    137     SelectItemParams(CommandDetails cmdDet, Menu menu, boolean loadTitleIcon) {
    138         super(cmdDet);
    139         mMenu = menu;
    140         mLoadTitleIcon = loadTitleIcon;
    141     }
    142 
    143     @Override
    144     boolean setIcon(Bitmap icon) {
    145         if (icon != null && mMenu != null) {
    146             if (mLoadTitleIcon && mMenu.titleIcon == null) {
    147                 mMenu.titleIcon = icon;
    148             } else {
    149                 for (Item item : mMenu.items) {
    150                     if (item.icon != null) {
    151                         continue;
    152                     }
    153                     item.icon = icon;
    154                     break;
    155                 }
    156             }
    157             return true;
    158         }
    159         return false;
    160     }
    161 }
    162 
    163 class GetInputParams extends CommandParams {
    164     Input mInput = null;
    165 
    166     GetInputParams(CommandDetails cmdDet, Input input) {
    167         super(cmdDet);
    168         mInput = input;
    169     }
    170 
    171     @Override
    172     boolean setIcon(Bitmap icon) {
    173         if (icon != null && mInput != null) {
    174             mInput.icon = icon;
    175         }
    176         return true;
    177     }
    178 }
    179 
    180 /*
    181  * BIP (Bearer Independent Protocol) is the mechanism for SIM card applications
    182  * to access data connection through the mobile device.
    183  *
    184  * SIM utilizes proactive commands (OPEN CHANNEL, CLOSE CHANNEL, SEND DATA and
    185  * RECEIVE DATA to control/read/write data for BIP. Refer to ETSI TS 102 223 for
    186  * the details of proactive commands procedures and their structures.
    187  */
    188 class BIPClientParams extends CommandParams {
    189     TextMessage mTextMsg;
    190     boolean mHasAlphaId;
    191 
    192     BIPClientParams(CommandDetails cmdDet, TextMessage textMsg, boolean has_alpha_id) {
    193         super(cmdDet);
    194         mTextMsg = textMsg;
    195         mHasAlphaId = has_alpha_id;
    196     }
    197 
    198     @Override
    199     boolean setIcon(Bitmap icon) {
    200         if (icon != null && mTextMsg != null) {
    201             mTextMsg.icon = icon;
    202             return true;
    203         }
    204         return false;
    205     }
    206 }
    207