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 SetEventListParams extends CommandParams { 86 int[] mEventInfo; 87 SetEventListParams(CommandDetails cmdDet, int[] eventInfo) { 88 super(cmdDet); 89 this.mEventInfo = eventInfo; 90 } 91 } 92 93 class PlayToneParams extends CommandParams { 94 TextMessage mTextMsg; 95 ToneSettings mSettings; 96 97 PlayToneParams(CommandDetails cmdDet, TextMessage textMsg, 98 Tone tone, Duration duration, boolean vibrate) { 99 super(cmdDet); 100 mTextMsg = textMsg; 101 mSettings = new ToneSettings(duration, tone, vibrate); 102 } 103 104 @Override 105 boolean setIcon(Bitmap icon) { 106 if (icon != null && mTextMsg != null) { 107 mTextMsg.icon = icon; 108 return true; 109 } 110 return false; 111 } 112 } 113 114 class CallSetupParams extends CommandParams { 115 TextMessage mConfirmMsg; 116 TextMessage mCallMsg; 117 118 CallSetupParams(CommandDetails cmdDet, TextMessage confirmMsg, 119 TextMessage callMsg) { 120 super(cmdDet); 121 mConfirmMsg = confirmMsg; 122 mCallMsg = callMsg; 123 } 124 125 @Override 126 boolean setIcon(Bitmap icon) { 127 if (icon == null) { 128 return false; 129 } 130 if (mConfirmMsg != null && mConfirmMsg.icon == null) { 131 mConfirmMsg.icon = icon; 132 return true; 133 } else if (mCallMsg != null && mCallMsg.icon == null) { 134 mCallMsg.icon = icon; 135 return true; 136 } 137 return false; 138 } 139 } 140 141 class SelectItemParams extends CommandParams { 142 Menu mMenu = null; 143 boolean mLoadTitleIcon = false; 144 145 SelectItemParams(CommandDetails cmdDet, Menu menu, boolean loadTitleIcon) { 146 super(cmdDet); 147 mMenu = menu; 148 mLoadTitleIcon = loadTitleIcon; 149 } 150 151 @Override 152 boolean setIcon(Bitmap icon) { 153 if (icon != null && mMenu != null) { 154 if (mLoadTitleIcon && mMenu.titleIcon == null) { 155 mMenu.titleIcon = icon; 156 } else { 157 for (Item item : mMenu.items) { 158 if (item.icon != null) { 159 continue; 160 } 161 item.icon = icon; 162 break; 163 } 164 } 165 return true; 166 } 167 return false; 168 } 169 } 170 171 class GetInputParams extends CommandParams { 172 Input mInput = null; 173 174 GetInputParams(CommandDetails cmdDet, Input input) { 175 super(cmdDet); 176 mInput = input; 177 } 178 179 @Override 180 boolean setIcon(Bitmap icon) { 181 if (icon != null && mInput != null) { 182 mInput.icon = icon; 183 } 184 return true; 185 } 186 } 187 188 /* 189 * BIP (Bearer Independent Protocol) is the mechanism for SIM card applications 190 * to access data connection through the mobile device. 191 * 192 * SIM utilizes proactive commands (OPEN CHANNEL, CLOSE CHANNEL, SEND DATA and 193 * RECEIVE DATA to control/read/write data for BIP. Refer to ETSI TS 102 223 for 194 * the details of proactive commands procedures and their structures. 195 */ 196 class BIPClientParams extends CommandParams { 197 TextMessage mTextMsg; 198 boolean mHasAlphaId; 199 200 BIPClientParams(CommandDetails cmdDet, TextMessage textMsg, boolean has_alpha_id) { 201 super(cmdDet); 202 mTextMsg = textMsg; 203 mHasAlphaId = has_alpha_id; 204 } 205 206 @Override 207 boolean setIcon(Bitmap icon) { 208 if (icon != null && mTextMsg != null) { 209 mTextMsg.icon = icon; 210 return true; 211 } 212 return false; 213 } 214 } 215