Home | History | Annotate | Download | only in incallui
      1 /*
      2  * Copyright (C) 2013 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.app.Application;
     20 import android.content.BroadcastReceiver;
     21 import android.content.Context;
     22 import android.content.Intent;
     23 import android.content.res.Configuration;
     24 import android.telecom.VideoProfile;
     25 
     26 /**
     27  * Top-level Application class for the InCall app.
     28  */
     29 public class InCallApp extends Application {
     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 
     49     public InCallApp() {
     50     }
     51 
     52     @Override
     53     public void onCreate() {
     54     }
     55 
     56     @Override
     57     public void onConfigurationChanged(Configuration newConfig) {
     58         super.onConfigurationChanged(newConfig);
     59     }
     60 
     61     /**
     62      * Accepts broadcatst Intents which will be prepared by {@link StatusBarNotifier} and thus
     63      * sent from framework's notification mechanism (which is outside Phone context).
     64      * This should be visible from outside, but shouldn't be in "exported" state.
     65      */
     66     public static class NotificationBroadcastReceiver extends BroadcastReceiver {
     67         @Override
     68         public void onReceive(Context context, Intent intent) {
     69             final String action = intent.getAction();
     70             Log.i(this, "Broadcast from Notification: " + action);
     71 
     72             // TODO: Commands of this nature should exist in the CallList.
     73             if (action.equals(ACTION_ANSWER_VIDEO_INCOMING_CALL)) {
     74                 InCallPresenter.getInstance().answerIncomingCall(
     75                         context, VideoProfile.VideoState.BIDIRECTIONAL);
     76             } else if (action.equals(ACTION_ANSWER_VOICE_INCOMING_CALL)) {
     77                 InCallPresenter.getInstance().answerIncomingCall(
     78                         context, VideoProfile.VideoState.AUDIO_ONLY);
     79             } else if (action.equals(ACTION_DECLINE_INCOMING_CALL)) {
     80                 InCallPresenter.getInstance().declineIncomingCall(context);
     81             } else if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) {
     82                 InCallPresenter.getInstance().hangUpOngoingCall(context);
     83             } else if (action.equals(ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST)) {
     84                 InCallPresenter.getInstance().acceptUpgradeRequest(context);
     85             } else if (action.equals(ACTION_DECLINE_VIDEO_UPGRADE_REQUEST)) {
     86                 InCallPresenter.getInstance().declineUpgradeRequest(context);
     87             }
     88         }
     89     }
     90 }
     91