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.incallui; 18 19 import android.content.BroadcastReceiver; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.telecom.VideoProfile; 23 24 /** 25 * Accepts broadcast Intents which will be prepared by {@link StatusBarNotifier} and thus 26 * sent from the notification manager. 27 * This should be visible from outside, but shouldn't be exported. 28 */ 29 public class NotificationBroadcastReceiver extends BroadcastReceiver { 30 31 /** 32 * Intent Action used for hanging up the current call from Notification bar. This will 33 * choose first ringing call, first active call, or first background call (typically in 34 * STATE_HOLDING state). 35 */ 36 public static final String ACTION_DECLINE_INCOMING_CALL = 37 "com.android.incallui.ACTION_DECLINE_INCOMING_CALL"; 38 public static final String ACTION_HANG_UP_ONGOING_CALL = 39 "com.android.incallui.ACTION_HANG_UP_ONGOING_CALL"; 40 public static final String ACTION_ANSWER_VIDEO_INCOMING_CALL = 41 "com.android.incallui.ACTION_ANSWER_VIDEO_INCOMING_CALL"; 42 public static final String ACTION_ANSWER_VOICE_INCOMING_CALL = 43 "com.android.incallui.ACTION_ANSWER_VOICE_INCOMING_CALL"; 44 public static final String ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST = 45 "com.android.incallui.ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST"; 46 public static final String ACTION_DECLINE_VIDEO_UPGRADE_REQUEST = 47 "com.android.incallui.ACTION_DECLINE_VIDEO_UPGRADE_REQUEST"; 48 public static final String ACTION_PULL_EXTERNAL_CALL = 49 "com.android.incallui.ACTION_PULL_EXTERNAL_CALL"; 50 public static final String EXTRA_NOTIFICATION_ID = 51 "com.android.incallui.extra.EXTRA_NOTIFICATION_ID"; 52 53 @Override 54 public void onReceive(Context context, Intent intent) { 55 final String action = intent.getAction(); 56 Log.i(this, "Broadcast from Notification: " + action); 57 58 // TODO: Commands of this nature should exist in the CallList. 59 if (action.equals(ACTION_ANSWER_VIDEO_INCOMING_CALL)) { 60 InCallPresenter.getInstance().answerIncomingCall( 61 context, VideoProfile.STATE_BIDIRECTIONAL); 62 } else if (action.equals(ACTION_ANSWER_VOICE_INCOMING_CALL)) { 63 InCallPresenter.getInstance().answerIncomingCall( 64 context, VideoProfile.STATE_AUDIO_ONLY); 65 } else if (action.equals(ACTION_DECLINE_INCOMING_CALL)) { 66 InCallPresenter.getInstance().declineIncomingCall(context); 67 } else if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) { 68 InCallPresenter.getInstance().hangUpOngoingCall(context); 69 } else if (action.equals(ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST)) { 70 //TODO: Change calltype after adding support for TX and RX 71 InCallPresenter.getInstance().acceptUpgradeRequest( 72 VideoProfile.STATE_BIDIRECTIONAL, context); 73 } else if (action.equals(ACTION_DECLINE_VIDEO_UPGRADE_REQUEST)) { 74 InCallPresenter.getInstance().declineUpgradeRequest(context); 75 } else if (action.equals(ACTION_PULL_EXTERNAL_CALL)) { 76 int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1); 77 InCallPresenter.getInstance().getExternalCallNotifier() 78 .pullExternalCall(notificationId); 79 } 80 } 81 82 } 83