1 /* 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 17 package com.android.server.telecom.testapps; 18 19 import android.app.Activity; 20 import android.content.Intent; 21 import android.os.Bundle; 22 import android.telecom.Log; 23 import android.telecom.TelecomManager; 24 import android.telephony.DisconnectCause; 25 import android.view.View; 26 import 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 */ 31 public 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 onCreate(Bundle savedInstanceState)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 } 71