blob: 517c70a821f669f20cdf1d88728f19e3f6bb5474 [file] [log] [blame]
The Android Open Source Project9d9730a2009-03-03 19:32:37 -08001/*
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.stk;
18
Alex Yakavenkad41f1d92010-07-12 14:13:13 -070019import com.android.internal.telephony.cat.AppInterface;
Wink Saville94e982b2014-07-11 07:38:14 -070020import com.android.internal.telephony.uicc.IccRefreshResponse;
Wink Savillee68857d2014-10-17 15:23:05 -070021import com.android.internal.telephony.cat.CatLog;
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080022import android.content.BroadcastReceiver;
23import android.content.Context;
24import android.content.Intent;
25import android.os.Bundle;
26
Wink Savillee68857d2014-10-17 15:23:05 -070027import com.android.internal.telephony.cat.AppInterface;
28
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080029/**
30 * Receiver class to get STK intents, broadcasted by telephony layer.
Wink Saville79085fc2009-06-09 10:27:23 -070031 *
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080032 */
33public class StkCmdReceiver extends BroadcastReceiver {
Yoshiaki Naka3a980db2019-10-30 17:11:33 +090034 private static final String LOG_TAG =
35 new Object(){}.getClass().getEnclosingClass().getSimpleName();
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080036
37 @Override
38 public void onReceive(Context context, Intent intent) {
39 String action = intent.getAction();
Teruaki Minami3f2bd962015-11-12 17:41:13 +010040 if (action == null) {
41 return;
42 }
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080043
Alex Yakavenkad41f1d92010-07-12 14:13:13 -070044 if (action.equals(AppInterface.CAT_CMD_ACTION)) {
Wink Savillee68857d2014-10-17 15:23:05 -070045 handleAction(context, intent, StkAppService.OP_CMD);
Alex Yakavenkad41f1d92010-07-12 14:13:13 -070046 } else if (action.equals(AppInterface.CAT_SESSION_END_ACTION)) {
Wink Savillee68857d2014-10-17 15:23:05 -070047 handleAction(context, intent, StkAppService.OP_END_SESSION);
Wink Saville94e982b2014-07-11 07:38:14 -070048 } else if (action.equals(AppInterface.CAT_ICC_STATUS_CHANGE)) {
Wink Savillee68857d2014-10-17 15:23:05 -070049 handleAction(context, intent, StkAppService.OP_CARD_STATUS_CHANGED);
Preeti Ahuja0f4cf2f2012-08-09 11:45:08 +053050 } else if (action.equals(AppInterface.CAT_ALPHA_NOTIFY_ACTION)) {
51 handleAction(context, intent, StkAppService.OP_ALPHA_NOTIFY);
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080052 }
53 }
54
Wink Savillee68857d2014-10-17 15:23:05 -070055 private void handleAction(Context context, Intent intent, int op) {
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080056 Bundle args = new Bundle();
Preeti Ahuja0f4cf2f2012-08-09 11:45:08 +053057 int slot_id = intent.getIntExtra(StkAppService.SLOT_ID, 0);
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080058
Wink Savillee68857d2014-10-17 15:23:05 -070059 args.putInt(StkAppService.OPCODE, op);
60 args.putInt(StkAppService.SLOT_ID, slot_id);
Wink Saville94e982b2014-07-11 07:38:14 -070061
Wink Savillee68857d2014-10-17 15:23:05 -070062 if (StkAppService.OP_CMD == op) {
63 args.putParcelable(StkAppService.CMD_MSG, intent
64 .getParcelableExtra(StkAppService.STK_CMD));
65 } else if (StkAppService.OP_CARD_STATUS_CHANGED == op) {
66 // If the Card is absent then check if the StkAppService is even
67 // running before starting it to stop it right away
68 if ((intent.getBooleanExtra(AppInterface.CARD_STATUS, false) == false)
69 && StkAppService.getInstance() == null) {
70 return;
71 }
72
73 args.putBoolean(AppInterface.CARD_STATUS,
74 intent.getBooleanExtra(AppInterface.CARD_STATUS, true));
75 args.putInt(AppInterface.REFRESH_RESULT,
76 intent.getIntExtra(AppInterface.REFRESH_RESULT,
77 IccRefreshResponse.REFRESH_RESULT_FILE_UPDATE));
Umashankar Godachi40a72f72017-09-12 15:16:55 +053078 args.putString(AppInterface.AID, intent.getStringExtra(AppInterface.AID));
Preeti Ahuja0f4cf2f2012-08-09 11:45:08 +053079 } else if (StkAppService.OP_ALPHA_NOTIFY == op) {
80 String alphaString = intent.getStringExtra(AppInterface.ALPHA_STRING);
81 args.putString(AppInterface.ALPHA_STRING, alphaString);
Wink Saville94e982b2014-07-11 07:38:14 -070082 }
Preeti Ahuja0f4cf2f2012-08-09 11:45:08 +053083
Yoshiaki Naka3a980db2019-10-30 17:11:33 +090084 CatLog.d(LOG_TAG, "handleAction, op: " + op +
Wink Savillee68857d2014-10-17 15:23:05 -070085 "args: " + args + ", slot id: " + slot_id);
86 Intent toService = new Intent(context, StkAppService.class);
87 toService.putExtras(args);
88 context.startService(toService);
Wink Saville94e982b2014-07-11 07:38:14 -070089 }
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080090}