CommandParams.java revision cbaa45bbf2cab852b6c9c3a887e9f803d4e857ea
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 17package com.android.internal.telephony.cat; 18 19import android.graphics.Bitmap; 20 21/** 22 * Container class for proactive command parameters. 23 * 24 */ 25class CommandParams { 26 CommandDetails cmdDet; 27 28 CommandParams(CommandDetails cmdDet) { 29 this.cmdDet = cmdDet; 30 } 31 32 AppInterface.CommandType getCommandType() { 33 return AppInterface.CommandType.fromInt(cmdDet.typeOfCommand); 34 } 35 36 boolean setIcon(Bitmap icon) { return true; } 37 38 @Override 39 public String toString() { 40 return cmdDet.toString(); 41 } 42} 43 44class DisplayTextParams extends CommandParams { 45 TextMessage textMsg; 46 47 DisplayTextParams(CommandDetails cmdDet, TextMessage textMsg) { 48 super(cmdDet); 49 this.textMsg = textMsg; 50 } 51 52 @Override 53 boolean setIcon(Bitmap icon) { 54 if (icon != null && textMsg != null) { 55 textMsg.icon = icon; 56 return true; 57 } 58 return false; 59 } 60} 61 62class LaunchBrowserParams extends CommandParams { 63 TextMessage confirmMsg; 64 LaunchBrowserMode mode; 65 String url; 66 67 LaunchBrowserParams(CommandDetails cmdDet, TextMessage confirmMsg, 68 String url, LaunchBrowserMode mode) { 69 super(cmdDet); 70 this.confirmMsg = confirmMsg; 71 this.mode = mode; 72 this.url = url; 73 } 74 75 @Override 76 boolean setIcon(Bitmap icon) { 77 if (icon != null && confirmMsg != null) { 78 confirmMsg.icon = icon; 79 return true; 80 } 81 return false; 82 } 83} 84 85class PlayToneParams extends CommandParams { 86 TextMessage textMsg; 87 ToneSettings settings; 88 89 PlayToneParams(CommandDetails cmdDet, TextMessage textMsg, 90 Tone tone, Duration duration, boolean vibrate) { 91 super(cmdDet); 92 this.textMsg = textMsg; 93 this.settings = new ToneSettings(duration, tone, vibrate); 94 } 95 96 @Override 97 boolean setIcon(Bitmap icon) { 98 if (icon != null && textMsg != null) { 99 textMsg.icon = icon; 100 return true; 101 } 102 return false; 103 } 104} 105 106class CallSetupParams extends CommandParams { 107 TextMessage confirmMsg; 108 TextMessage callMsg; 109 110 CallSetupParams(CommandDetails cmdDet, TextMessage confirmMsg, 111 TextMessage callMsg) { 112 super(cmdDet); 113 this.confirmMsg = confirmMsg; 114 this.callMsg = callMsg; 115 } 116 117 @Override 118 boolean setIcon(Bitmap icon) { 119 if (icon == null) { 120 return false; 121 } 122 if (confirmMsg != null && confirmMsg.icon == null) { 123 confirmMsg.icon = icon; 124 return true; 125 } else if (callMsg != null && callMsg.icon == null) { 126 callMsg.icon = icon; 127 return true; 128 } 129 return false; 130 } 131} 132 133class SelectItemParams extends CommandParams { 134 Menu menu = null; 135 boolean loadTitleIcon = false; 136 137 SelectItemParams(CommandDetails cmdDet, Menu menu, boolean loadTitleIcon) { 138 super(cmdDet); 139 this.menu = menu; 140 this.loadTitleIcon = loadTitleIcon; 141 } 142 143 @Override 144 boolean setIcon(Bitmap icon) { 145 if (icon != null && menu != null) { 146 if (loadTitleIcon && menu.titleIcon == null) { 147 menu.titleIcon = icon; 148 } else { 149 for (Item item : menu.items) { 150 if (item.icon != null) { 151 continue; 152 } 153 item.icon = icon; 154 break; 155 } 156 } 157 return true; 158 } 159 return false; 160 } 161} 162 163class GetInputParams extends CommandParams { 164 Input input = null; 165 166 GetInputParams(CommandDetails cmdDet, Input input) { 167 super(cmdDet); 168 this.input = input; 169 } 170 171 @Override 172 boolean setIcon(Bitmap icon) { 173 if (icon != null && input != null) { 174 input.icon = icon; 175 } 176 return true; 177 } 178} 179 180/* 181 * BIP (Bearer Independent Protocol) is the mechanism for SIM card applications 182 * to access data connection through the mobile device. 183 * 184 * SIM utilizes proactive commands (OPEN CHANNEL, CLOSE CHANNEL, SEND DATA and 185 * RECEIVE DATA to control/read/write data for BIP. Refer to ETSI TS 102 223 for 186 * the details of proactive commands procedures and their structures. 187 */ 188class BIPClientParams extends CommandParams { 189 TextMessage textMsg; 190 boolean bHasAlphaId; 191 192 BIPClientParams(CommandDetails cmdDet, TextMessage textMsg, boolean has_alpha_id) { 193 super(cmdDet); 194 this.textMsg = textMsg; 195 this.bHasAlphaId = has_alpha_id; 196 } 197 198 @Override 199 boolean setIcon(Bitmap icon) { 200 if (icon != null && textMsg != null) { 201 textMsg.icon = icon; 202 return true; 203 } 204 return false; 205 } 206} 207