1 /* 2 * Copyright (C) 2015 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 /** 25 * Test in call service broadcast receiver. 26 */ 27 public class TestInCallServiceBroadcastReceiver extends BroadcastReceiver { 28 private static final String TAG = "TestInCallServiceBR"; 29 30 /** 31 * Sends an upgrade to video request for any live calls. 32 */ 33 public static final String ACTION_SEND_UPDATE_REQUEST_FROM_TEST_INCALL_SERVICE = 34 "android.server.telecom.testapps.ACTION_SEND_UPDATE_REQUEST_FROM_TEST_INCALL_SERVICE"; 35 36 /** 37 * Sends an a response to an upgrade to video request. 38 */ 39 public static final String ACTION_SEND_UPGRADE_RESPONSE = 40 "android.server.telecom.testapps.ACTION_SEND_UPGRADE_RESPONSE"; 41 42 /** 43 * Handles broadcasts directed at the {@link TestInCallServiceImpl}. 44 * 45 * @param context The Context in which the receiver is running. 46 * @param intent The Intent being received. 47 */ 48 @Override onReceive(Context context, Intent intent)49 public void onReceive(Context context, Intent intent) { 50 String action = intent.getAction(); 51 Log.v(TAG, "onReceive: " + action); 52 53 if (ACTION_SEND_UPDATE_REQUEST_FROM_TEST_INCALL_SERVICE.equals(action)) { 54 final int videoState = Integer.parseInt(intent.getData().getSchemeSpecificPart()); 55 TestCallList.getInstance().sendUpgradeToVideoRequest(videoState); 56 } else if (ACTION_SEND_UPGRADE_RESPONSE.equals(action)) { 57 final int videoState = Integer.parseInt(intent.getData().getSchemeSpecificPart()); 58 TestCallList.getInstance().sendUpgradeToVideoResponse(videoState); 59 } 60 } 61 } 62