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