blob: f27661198f33ef98ab84e8e1247661cc0fd915d5 [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;
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080020
21import android.content.BroadcastReceiver;
22import android.content.Context;
23import android.content.Intent;
24import android.os.Bundle;
25
26/**
27 * Receiver class to get STK intents, broadcasted by telephony layer.
Wink Saville79085fc2009-06-09 10:27:23 -070028 *
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080029 */
30public class StkCmdReceiver extends BroadcastReceiver {
31
32 @Override
33 public void onReceive(Context context, Intent intent) {
34 String action = intent.getAction();
35
Alex Yakavenkad41f1d92010-07-12 14:13:13 -070036 if (action.equals(AppInterface.CAT_CMD_ACTION)) {
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080037 handleCommandMessage(context, intent);
Alex Yakavenkad41f1d92010-07-12 14:13:13 -070038 } else if (action.equals(AppInterface.CAT_SESSION_END_ACTION)) {
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080039 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}