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 19 import com.android.internal.telephony.cat.AppInterface; 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. 28 * 29 */ 30 public class StkCmdReceiver extends BroadcastReceiver { 31 32 @Override 33 public void onReceive(Context context, Intent intent) { 34 String action = intent.getAction(); 35 36 if (action.equals(AppInterface.CAT_CMD_ACTION)) { 37 handleCommandMessage(context, intent); 38 } else if (action.equals(AppInterface.CAT_SESSION_END_ACTION)) { 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 } 59