• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.server.telecom.testapps;
18 
19 import android.content.BroadcastReceiver;
20 import android.content.Context;
21 import android.content.Intent;
22 import android.util.Log;
23 
24 public class TestConnectionServiceReceiver extends BroadcastReceiver {
25     private static final String TAG = "TestConnectionServiceBR";
26 
27     // Switches the PhoneAccount to the second test SIM account.
28     public static final String INTENT_SWITCH_PHONE_ACCOUNT =
29             "android.server.telecom.testapps.ACTION_SWITCH_PHONE_ACCOUNT";
30 
31     // Creates a PhoneAccount that is incorrect and should create a SecurityException
32     public static final String INTENT_SWITCH_PHONE_ACCOUNT_WRONG =
33             "android.server.telecom.testapps.ACTION_SWITCH_PHONE_ACCOUNT_WRONG";
34 
35     /**
36      * Handles broadcasts directed at the {@link TestInCallServiceImpl}.
37      *
38      * @param context The Context in which the receiver is running.
39      * @param intent  The Intent being received.
40      */
41     @Override
onReceive(Context context, Intent intent)42     public void onReceive(Context context, Intent intent) {
43         String action = intent.getAction();
44         Log.v(TAG, "onReceive: " + action);
45 
46         TestConnectionService cs = TestConnectionService.getInstance();
47         if (cs == null) {
48             Log.i(TAG, "null TestConnectionService");
49             return;
50         }
51 
52         if (INTENT_SWITCH_PHONE_ACCOUNT.equals(action)) {
53             cs.switchPhoneAccount();
54         } else if (INTENT_SWITCH_PHONE_ACCOUNT_WRONG.equals(action)) {
55             cs.switchPhoneAccountWrong();
56         }
57     }
58 }
59