blob: ae606c816a21e5fd6738f1724c971bda85d3dcd8 [file] [log] [blame]
Santos Cordon76faae52013-12-12 18:55:50 -08001/*
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
Tyler Gunn7cc70b42014-09-12 22:17:27 -070017package com.android.server.telecom.testapps;
Santos Cordon76faae52013-12-12 18:55:50 -080018
19import android.app.Activity;
Yorke Leeedaa77a2014-09-04 14:39:20 -070020import android.content.Intent;
21import android.net.Uri;
Santos Cordon76faae52013-12-12 18:55:50 -080022import android.os.Bundle;
Tyler Gunn141c4bf2015-12-16 08:14:37 -080023import android.telecom.VideoProfile;
Santos Cordon76faae52013-12-12 18:55:50 -080024
25/**
26 * This activity exists in order to add an icon to the launcher. This activity has no UI of its own
Sailesh Nepal905dfba2014-07-14 08:20:41 -070027 * and instead starts the notification for {@link TestConnectionService} via
28 * {@link CallServiceNotifier}. After triggering a notification update, this activity immediately
29 * finishes.
Yorke Leeedaa77a2014-09-04 14:39:20 -070030 *
31 * To directly trigger a new incoming call, use the following adb command:
32 *
Tyler Gunn7cc70b42014-09-12 22:17:27 -070033 * adb shell am start -a android.telecom.testapps.ACTION_START_INCOMING_CALL -d "tel:123456789"
Santos Cordon76faae52013-12-12 18:55:50 -080034 */
35public class TestCallActivity extends Activity {
36
Yorke Leeedaa77a2014-09-04 14:39:20 -070037 public static final String ACTION_NEW_INCOMING_CALL =
Tyler Gunn7cc70b42014-09-12 22:17:27 -070038 "android.telecom.testapps.ACTION_START_INCOMING_CALL";
Yorke Leeedaa77a2014-09-04 14:39:20 -070039
Yorke Lee9250e5f2014-10-01 13:39:09 -070040 /*
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
Yorke Lee2a6985f2015-03-27 12:30:44 -070046 /*
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
Yorke Lee817090c2015-04-10 12:12:25 -070052 public static final String ACTION_SEND_UPGRADE_REQUEST =
53 "android.telecom.testapps.ACTION_SEND_UPGRADE_REQUEST";
54
Hall Liudd68bc32017-01-25 17:14:23 -080055 static final String ACTION_RTT_CALL =
56 "android.telecom.testapps.ACTION_RTT_CALL";
57
Hall Liuaeece4e2017-02-14 16:42:12 -080058 public static final String ACTION_REMOTE_RTT_UPGRADE =
59 "android.telecom.testapps.ACTION_REMOTE_RTT_UPGRADE";
60
Santos Cordon76faae52013-12-12 18:55:50 -080061 @Override
62 protected void onCreate(Bundle icicle) {
63 super.onCreate(icicle);
Yorke Leeedaa77a2014-09-04 14:39:20 -070064 final Intent intent = getIntent();
Yorke Lee9250e5f2014-10-01 13:39:09 -070065 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) {
Tyler Gunn141c4bf2015-12-16 08:14:37 -080068 CallNotificationReceiver.sendIncomingCallIntent(this, data,
69 VideoProfile.STATE_AUDIO_ONLY);
Yorke Lee3d0ef1d2014-10-14 15:30:16 -070070 } else if (ACTION_NEW_UNKNOWN_CALL.equals(action) && data != null) {
Yorke Lee9250e5f2014-10-01 13:39:09 -070071 CallNotificationReceiver.addNewUnknownCall(this, data, intent.getExtras());
Yorke Lee2a6985f2015-03-27 12:30:44 -070072 } else if (ACTION_HANGUP_CALLS.equals(action)) {
73 CallNotificationReceiver.hangupCalls(this);
Hall Liudd68bc32017-01-25 17:14:23 -080074 } else if (ACTION_RTT_CALL.equals(action)) {
75 CallNotificationReceiver.sendIncomingRttCallIntent(
76 this, data, VideoProfile.STATE_AUDIO_ONLY);
Yorke Lee817090c2015-04-10 12:12:25 -070077 } else if (ACTION_SEND_UPGRADE_REQUEST.equals(action)) {
78 CallNotificationReceiver.sendUpgradeRequest(this, data);
Hall Liuaeece4e2017-02-14 16:42:12 -080079 } else if (ACTION_REMOTE_RTT_UPGRADE.equals(action)) {
80 CallNotificationReceiver.remoteRttUpgrade(this);
Yorke Lee9250e5f2014-10-01 13:39:09 -070081 } else {
82 CallServiceNotifier.getInstance().updateNotification(this);
Yorke Leeedaa77a2014-09-04 14:39:20 -070083 }
Santos Cordon76faae52013-12-12 18:55:50 -080084 finish();
85 }
Santos Cordon76faae52013-12-12 18:55:50 -080086}