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; |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 20 | |
| 21 | import android.content.BroadcastReceiver; |
| 22 | import android.content.Context; |
| 23 | import android.content.Intent; |
| 24 | import android.os.Bundle; |
| 25 | |
| 26 | /** |
| 27 | * Receiver class to get STK intents, broadcasted by telephony layer. |
Wink Saville | 79085fc | 2009-06-09 10:27:23 -0700 | [diff] [blame] | 28 | * |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 29 | */ |
| 30 | public class StkCmdReceiver extends BroadcastReceiver { |
| 31 | |
| 32 | @Override |
| 33 | public void onReceive(Context context, Intent intent) { |
| 34 | String action = intent.getAction(); |
| 35 | |
Alex Yakavenka | d41f1d9 | 2010-07-12 14:13:13 -0700 | [diff] [blame] | 36 | if (action.equals(AppInterface.CAT_CMD_ACTION)) { |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 37 | handleCommandMessage(context, intent); |
Alex Yakavenka | d41f1d9 | 2010-07-12 14:13:13 -0700 | [diff] [blame] | 38 | } else if (action.equals(AppInterface.CAT_SESSION_END_ACTION)) { |
The Android Open Source Project | 9d9730a | 2009-03-03 19:32:37 -0800 | [diff] [blame] | 39 | handleSessionEnd(context, intent); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | private void handleCommandMessage(Context context, Intent intent) { |
| 44 | Bundle args = new Bundle(); |
| 45 | args.putInt(StkAppService.OPCODE, StkAppService.OP_CMD); |
| 46 | args.putParcelable(StkAppService.CMD_MSG, intent |
| 47 | .getParcelableExtra("STK CMD")); |
| 48 | context.startService(new Intent(context, StkAppService.class) |
| 49 | .putExtras(args)); |
| 50 | } |
| 51 | |
| 52 | private void handleSessionEnd(Context context, Intent intent) { |
| 53 | Bundle args = new Bundle(); |
| 54 | args.putInt(StkAppService.OPCODE, StkAppService.OP_END_SESSION); |
| 55 | context.startService(new Intent(context, StkAppService.class) |
| 56 | .putExtras(args)); |
| 57 | } |
| 58 | } |