blob: f33022c1e108ac1bc2a1a4059d5e342b2096d881 [file] [log] [blame]
Tyler Gunn6f9ceb22017-04-06 08:47:01 -07001/*
2 * Copyright (C) 2017 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.os.Bundle;
22import android.telecom.Log;
23import android.telecom.TelecomManager;
24import android.telephony.DisconnectCause;
25import android.view.View;
26import android.widget.Button;
27
28/**
29 * Displays a UX to the user confirming whether they want to handover a call to the self-managed CS.
30 */
31public class HandoverActivity extends Activity {
32 public static final String EXTRA_CALL_ID = "com.android.server.telecom.testapps.extra.CALL_ID";
33
34 private Button mAcceptHandoverButton;
35 private Button mRejectHandoverButton;
36
37 @Override
38 public void onCreate(Bundle savedInstanceState) {
39 super.onCreate(savedInstanceState);
40 Intent launchingIntent = getIntent();
41 int callId = launchingIntent.getIntExtra(EXTRA_CALL_ID, 0);
42 Log.i(this, "showing fullscreen upgrade ux for call id %d", callId);
43
44 setContentView(R.layout.self_managed_handover);
45 final SelfManagedConnection connection = SelfManagedCallList.getInstance()
46 .getConnectionById(callId);
47 mAcceptHandoverButton = (Button) findViewById(R.id.acceptUpgradeButton);
48 mAcceptHandoverButton.setOnClickListener((View v) -> {
49 if (connection != null) {
50 connection.setConnectionActive();
51 Intent intent = new Intent(Intent.ACTION_MAIN, null);
52 intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION |
53 Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
54 intent.setClass(this, SelfManagedCallingActivity.class);
55 startActivity(intent);
56 }
57 finish();
58 });
59 mRejectHandoverButton = (Button) findViewById(R.id.rejectUpgradeButton);
60 mRejectHandoverButton.setOnClickListener((View v) -> {
61 if (connection != null) {
62 connection.setConnectionDisconnected(DisconnectCause.INCOMING_REJECTED);
63 connection.destroy();
64 TelecomManager tm = TelecomManager.from(this);
65 tm.showInCallScreen(false);
66 }
67 finish();
68 });
69 }
70}