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 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 39 class DisplayTextParams extends CommandParams { 40 TextMessage textMsg; 41 42 DisplayTextParams(CommandDetails cmdDet, TextMessage textMsg) { 43 super(cmdDet); 44 this.textMsg = textMsg; 45 } 46 47 boolean setIcon(Bitmap icon) { 48 if (icon != null && textMsg != null) { 49 textMsg.icon = icon; 50 return true; 51 } 52 return false; 53 } 54 } 55 56 class LaunchBrowserParams extends CommandParams { 57 TextMessage confirmMsg; 58 LaunchBrowserMode mode; 59 String url; 60 61 LaunchBrowserParams(CommandDetails cmdDet, TextMessage confirmMsg, 62 String url, LaunchBrowserMode mode) { 63 super(cmdDet); 64 this.confirmMsg = confirmMsg; 65 this.mode = mode; 66 this.url = url; 67 } 68 69 boolean setIcon(Bitmap icon) { 70 if (icon != null && confirmMsg != null) { 71 confirmMsg.icon = icon; 72 return true; 73 } 74 return false; 75 } 76 } 77 78 class PlayToneParams extends CommandParams { 79 TextMessage textMsg; 80 ToneSettings settings; 81 82 PlayToneParams(CommandDetails cmdDet, TextMessage textMsg, 83 Tone tone, Duration duration, boolean vibrate) { 84 super(cmdDet); 85 this.textMsg = textMsg; 86 this.settings = new ToneSettings(duration, tone, vibrate); 87 } 88 89 boolean setIcon(Bitmap icon) { 90 if (icon != null && textMsg != null) { 91 textMsg.icon = icon; 92 return true; 93 } 94 return false; 95 } 96 } 97 98 class CallSetupParams extends CommandParams { 99 TextMessage confirmMsg; 100 TextMessage callMsg; 101 102 CallSetupParams(CommandDetails cmdDet, TextMessage confirmMsg, 103 TextMessage callMsg) { 104 super(cmdDet); 105 this.confirmMsg = confirmMsg; 106 this.callMsg = callMsg; 107 } 108 109 boolean setIcon(Bitmap icon) { 110 if (icon == null) { 111 return false; 112 } 113 if (confirmMsg != null && confirmMsg.icon == null) { 114 confirmMsg.icon = icon; 115 return true; 116 } else if (callMsg != null && callMsg.icon == null) { 117 callMsg.icon = icon; 118 return true; 119 } 120 return false; 121 } 122 } 123 124 class SelectItemParams extends CommandParams { 125 Menu menu = null; 126 boolean loadTitleIcon = false; 127 128 SelectItemParams(CommandDetails cmdDet, Menu menu, boolean loadTitleIcon) { 129 super(cmdDet); 130 this.menu = menu; 131 this.loadTitleIcon = loadTitleIcon; 132 } 133 134 boolean setIcon(Bitmap icon) { 135 if (icon != null && menu != null) { 136 if (loadTitleIcon && menu.titleIcon == null) { 137 menu.titleIcon = icon; 138 } else { 139 for (Item item : menu.items) { 140 if (item.icon != null) { 141 continue; 142 } 143 item.icon = icon; 144 break; 145 } 146 } 147 return true; 148 } 149 return false; 150 } 151 } 152 153 class GetInputParams extends CommandParams { 154 Input input = null; 155 156 GetInputParams(CommandDetails cmdDet, Input input) { 157 super(cmdDet); 158 this.input = input; 159 } 160 161 boolean setIcon(Bitmap icon) { 162 if (icon != null && input != null) { 163 input.icon = icon; 164 } 165 return true; 166 } 167 } 168 169 170