summaryrefslogtreecommitdiffstats
path: root/src/com/android/incallui/InCallApp.java
blob: a87f5407d8ce71d36449d58d29e3eb2b6bd12280 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.incallui;

import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.telecom.VideoProfile;

/**
 * Top-level Application class for the InCall app.
 */
public class InCallApp extends Application {

    /**
     * Intent Action used for hanging up the current call from Notification bar. This will
     * choose first ringing call, first active call, or first background call (typically in
     * STATE_HOLDING state).
     */
    public static final String ACTION_DECLINE_INCOMING_CALL =
            "com.android.incallui.ACTION_DECLINE_INCOMING_CALL";
    public static final String ACTION_HANG_UP_ONGOING_CALL =
            "com.android.incallui.ACTION_HANG_UP_ONGOING_CALL";
    public static final String ACTION_ANSWER_MORE_INCOMING_CALL =
            "com.android.incallui.ACTION_ANSWER_MORE_INCOMING_CALL";
    public static final String ACTION_ANSWER_VOICE_INCOMING_CALL =
            "com.android.incallui.ACTION_ANSWER_VOICE_INCOMING_CALL";
    public static final String ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST =
            "com.android.incallui.ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST";
    public static final String ACTION_DECLINE_VIDEO_UPGRADE_REQUEST =
            "com.android.incallui.ACTION_DECLINE_VIDEO_UPGRADE_REQUEST";
    public static final String ADD_CALL_MODE_KEY = "add_call_mode";
    public static final String ADD_PARTICIPANT_KEY = "add_participant";
    public static final String CURRENT_PARTICIPANT_LIST = "current_participant_list";

    public InCallApp() {
    }

    @Override
    public void onCreate() {
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    /**
     * Accepts broadcatst Intents which will be prepared by {@link StatusBarNotifier} and thus
     * sent from framework's notification mechanism (which is outside Phone context).
     * This should be visible from outside, but shouldn't be in "exported" state.
     */
    public static class NotificationBroadcastReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();
            Log.i(this, "Broadcast from Notification: " + action);

            // TODO: Commands of this nature should exist in the CallList.
            if (action.equals(ACTION_ANSWER_MORE_INCOMING_CALL)) {
                InCallPresenter.getInstance().bringToForeground(false);
            } else if (action.equals(ACTION_ANSWER_VOICE_INCOMING_CALL)) {
                InCallPresenter.getInstance().answerIncomingCall(
                        context, VideoProfile.VideoState.AUDIO_ONLY);
            } else if (action.equals(ACTION_DECLINE_INCOMING_CALL)) {
                InCallPresenter.getInstance().declineIncomingCall(context);
            } else if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) {
                InCallPresenter.getInstance().hangUpOngoingCall(context);
            } else if (action.equals(ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST)) {
                InCallPresenter inCallPresenter = InCallPresenter.getInstance();
                inCallPresenter.acceptUpgradeRequest(context);
                inCallPresenter.bringToForeground(false);
            } else if (action.equals(ACTION_DECLINE_VIDEO_UPGRADE_REQUEST)) {
                InCallPresenter.getInstance().declineUpgradeRequest(context);
            }
        }
    }
}