The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 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.stk; |
| 18 | |
Alex Yakavenka | d41f1d9 | 2010-07-12 14:13:13 -0700 | [diff] [blame] | 19 | import com.android.internal.telephony.cat.AppInterface; |
Wink Saville | 94e982b | 2014-07-11 07:38:14 -0700 | [diff] [blame] | 20 | import com.android.internal.telephony.uicc.IccRefreshResponse; |
Wink Saville | e68857d | 2014-10-17 15:23:05 -0700 | [diff] [blame] | 21 | import com.android.internal.telephony.cat.CatLog; |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 22 | import android.content.BroadcastReceiver; |
| 23 | import android.content.Context; |
| 24 | import android.content.Intent; |
| 25 | import android.os.Bundle; |
| 26 | |
Wink Saville | e68857d | 2014-10-17 15:23:05 -0700 | [diff] [blame] | 27 | import com.android.internal.telephony.cat.AppInterface; |
| 28 | |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 29 | /** |
| 30 | * Receiver class to get STK intents, broadcasted by telephony layer. |
Wink Saville | 79085fc | 2009-06-09 10:27:23 -0700 | [diff] [blame] | 31 | * |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 32 | */ |
| 33 | public class StkCmdReceiver extends BroadcastReceiver { |
Yoshiaki Naka | 3a980db | 2019-10-30 17:11:33 +0900 | [diff] [blame] | 34 | private static final String LOG_TAG = |
| 35 | new Object(){}.getClass().getEnclosingClass().getSimpleName(); |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 36 | |
| 37 | @Override |
| 38 | public void onReceive(Context context, Intent intent) { |
| 39 | String action = intent.getAction(); |
Teruaki Minami | 3f2bd96 | 2015-11-12 17:41:13 +0100 | [diff] [blame] | 40 | if (action == null) { |
| 41 | return; |
| 42 | } |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 43 | |
Alex Yakavenka | d41f1d9 | 2010-07-12 14:13:13 -0700 | [diff] [blame] | 44 | if (action.equals(AppInterface.CAT_CMD_ACTION)) { |
Wink Saville | e68857d | 2014-10-17 15:23:05 -0700 | [diff] [blame] | 45 | handleAction(context, intent, StkAppService.OP_CMD); |
Alex Yakavenka | d41f1d9 | 2010-07-12 14:13:13 -0700 | [diff] [blame] | 46 | } else if (action.equals(AppInterface.CAT_SESSION_END_ACTION)) { |
Wink Saville | e68857d | 2014-10-17 15:23:05 -0700 | [diff] [blame] | 47 | handleAction(context, intent, StkAppService.OP_END_SESSION); |
Wink Saville | 94e982b | 2014-07-11 07:38:14 -0700 | [diff] [blame] | 48 | } else if (action.equals(AppInterface.CAT_ICC_STATUS_CHANGE)) { |
Wink Saville | e68857d | 2014-10-17 15:23:05 -0700 | [diff] [blame] | 49 | handleAction(context, intent, StkAppService.OP_CARD_STATUS_CHANGED); |
Preeti Ahuja | 0f4cf2f | 2012-08-09 11:45:08 +0530 | [diff] [blame] | 50 | } else if (action.equals(AppInterface.CAT_ALPHA_NOTIFY_ACTION)) { |
| 51 | handleAction(context, intent, StkAppService.OP_ALPHA_NOTIFY); |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | |
Wink Saville | e68857d | 2014-10-17 15:23:05 -0700 | [diff] [blame] | 55 | private void handleAction(Context context, Intent intent, int op) { |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 56 | Bundle args = new Bundle(); |
Preeti Ahuja | 0f4cf2f | 2012-08-09 11:45:08 +0530 | [diff] [blame] | 57 | int slot_id = intent.getIntExtra(StkAppService.SLOT_ID, 0); |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 58 | |
Wink Saville | e68857d | 2014-10-17 15:23:05 -0700 | [diff] [blame] | 59 | args.putInt(StkAppService.OPCODE, op); |
| 60 | args.putInt(StkAppService.SLOT_ID, slot_id); |
Wink Saville | 94e982b | 2014-07-11 07:38:14 -0700 | [diff] [blame] | 61 | |
Wink Saville | e68857d | 2014-10-17 15:23:05 -0700 | [diff] [blame] | 62 | 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 Godachi | 40a72f7 | 2017-09-12 15:16:55 +0530 | [diff] [blame] | 78 | args.putString(AppInterface.AID, intent.getStringExtra(AppInterface.AID)); |
Preeti Ahuja | 0f4cf2f | 2012-08-09 11:45:08 +0530 | [diff] [blame] | 79 | } else if (StkAppService.OP_ALPHA_NOTIFY == op) { |
| 80 | String alphaString = intent.getStringExtra(AppInterface.ALPHA_STRING); |
| 81 | args.putString(AppInterface.ALPHA_STRING, alphaString); |
Wink Saville | 94e982b | 2014-07-11 07:38:14 -0700 | [diff] [blame] | 82 | } |
Preeti Ahuja | 0f4cf2f | 2012-08-09 11:45:08 +0530 | [diff] [blame] | 83 | |
Yoshiaki Naka | 3a980db | 2019-10-30 17:11:33 +0900 | [diff] [blame] | 84 | CatLog.d(LOG_TAG, "handleAction, op: " + op + |
Wink Saville | e68857d | 2014-10-17 15:23:05 -0700 | [diff] [blame] | 85 | "args: " + args + ", slot id: " + slot_id); |
| 86 | Intent toService = new Intent(context, StkAppService.class); |
| 87 | toService.putExtras(args); |
| 88 | context.startService(toService); |
Wink Saville | 94e982b | 2014-07-11 07:38:14 -0700 | [diff] [blame] | 89 | } |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 90 | } |