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