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
17package com.android.server.telecom.testapps;
18
19import android.app.Activity;
20import android.content.Intent;
21import android.net.Uri;
22import android.os.Bundle;
23import android.telecom.VideoProfile;
24
25/**
26 * This activity exists in order to add an icon to the launcher. This activity has no UI of its own
27 * and instead starts the notification for {@link TestConnectionService} via
28 * {@link CallServiceNotifier}. After triggering a notification update, this activity immediately
29 * finishes.
30 *
31 * To directly trigger a new incoming call, use the following adb command:
32 *
33 * adb shell am start -a android.telecom.testapps.ACTION_START_INCOMING_CALL -d "tel:123456789"
34 */
35public class TestCallActivity extends Activity {
36
37    public static final String ACTION_NEW_INCOMING_CALL =
38            "android.telecom.testapps.ACTION_START_INCOMING_CALL";
39
40    /*
41     * Action to exercise TelecomManager.addNewUnknownCall().
42     */
43    public static final String ACTION_NEW_UNKNOWN_CALL =
44            "android.telecom.testapps.ACTION_NEW_UNKNOWN_CALL";
45
46    /*
47     * Hang up any test incoming calls, to simulate the user missing a call.
48     */
49    public static final String ACTION_HANGUP_CALLS =
50            "android.telecom.testapps.ACTION_HANGUP_CALLS";
51
52    public static final String ACTION_SEND_UPGRADE_REQUEST =
53            "android.telecom.testapps.ACTION_SEND_UPGRADE_REQUEST";
54
55    static final String ACTION_RTT_CALL =
56            "android.telecom.testapps.ACTION_RTT_CALL";
57
58    public static final String ACTION_REMOTE_RTT_UPGRADE =
59            "android.telecom.testapps.ACTION_REMOTE_RTT_UPGRADE";
60
61    @Override
62    protected void onCreate(Bundle icicle) {
63        super.onCreate(icicle);
64        final Intent intent = getIntent();
65        final String action = intent != null ? intent.getAction() : null;
66        final Uri data = intent != null ? intent.getData() : null;
67        if (ACTION_NEW_INCOMING_CALL.equals(action) && data != null) {
68            CallNotificationReceiver.sendIncomingCallIntent(this, data,
69                    VideoProfile.STATE_AUDIO_ONLY);
70        } else if (ACTION_NEW_UNKNOWN_CALL.equals(action) && data != null) {
71            CallNotificationReceiver.addNewUnknownCall(this, data, intent.getExtras());
72        } else if (ACTION_HANGUP_CALLS.equals(action)) {
73            CallNotificationReceiver.hangupCalls(this);
74        } else if (ACTION_RTT_CALL.equals(action)) {
75            CallNotificationReceiver.sendIncomingRttCallIntent(
76                    this, data, VideoProfile.STATE_AUDIO_ONLY);
77        } else if (ACTION_SEND_UPGRADE_REQUEST.equals(action)) {
78            CallNotificationReceiver.sendUpgradeRequest(this, data);
79        } else if (ACTION_REMOTE_RTT_UPGRADE.equals(action)) {
80            CallNotificationReceiver.remoteRttUpgrade(this);
81        } else {
82            CallServiceNotifier.getInstance().updateNotification(this);
83        }
84        finish();
85    }
86}
87