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 CommandParams(CommandDetails cmdDet)30 CommandParams(CommandDetails cmdDet) { 31 mCmdDet = cmdDet; 32 } 33 getCommandType()34 AppInterface.CommandType getCommandType() { 35 return AppInterface.CommandType.fromInt(mCmdDet.typeOfCommand); 36 } 37 setIcon(Bitmap icon)38 boolean setIcon(Bitmap icon) { return true; } 39 40 @Override toString()41 public String toString() { 42 return mCmdDet.toString(); 43 } 44 } 45 46 class DisplayTextParams extends CommandParams { 47 TextMessage mTextMsg; 48 DisplayTextParams(CommandDetails cmdDet, TextMessage textMsg)49 DisplayTextParams(CommandDetails cmdDet, TextMessage textMsg) { 50 super(cmdDet); 51 mTextMsg = textMsg; 52 } 53 54 @Override setIcon(Bitmap icon)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 toString()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 LaunchBrowserParams(CommandDetails cmdDet, TextMessage confirmMsg, String url, LaunchBrowserMode mode)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 setIcon(Bitmap icon)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 toString()92 public String toString() { 93 return "TextMessage=" + mConfirmMsg + " " + super.toString(); 94 } 95 } 96 97 class SetEventListParams extends CommandParams { 98 int[] mEventInfo; SetEventListParams(CommandDetails cmdDet, int[] eventInfo)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 PlayToneParams(CommandDetails cmdDet, TextMessage textMsg, Tone tone, Duration duration, boolean vibrate)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 setIcon(Bitmap icon)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 CallSetupParams(CommandDetails cmdDet, TextMessage confirmMsg, TextMessage callMsg)130 CallSetupParams(CommandDetails cmdDet, TextMessage confirmMsg, 131 TextMessage callMsg) { 132 super(cmdDet); 133 mConfirmMsg = confirmMsg; 134 mCallMsg = callMsg; 135 } 136 137 @Override setIcon(Bitmap icon)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 SelectItemParams extends CommandParams { 154 Menu mMenu = null; 155 boolean mLoadTitleIcon = false; 156 SelectItemParams(CommandDetails cmdDet, Menu menu, boolean loadTitleIcon)157 SelectItemParams(CommandDetails cmdDet, Menu menu, boolean loadTitleIcon) { 158 super(cmdDet); 159 mMenu = menu; 160 mLoadTitleIcon = loadTitleIcon; 161 } 162 163 @Override setIcon(Bitmap icon)164 boolean setIcon(Bitmap icon) { 165 if (icon != null && mMenu != null) { 166 if (mLoadTitleIcon && mMenu.titleIcon == null) { 167 mMenu.titleIcon = icon; 168 } else { 169 for (Item item : mMenu.items) { 170 if (item.icon != null) { 171 continue; 172 } 173 item.icon = icon; 174 break; 175 } 176 } 177 return true; 178 } 179 return false; 180 } 181 } 182 183 class GetInputParams extends CommandParams { 184 Input mInput = null; 185 GetInputParams(CommandDetails cmdDet, Input input)186 GetInputParams(CommandDetails cmdDet, Input input) { 187 super(cmdDet); 188 mInput = input; 189 } 190 191 @Override setIcon(Bitmap icon)192 boolean setIcon(Bitmap icon) { 193 if (icon != null && mInput != null) { 194 mInput.icon = icon; 195 } 196 return true; 197 } 198 } 199 200 /* 201 * BIP (Bearer Independent Protocol) is the mechanism for SIM card applications 202 * to access data connection through the mobile device. 203 * 204 * SIM utilizes proactive commands (OPEN CHANNEL, CLOSE CHANNEL, SEND DATA and 205 * RECEIVE DATA to control/read/write data for BIP. Refer to ETSI TS 102 223 for 206 * the details of proactive commands procedures and their structures. 207 */ 208 class BIPClientParams extends CommandParams { 209 TextMessage mTextMsg; 210 boolean mHasAlphaId; 211 BIPClientParams(CommandDetails cmdDet, TextMessage textMsg, boolean has_alpha_id)212 BIPClientParams(CommandDetails cmdDet, TextMessage textMsg, boolean has_alpha_id) { 213 super(cmdDet); 214 mTextMsg = textMsg; 215 mHasAlphaId = has_alpha_id; 216 } 217 218 @Override setIcon(Bitmap icon)219 boolean setIcon(Bitmap icon) { 220 if (icon != null && mTextMsg != null) { 221 mTextMsg.icon = icon; 222 return true; 223 } 224 return false; 225 } 226 } 227