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