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 
     25 /**
     26  * Top-level Application class for the InCall app.
     27  */
     28 public class InCallApp extends Application {
     29 
     30     /**
     31      * Intent Action used for hanging up the current call from Notification bar. This will
     32      * choose first ringing call, first active call, or first background call (typically in
     33      * HOLDING state).
     34      */
     35     public static final String ACTION_HANG_UP_ONGOING_CALL =
     36             "com.android.incallui.ACTION_HANG_UP_ONGOING_CALL";
     37 
     38     public InCallApp() {
     39     }
     40 
     41     @Override
     42     public void onCreate() {
     43     }
     44 
     45     @Override
     46     public void onConfigurationChanged(Configuration newConfig) {
     47         super.onConfigurationChanged(newConfig);
     48     }
     49 
     50     /**
     51      * Accepts broadcast Intents which will be prepared by {@link StatusBarNotifier} and thus
     52      * sent from framework's notification mechanism (which is outside Phone context).
     53      * This should be visible from outside, but shouldn't be in "exported" state.
     54      *
     55      */
     56     public static class NotificationBroadcastReceiver extends BroadcastReceiver {
     57         @Override
     58         public void onReceive(Context context, Intent intent) {
     59             final String action = intent.getAction();
     60             Log.i(this, "Broadcast from Notification: " + action);
     61 
     62             if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) {
     63                 // TODO: Commands of this nature should exist in the CallList or a
     64                 //       CallController class that has access to CallCommandClient and
     65                 //       CallList.
     66                 InCallPresenter.getInstance().hangUpOngoingCall(context);
     67             }
     68         }
     69     }
     70 }
     71