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.telephony.DisconnectCause;
24 import android.view.View;
25 import android.widget.Button;
26 
27 import com.android.server.telecom.testapps.R;
28 
29 /**
30  * Sample Incoming Call activity for Self-Managed calls.
31  */
32 public class IncomingSelfManagedCallActivity extends Activity {
33     public static final String EXTRA_CALL_ID = "com.android.server.telecom.testapps.extra.CALL_ID";
34 
35     private Button mAnswerCallButton;
36     private Button mRejectCallButton;
37 
38     @Override
onCreate(Bundle savedInstanceState)39     public void onCreate(Bundle savedInstanceState) {
40         super.onCreate(savedInstanceState);
41         Intent launchingIntent = getIntent();
42         int callId = launchingIntent.getIntExtra(EXTRA_CALL_ID, 0);
43         Log.i(this, "showing fullscreen answer ux for call id %d", callId);
44 
45         setContentView(R.layout.self_managed_incoming_call);
46         final SelfManagedConnection connection = SelfManagedCallList.getInstance()
47                 .getConnectionById(callId);
48         mAnswerCallButton = (Button) findViewById(R.id.answerCallButton);
49         mAnswerCallButton.setOnClickListener((View v) -> {
50             if (connection != null) {
51                 connection.setConnectionActive();
52             }
53             finish();
54         });
55         mRejectCallButton = (Button) findViewById(R.id.rejectCallButton);
56         mRejectCallButton.setOnClickListener((View v) -> {
57             if (connection != null) {
58                 connection.setConnectionDisconnected(DisconnectCause.INCOMING_REJECTED);
59                 connection.destroy();
60             }
61             finish();
62         });
63     }
64 }