CommandParams.java revision 0825495a331bb44df395a0cdb79fab85e68db5d5
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    boolean setIcon(Bitmap icon) {
53        if (icon != null && textMsg != null) {
54            textMsg.icon = icon;
55            return true;
56        }
57        return false;
58    }
59}
60
61class LaunchBrowserParams extends CommandParams {
62    TextMessage confirmMsg;
63    LaunchBrowserMode mode;
64    String url;
65
66    LaunchBrowserParams(CommandDetails cmdDet, TextMessage confirmMsg,
67            String url, LaunchBrowserMode mode) {
68        super(cmdDet);
69        this.confirmMsg = confirmMsg;
70        this.mode = mode;
71        this.url = url;
72    }
73
74    boolean setIcon(Bitmap icon) {
75        if (icon != null && confirmMsg != null) {
76            confirmMsg.icon = icon;
77            return true;
78        }
79        return false;
80    }
81}
82
83class PlayToneParams extends CommandParams {
84    TextMessage textMsg;
85    ToneSettings settings;
86
87    PlayToneParams(CommandDetails cmdDet, TextMessage textMsg,
88            Tone tone, Duration duration, boolean vibrate) {
89        super(cmdDet);
90        this.textMsg = textMsg;
91        this.settings = new ToneSettings(duration, tone, vibrate);
92    }
93
94    boolean setIcon(Bitmap icon) {
95        if (icon != null && textMsg != null) {
96            textMsg.icon = icon;
97            return true;
98        }
99        return false;
100    }
101}
102
103class CallSetupParams extends CommandParams {
104    TextMessage confirmMsg;
105    TextMessage callMsg;
106
107    CallSetupParams(CommandDetails cmdDet, TextMessage confirmMsg,
108            TextMessage callMsg) {
109        super(cmdDet);
110        this.confirmMsg = confirmMsg;
111        this.callMsg = callMsg;
112    }
113
114    boolean setIcon(Bitmap icon) {
115        if (icon == null) {
116            return false;
117        }
118        if (confirmMsg != null && confirmMsg.icon == null) {
119            confirmMsg.icon = icon;
120            return true;
121        } else if (callMsg != null && callMsg.icon == null) {
122            callMsg.icon = icon;
123            return true;
124        }
125        return false;
126    }
127}
128
129class SelectItemParams extends CommandParams {
130    Menu menu = null;
131    boolean loadTitleIcon = false;
132
133    SelectItemParams(CommandDetails cmdDet, Menu menu, boolean loadTitleIcon) {
134        super(cmdDet);
135        this.menu = menu;
136        this.loadTitleIcon = loadTitleIcon;
137    }
138
139    boolean setIcon(Bitmap icon) {
140        if (icon != null && menu != null) {
141            if (loadTitleIcon && menu.titleIcon == null) {
142                menu.titleIcon = icon;
143            } else {
144                for (Item item : menu.items) {
145                    if (item.icon != null) {
146                        continue;
147                    }
148                    item.icon = icon;
149                    break;
150                }
151            }
152            return true;
153        }
154        return false;
155    }
156}
157
158class GetInputParams extends CommandParams {
159    Input input = null;
160
161    GetInputParams(CommandDetails cmdDet, Input input) {
162        super(cmdDet);
163        this.input = input;
164    }
165
166    boolean setIcon(Bitmap icon) {
167        if (icon != null && input != null) {
168            input.icon = icon;
169        }
170        return true;
171    }
172}
173
174/*
175 * BIP (Bearer Independent Protocol) is the mechanism for SIM card applications
176 * to access data connection through the mobile device.
177 *
178 * SIM utilizes proactive commands (OPEN CHANNEL, CLOSE CHANNEL, SEND DATA and
179 * RECEIVE DATA to control/read/write data for BIP. Refer to ETSI TS 102 223 for
180 * the details of proactive commands procedures and their structures.
181 */
182class BIPClientParams extends CommandParams {
183    TextMessage textMsg;
184    boolean bHasAlphaId;
185
186    BIPClientParams(CommandDetails cmdDet, TextMessage textMsg, boolean has_alpha_id) {
187        super(cmdDet);
188        this.textMsg = textMsg;
189        this.bHasAlphaId = has_alpha_id;
190    }
191
192    boolean setIcon(Bitmap icon) {
193        if (icon != null && textMsg != null) {
194            textMsg.icon = icon;
195            return true;
196        }
197        return false;
198    }
199}
200