Skip to content

Commit efd617e

Browse files
Wink SavilleAndroid Git Automerger
authored andcommitted
am 0ad96f8: am d4d3516: Merge "Add support of dislaying Alpha tag for BIP commands" into ics-mr1
* commit '0ad96f89401920486b68d8404f6a143870d57500': Add support of dislaying Alpha tag for BIP commands
2 parents 7da207b + 0ad96f8 commit efd617e

File tree

5 files changed

+150
-11
lines changed

5 files changed

+150
-11
lines changed

telephony/java/com/android/internal/telephony/cat/AppInterface.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public interface AppInterface {
4242
* Enumeration for representing "Type of Command" of proactive commands.
4343
* Those are the only commands which are supported by the Telephony. Any app
4444
* implementation should support those.
45+
* Refer to ETSI TS 102.223 section 9.4
4546
*/
4647
public static enum CommandType {
4748
DISPLAY_TEXT(0x21),
@@ -59,7 +60,11 @@ public static enum CommandType {
5960
SET_UP_IDLE_MODE_TEXT(0x28),
6061
SET_UP_MENU(0x25),
6162
SET_UP_CALL(0x10),
62-
PROVIDE_LOCAL_INFORMATION(0x26);
63+
PROVIDE_LOCAL_INFORMATION(0x26),
64+
OPEN_CHANNEL(0x40),
65+
CLOSE_CHANNEL(0x41),
66+
RECEIVE_DATA(0x42),
67+
SEND_DATA(0x43);
6368

6469
private int mValue;
6570

telephony/java/com/android/internal/telephony/cat/CatCmdMessage.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ public class CallSettings {
8585
mCallSettings.confirmMsg = ((CallSetupParams) cmdParams).confirmMsg;
8686
mCallSettings.callMsg = ((CallSetupParams) cmdParams).callMsg;
8787
break;
88+
case OPEN_CHANNEL:
89+
case CLOSE_CHANNEL:
90+
case RECEIVE_DATA:
91+
case SEND_DATA:
92+
BIPClientParams param = (BIPClientParams) cmdParams;
93+
mTextMsg = param.textMsg;
94+
break;
8895
}
8996
}
9097

telephony/java/com/android/internal/telephony/cat/CatService.java

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import android.content.Context;
2020
import android.content.Intent;
21+
import android.content.pm.PackageManager;
22+
import android.content.pm.ResolveInfo;
2123
import android.os.AsyncResult;
2224
import android.os.Handler;
2325
import android.os.HandlerThread;
@@ -32,6 +34,7 @@
3234

3335

3436
import java.io.ByteArrayOutputStream;
37+
import java.util.List;
3538
import java.util.Locale;
3639

3740
class RilMessage {
@@ -72,6 +75,7 @@ public class CatService extends Handler implements AppInterface {
7275
private CatCmdMessage mMenuCmd = null;
7376

7477
private RilMessageDecoder mMsgDecoder = null;
78+
private boolean mStkAppInstalled = false;
7579

7680
// Service constants.
7781
static final int MSG_ID_SESSION_END = 1;
@@ -123,7 +127,10 @@ private CatService(CommandsInterface ci, IccRecords ir, Context context,
123127
ic.registerForReady(this, MSG_ID_SIM_READY, null);
124128
mIccRecords.registerForRecordsLoaded(this, MSG_ID_ICC_RECORDS_LOADED, null);
125129

126-
CatLog.d(this, "Is running");
130+
// Check if STK application is availalbe
131+
mStkAppInstalled = isStkAppInstalled();
132+
133+
CatLog.d(this, "Running CAT service. STK app installed:" + mStkAppInstalled);
127134
}
128135

129136
public void dispose() {
@@ -152,7 +159,7 @@ private void handleRilMsg(RilMessage rilMsg) {
152159
if (rilMsg.mResCode == ResultCode.OK) {
153160
cmdParams = (CommandParams) rilMsg.mData;
154161
if (cmdParams != null) {
155-
handleProactiveCommand(cmdParams);
162+
handleCommand(cmdParams, false);
156163
}
157164
}
158165
break;
@@ -168,7 +175,7 @@ private void handleRilMsg(RilMessage rilMsg) {
168175
}
169176
if (cmdParams != null) {
170177
if (rilMsg.mResCode == ResultCode.OK) {
171-
handleProactiveCommand(cmdParams);
178+
handleCommand(cmdParams, true);
172179
} else {
173180
// for proactive commands that couldn't be decoded
174181
// successfully respond with the code generated by the
@@ -181,7 +188,7 @@ private void handleRilMsg(RilMessage rilMsg) {
181188
case MSG_ID_REFRESH:
182189
cmdParams = (CommandParams) rilMsg.mData;
183190
if (cmdParams != null) {
184-
handleProactiveCommand(cmdParams);
191+
handleCommand(cmdParams, false);
185192
}
186193
break;
187194
case MSG_ID_SESSION_END:
@@ -195,11 +202,13 @@ private void handleRilMsg(RilMessage rilMsg) {
195202
}
196203

197204
/**
198-
* Handles RIL_UNSOL_STK_PROACTIVE_COMMAND unsolicited command from RIL.
205+
* Handles RIL_UNSOL_STK_EVENT_NOTIFY or RIL_UNSOL_STK_PROACTIVE_COMMAND command
206+
* from RIL.
199207
* Sends valid proactive command data to the application using intents.
200-
*
208+
* RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE will be send back if the command is
209+
* from RIL_UNSOL_STK_PROACTIVE_COMMAND.
201210
*/
202-
private void handleProactiveCommand(CommandParams cmdParams) {
211+
private void handleCommand(CommandParams cmdParams, boolean isProactiveCmd) {
203212
CatLog.d(this, cmdParams.getCommandType().name());
204213

205214
CharSequence message;
@@ -233,15 +242,16 @@ private void handleProactiveCommand(CommandParams cmdParams) {
233242
case CommandParamsFactory.DTTZ_SETTING:
234243
resp = new DTTZResponseData(null);
235244
sendTerminalResponse(cmdParams.cmdDet, ResultCode.OK, false, 0, resp);
236-
return;
245+
break;
237246
case CommandParamsFactory.LANGUAGE_SETTING:
238247
resp = new LanguageResponseData(Locale.getDefault().getLanguage());
239248
sendTerminalResponse(cmdParams.cmdDet, ResultCode.OK, false, 0, resp);
240-
return;
249+
break;
241250
default:
242251
sendTerminalResponse(cmdParams.cmdDet, ResultCode.OK, false, 0, null);
243-
return;
244252
}
253+
// No need to start STK app here.
254+
return;
245255
case LAUNCH_BROWSER:
246256
if ((((LaunchBrowserParams) cmdParams).confirmMsg.text != null)
247257
&& (((LaunchBrowserParams) cmdParams).confirmMsg.text.equals(STK_DEFAULT))) {
@@ -272,6 +282,42 @@ private void handleProactiveCommand(CommandParams cmdParams) {
272282
((CallSetupParams) cmdParams).confirmMsg.text = message.toString();
273283
}
274284
break;
285+
case OPEN_CHANNEL:
286+
case CLOSE_CHANNEL:
287+
case RECEIVE_DATA:
288+
case SEND_DATA:
289+
BIPClientParams cmd = (BIPClientParams) cmdParams;
290+
if (cmd.bHasAlphaId && (cmd.textMsg.text == null)) {
291+
CatLog.d(this, "cmd " + cmdParams.getCommandType() + " with null alpha id");
292+
// If alpha length is zero, we just respond with OK.
293+
if (isProactiveCmd) {
294+
sendTerminalResponse(cmdParams.cmdDet, ResultCode.OK, false, 0, null);
295+
}
296+
return;
297+
}
298+
// Respond with permanent failure to avoid retry if STK app is not present.
299+
if (!mStkAppInstalled) {
300+
CatLog.d(this, "No STK application found.");
301+
if (isProactiveCmd) {
302+
sendTerminalResponse(cmdParams.cmdDet,
303+
ResultCode.BEYOND_TERMINAL_CAPABILITY,
304+
false, 0, null);
305+
return;
306+
}
307+
}
308+
/*
309+
* CLOSE_CHANNEL, RECEIVE_DATA and SEND_DATA can be delivered by
310+
* either PROACTIVE_COMMAND or EVENT_NOTIFY.
311+
* If PROACTIVE_COMMAND is used for those commands, send terminal
312+
* response here.
313+
*/
314+
if (isProactiveCmd &&
315+
((cmdParams.getCommandType() == CommandType.CLOSE_CHANNEL) ||
316+
(cmdParams.getCommandType() == CommandType.RECEIVE_DATA) ||
317+
(cmdParams.getCommandType() == CommandType.SEND_DATA))) {
318+
sendTerminalResponse(cmdParams.cmdDet, ResultCode.OK, false, 0, null);
319+
}
320+
break;
275321
default:
276322
CatLog.d(this, "Unsupported command");
277323
return;
@@ -682,6 +728,7 @@ private void handleCmdResponse(CatResponseMessage resMsg) {
682728
case NO_RESPONSE_FROM_USER:
683729
case UICC_SESSION_TERM_BY_USER:
684730
case BACKWARD_MOVE_BY_USER:
731+
case USER_NOT_ACCEPT:
685732
resp = null;
686733
break;
687734
default:
@@ -690,4 +737,14 @@ private void handleCmdResponse(CatResponseMessage resMsg) {
690737
sendTerminalResponse(cmdDet, resMsg.resCode, false, 0, resp);
691738
mCurrntCmd = null;
692739
}
740+
741+
private boolean isStkAppInstalled() {
742+
Intent intent = new Intent(AppInterface.CAT_CMD_ACTION);
743+
PackageManager pm = mContext.getPackageManager();
744+
List<ResolveInfo> broadcastReceivers =
745+
pm.queryBroadcastReceivers(intent, PackageManager.GET_META_DATA);
746+
int numReceiver = broadcastReceivers == null ? 0 : broadcastReceivers.size();
747+
748+
return (numReceiver > 0);
749+
}
693750
}

telephony/java/com/android/internal/telephony/cat/CommandParams.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,29 @@ boolean setIcon(Bitmap icon) {
166166
}
167167
}
168168

169+
/*
170+
* BIP (Bearer Independent Protocol) is the mechanism for SIM card applications
171+
* to access data connection through the mobile device.
172+
*
173+
* SIM utilizes proactive commands (OPEN CHANNEL, CLOSE CHANNEL, SEND DATA and
174+
* RECEIVE DATA to control/read/write data for BIP. Refer to ETSI TS 102 223 for
175+
* the details of proactive commands procedures and their structures.
176+
*/
177+
class BIPClientParams extends CommandParams {
178+
TextMessage textMsg;
179+
boolean bHasAlphaId;
180+
181+
BIPClientParams(CommandDetails cmdDet, TextMessage textMsg, boolean has_alpha_id) {
182+
super(cmdDet);
183+
this.textMsg = textMsg;
184+
this.bHasAlphaId = has_alpha_id;
185+
}
169186

187+
boolean setIcon(Bitmap icon) {
188+
if (icon != null && textMsg != null) {
189+
textMsg.icon = icon;
190+
return true;
191+
}
192+
return false;
193+
}
194+
}

telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ void make(BerTlv berTlv) {
165165
case PROVIDE_LOCAL_INFORMATION:
166166
cmdPending = processProvideLocalInfo(cmdDet, ctlvs);
167167
break;
168+
case OPEN_CHANNEL:
169+
case CLOSE_CHANNEL:
170+
case RECEIVE_DATA:
171+
case SEND_DATA:
172+
cmdPending = processBIPClient(cmdDet, ctlvs);
173+
break;
168174
default:
169175
// unsupported proactive commands
170176
mCmdParams = new CommandParams(cmdDet);
@@ -893,4 +899,43 @@ private boolean processProvideLocalInfo(CommandDetails cmdDet, List<Comprehensio
893899
}
894900
return false;
895901
}
902+
903+
private boolean processBIPClient(CommandDetails cmdDet,
904+
List<ComprehensionTlv> ctlvs) throws ResultException {
905+
AppInterface.CommandType commandType =
906+
AppInterface.CommandType.fromInt(cmdDet.typeOfCommand);
907+
if (commandType != null) {
908+
CatLog.d(this, "process "+ commandType.name());
909+
}
910+
911+
TextMessage textMsg = new TextMessage();
912+
IconId iconId = null;
913+
ComprehensionTlv ctlv = null;
914+
boolean has_alpha_id = false;
915+
916+
// parse alpha identifier
917+
ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID, ctlvs);
918+
if (ctlv != null) {
919+
textMsg.text = ValueParser.retrieveAlphaId(ctlv);
920+
CatLog.d(this, "alpha TLV text=" + textMsg.text);
921+
has_alpha_id = true;
922+
}
923+
924+
// parse icon identifier
925+
ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs);
926+
if (ctlv != null) {
927+
iconId = ValueParser.retrieveIconId(ctlv);
928+
textMsg.iconSelfExplanatory = iconId.selfExplanatory;
929+
}
930+
931+
textMsg.responseNeeded = false;
932+
mCmdParams = new BIPClientParams(cmdDet, textMsg, has_alpha_id);
933+
934+
if (iconId != null) {
935+
mIconLoadState = LOAD_SINGLE_ICON;
936+
mIconLoader.loadIcon(iconId.recordNumber, this.obtainMessage(MSG_ID_LOAD_ICON_DONE));
937+
return true;
938+
}
939+
return false;
940+
}
896941
}

0 commit comments

Comments
 (0)