Santos Cordon | 76faae5 | 2013-12-12 18:55:50 -0800 | [diff] [blame] | 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 | |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 17 | package com.android.server.telecom.testapps; |
Santos Cordon | 76faae5 | 2013-12-12 18:55:50 -0800 | [diff] [blame] | 18 | |
| 19 | import android.app.Activity; |
Yorke Lee | edaa77a | 2014-09-04 14:39:20 -0700 | [diff] [blame] | 20 | import android.content.Intent; |
| 21 | import android.net.Uri; |
Santos Cordon | 76faae5 | 2013-12-12 18:55:50 -0800 | [diff] [blame] | 22 | import android.os.Bundle; |
Tyler Gunn | 141c4bf | 2015-12-16 08:14:37 -0800 | [diff] [blame] | 23 | import android.telecom.VideoProfile; |
Santos Cordon | 76faae5 | 2013-12-12 18:55:50 -0800 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * This activity exists in order to add an icon to the launcher. This activity has no UI of its own |
Sailesh Nepal | 905dfba | 2014-07-14 08:20:41 -0700 | [diff] [blame] | 27 | * and instead starts the notification for {@link TestConnectionService} via |
| 28 | * {@link CallServiceNotifier}. After triggering a notification update, this activity immediately |
| 29 | * finishes. |
Yorke Lee | edaa77a | 2014-09-04 14:39:20 -0700 | [diff] [blame] | 30 | * |
| 31 | * To directly trigger a new incoming call, use the following adb command: |
| 32 | * |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 33 | * adb shell am start -a android.telecom.testapps.ACTION_START_INCOMING_CALL -d "tel:123456789" |
Santos Cordon | 76faae5 | 2013-12-12 18:55:50 -0800 | [diff] [blame] | 34 | */ |
| 35 | public class TestCallActivity extends Activity { |
| 36 | |
Yorke Lee | edaa77a | 2014-09-04 14:39:20 -0700 | [diff] [blame] | 37 | public static final String ACTION_NEW_INCOMING_CALL = |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 38 | "android.telecom.testapps.ACTION_START_INCOMING_CALL"; |
Yorke Lee | edaa77a | 2014-09-04 14:39:20 -0700 | [diff] [blame] | 39 | |
Yorke Lee | 9250e5f | 2014-10-01 13:39:09 -0700 | [diff] [blame] | 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 | |
Yorke Lee | 2a6985f | 2015-03-27 12:30:44 -0700 | [diff] [blame] | 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 | |
Yorke Lee | 817090c | 2015-04-10 12:12:25 -0700 | [diff] [blame] | 52 | public static final String ACTION_SEND_UPGRADE_REQUEST = |
| 53 | "android.telecom.testapps.ACTION_SEND_UPGRADE_REQUEST"; |
| 54 | |
Hall Liu | dd68bc3 | 2017-01-25 17:14:23 -0800 | [diff] [blame] | 55 | static final String ACTION_RTT_CALL = |
| 56 | "android.telecom.testapps.ACTION_RTT_CALL"; |
| 57 | |
Hall Liu | aeece4e | 2017-02-14 16:42:12 -0800 | [diff] [blame] | 58 | public static final String ACTION_REMOTE_RTT_UPGRADE = |
| 59 | "android.telecom.testapps.ACTION_REMOTE_RTT_UPGRADE"; |
| 60 | |
Santos Cordon | 76faae5 | 2013-12-12 18:55:50 -0800 | [diff] [blame] | 61 | @Override |
| 62 | protected void onCreate(Bundle icicle) { |
| 63 | super.onCreate(icicle); |
Yorke Lee | edaa77a | 2014-09-04 14:39:20 -0700 | [diff] [blame] | 64 | final Intent intent = getIntent(); |
Yorke Lee | 9250e5f | 2014-10-01 13:39:09 -0700 | [diff] [blame] | 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) { |
Tyler Gunn | 141c4bf | 2015-12-16 08:14:37 -0800 | [diff] [blame] | 68 | CallNotificationReceiver.sendIncomingCallIntent(this, data, |
| 69 | VideoProfile.STATE_AUDIO_ONLY); |
Yorke Lee | 3d0ef1d | 2014-10-14 15:30:16 -0700 | [diff] [blame] | 70 | } else if (ACTION_NEW_UNKNOWN_CALL.equals(action) && data != null) { |
Yorke Lee | 9250e5f | 2014-10-01 13:39:09 -0700 | [diff] [blame] | 71 | CallNotificationReceiver.addNewUnknownCall(this, data, intent.getExtras()); |
Yorke Lee | 2a6985f | 2015-03-27 12:30:44 -0700 | [diff] [blame] | 72 | } else if (ACTION_HANGUP_CALLS.equals(action)) { |
| 73 | CallNotificationReceiver.hangupCalls(this); |
Hall Liu | dd68bc3 | 2017-01-25 17:14:23 -0800 | [diff] [blame] | 74 | } else if (ACTION_RTT_CALL.equals(action)) { |
| 75 | CallNotificationReceiver.sendIncomingRttCallIntent( |
| 76 | this, data, VideoProfile.STATE_AUDIO_ONLY); |
Yorke Lee | 817090c | 2015-04-10 12:12:25 -0700 | [diff] [blame] | 77 | } else if (ACTION_SEND_UPGRADE_REQUEST.equals(action)) { |
| 78 | CallNotificationReceiver.sendUpgradeRequest(this, data); |
Hall Liu | aeece4e | 2017-02-14 16:42:12 -0800 | [diff] [blame] | 79 | } else if (ACTION_REMOTE_RTT_UPGRADE.equals(action)) { |
| 80 | CallNotificationReceiver.remoteRttUpgrade(this); |
Yorke Lee | 9250e5f | 2014-10-01 13:39:09 -0700 | [diff] [blame] | 81 | } else { |
| 82 | CallServiceNotifier.getInstance().updateNotification(this); |
Yorke Lee | edaa77a | 2014-09-04 14:39:20 -0700 | [diff] [blame] | 83 | } |
Santos Cordon | 76faae5 | 2013-12-12 18:55:50 -0800 | [diff] [blame] | 84 | finish(); |
| 85 | } |
Santos Cordon | 76faae5 | 2013-12-12 18:55:50 -0800 | [diff] [blame] | 86 | } |