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.server.telecom.testapps;
18 
19 import android.app.Activity;
20 import android.content.Intent;
21 import android.net.Uri;
22 import android.os.Bundle;
23 import 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  */
35 public 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     @Override
onCreate(Bundle icicle)56     protected void onCreate(Bundle icicle) {
57         super.onCreate(icicle);
58         final Intent intent = getIntent();
59         final String action = intent != null ? intent.getAction() : null;
60         final Uri data = intent != null ? intent.getData() : null;
61         if (ACTION_NEW_INCOMING_CALL.equals(action) && data != null) {
62             CallNotificationReceiver.sendIncomingCallIntent(this, data,
63                     VideoProfile.STATE_AUDIO_ONLY);
64         } else if (ACTION_NEW_UNKNOWN_CALL.equals(action) && data != null) {
65             CallNotificationReceiver.addNewUnknownCall(this, data, intent.getExtras());
66         } else if (ACTION_HANGUP_CALLS.equals(action)) {
67             CallNotificationReceiver.hangupCalls(this);
68         } else if (ACTION_SEND_UPGRADE_REQUEST.equals(action)) {
69             CallNotificationReceiver.sendUpgradeRequest(this, data);
70         } else {
71             CallServiceNotifier.getInstance().updateNotification(this);
72         }
73         finish();
74     }
75 }
76