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     // Variable to track if an optional icon load has failed.
     28     boolean mLoadIconFailed = false;
     29 
     30     CommandParams(CommandDetails cmdDet) {
     31         mCmdDet = cmdDet;
     32     }
     33 
     34     AppInterface.CommandType getCommandType() {
     35         return AppInterface.CommandType.fromInt(mCmdDet.typeOfCommand);
     36     }
     37 
     38     boolean setIcon(Bitmap icon) { return true; }
     39 
     40     @Override
     41     public String toString() {
     42         return mCmdDet.toString();
     43     }
     44 }
     45 
     46 class DisplayTextParams extends CommandParams {
     47     TextMessage mTextMsg;
     48 
     49     DisplayTextParams(CommandDetails cmdDet, TextMessage textMsg) {
     50         super(cmdDet);
     51         mTextMsg = textMsg;
     52     }
     53 
     54     @Override
     55     boolean setIcon(Bitmap icon) {
     56         if (icon != null && mTextMsg != null) {
     57             mTextMsg.icon = icon;
     58             return true;
     59         }
     60         return false;
     61     }
     62 
     63     @Override
     64     public String toString() {
     65         return "TextMessage=" + mTextMsg + " " + super.toString();
     66     }
     67 }
     68 
     69 class LaunchBrowserParams extends CommandParams {
     70     TextMessage mConfirmMsg;
     71     LaunchBrowserMode mMode;
     72     String mUrl;
     73 
     74     LaunchBrowserParams(CommandDetails cmdDet, TextMessage confirmMsg,
     75             String url, LaunchBrowserMode mode) {
     76         super(cmdDet);
     77         mConfirmMsg = confirmMsg;
     78         mMode = mode;
     79         mUrl = url;
     80     }
     81 
     82     @Override
     83     boolean setIcon(Bitmap icon) {
     84         if (icon != null && mConfirmMsg != null) {
     85             mConfirmMsg.icon = icon;
     86             return true;
     87         }
     88         return false;
     89     }
     90 
     91     @Override
     92     public String toString() {
     93         return "TextMessage=" + mConfirmMsg + " " + super.toString();
     94     }
     95 }
     96 
     97 class SetEventListParams extends CommandParams {
     98     int[] mEventInfo;
     99     SetEventListParams(CommandDetails cmdDet, int[] eventInfo) {
    100         super(cmdDet);
    101         this.mEventInfo = eventInfo;
    102     }
    103 }
    104 
    105 class PlayToneParams extends CommandParams {
    106     TextMessage mTextMsg;
    107     ToneSettings mSettings;
    108 
    109     PlayToneParams(CommandDetails cmdDet, TextMessage textMsg,
    110             Tone tone, Duration duration, boolean vibrate) {
    111         super(cmdDet);
    112         mTextMsg = textMsg;
    113         mSettings = new ToneSettings(duration, tone, vibrate);
    114     }
    115 
    116     @Override
    117     boolean setIcon(Bitmap icon) {
    118         if (icon != null && mTextMsg != null) {
    119             mTextMsg.icon = icon;
    120             return true;
    121         }
    122         return false;
    123     }
    124 }
    125 
    126 class CallSetupParams extends CommandParams {
    127     TextMessage mConfirmMsg;
    128     TextMessage mCallMsg;
    129 
    130     CallSetupParams(CommandDetails cmdDet, TextMessage confirmMsg,
    131             TextMessage callMsg) {
    132         super(cmdDet);
    133         mConfirmMsg = confirmMsg;
    134         mCallMsg = callMsg;
    135     }
    136 
    137     @Override
    138     boolean setIcon(Bitmap icon) {
    139         if (icon == null) {
    140             return false;
    141         }
    142         if (mConfirmMsg != null && mConfirmMsg.icon == null) {
    143             mConfirmMsg.icon = icon;
    144             return true;
    145         } else if (mCallMsg != null && mCallMsg.icon == null) {
    146             mCallMsg.icon = icon;
    147             return true;
    148         }
    149         return false;
    150     }
    151 }
    152 
    153 class LanguageParams extends CommandParams {
    154     String mLanguage;
    155 
    156     LanguageParams(CommandDetails cmdDet, String lang) {
    157         super(cmdDet);
    158         mLanguage = lang;
    159     }
    160 }
    161 
    162 class SelectItemParams extends CommandParams {
    163     Menu mMenu = null;
    164     boolean mLoadTitleIcon = false;
    165 
    166     SelectItemParams(CommandDetails cmdDet, Menu menu, boolean loadTitleIcon) {
    167         super(cmdDet);
    168         mMenu = menu;
    169         mLoadTitleIcon = loadTitleIcon;
    170     }
    171 
    172     @Override
    173     boolean setIcon(Bitmap icon) {
    174         if (icon != null && mMenu != null) {
    175             if (mLoadTitleIcon && mMenu.titleIcon == null) {
    176                 mMenu.titleIcon = icon;
    177             } else {
    178                 for (Item item : mMenu.items) {
    179                     if (item.icon != null) {
    180                         continue;
    181                     }
    182                     item.icon = icon;
    183                     break;
    184                 }
    185             }
    186             return true;
    187         }
    188         return false;
    189     }
    190 }
    191 
    192 class GetInputParams extends CommandParams {
    193     Input mInput = null;
    194 
    195     GetInputParams(CommandDetails cmdDet, Input input) {
    196         super(cmdDet);
    197         mInput = input;
    198     }
    199 
    200     @Override
    201     boolean setIcon(Bitmap icon) {
    202         if (icon != null && mInput != null) {
    203             mInput.icon = icon;
    204         }
    205         return true;
    206     }
    207 }
    208 
    209 /*
    210  * BIP (Bearer Independent Protocol) is the mechanism for SIM card applications
    211  * to access data connection through the mobile device.
    212  *
    213  * SIM utilizes proactive commands (OPEN CHANNEL, CLOSE CHANNEL, SEND DATA and
    214  * RECEIVE DATA to control/read/write data for BIP. Refer to ETSI TS 102 223 for
    215  * the details of proactive commands procedures and their structures.
    216  */
    217 class BIPClientParams extends CommandParams {
    218     TextMessage mTextMsg;
    219     boolean mHasAlphaId;
    220 
    221     BIPClientParams(CommandDetails cmdDet, TextMessage textMsg, boolean has_alpha_id) {
    222         super(cmdDet);
    223         mTextMsg = textMsg;
    224         mHasAlphaId = has_alpha_id;
    225     }
    226 
    227     @Override
    228     boolean setIcon(Bitmap icon) {
    229         if (icon != null && mTextMsg != null) {
    230             mTextMsg.icon = icon;
    231             return true;
    232         }
    233         return false;
    234     }
    235 }
    236