• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.Call;
23 import android.telecom.VideoProfile;
24 import android.util.Log;
25 import android.view.View;
26 import android.view.View.OnClickListener;
27 import android.widget.ListView;
28 import android.widget.Toast;
29 
30 public class TestInCallUI extends Activity {
31 
32     private ListView mListView;
33     private TestCallList mCallList;
34 
35     /** ${inheritDoc} */
36     @Override
onCreate(Bundle savedInstanceState)37     protected void onCreate(Bundle savedInstanceState) {
38         super.onCreate(savedInstanceState);
39 
40         setContentView(R.layout.incall_screen);
41 
42         mListView = (ListView) findViewById(R.id.callListView);
43         mListView.setAdapter(new CallListAdapter(this));
44         mListView.setVisibility(View.VISIBLE);
45 
46         mCallList = TestCallList.getInstance();
47         mCallList.addListener(new TestCallList.Listener() {
48             @Override
49             public void onCallRemoved(Call call) {
50                 if (mCallList.size() == 0) {
51                     Log.i(TestInCallUI.class.getSimpleName(), "Ending the incall UI");
52                     finish();
53                 }
54             }
55 
56             @Override
57             public void onRttStarted(Call call) {
58                 Toast.makeText(TestInCallUI.this, "RTT now enabled", Toast.LENGTH_SHORT).show();
59             }
60 
61             @Override
62             public void onRttStopped(Call call) {
63                 Toast.makeText(TestInCallUI.this, "RTT now disabled", Toast.LENGTH_SHORT).show();
64             }
65 
66             @Override
67             public void onRttInitiationFailed(Call call, int reason) {
68                 Toast.makeText(TestInCallUI.this, String.format("RTT failed to init: %d", reason),
69                         Toast.LENGTH_SHORT).show();
70             }
71 
72             @Override
73             public void onRttRequest(Call call, int id) {
74                 Toast.makeText(TestInCallUI.this, String.format("RTT request: %d", id),
75                         Toast.LENGTH_SHORT).show();
76             }
77         });
78 
79         View endCallButton = findViewById(R.id.end_call_button);
80         View holdButton = findViewById(R.id.hold_button);
81         View muteButton = findViewById(R.id.mute_button);
82         View rttIfaceButton = findViewById(R.id.rtt_iface_button);
83         View answerButton = findViewById(R.id.answer_button);
84         View startRttButton = findViewById(R.id.start_rtt_button);
85         View acceptRttButton = findViewById(R.id.accept_rtt_button);
86 
87         endCallButton.setOnClickListener(new OnClickListener() {
88             @Override
89             public void onClick(View view) {
90                 Call call = mCallList.getCall(0);
91                 if (call != null) {
92                     call.disconnect();
93                 }
94             }
95         });
96         holdButton.setOnClickListener(new OnClickListener() {
97             @Override
98             public void onClick(View view) {
99                 Call call = mCallList.getCall(0);
100                 if (call != null) {
101                     if (call.getState() == Call.STATE_HOLDING) {
102                         call.unhold();
103                     } else {
104                         call.hold();
105                     }
106                 }
107             }
108         });
109         muteButton.setOnClickListener(new OnClickListener() {
110             @Override
111             public void onClick(View view) {
112                 Call call = mCallList.getCall(0);
113                 if (call != null) {
114 
115                 }
116             }
117         });
118 
119         rttIfaceButton.setOnClickListener((view) -> {
120             Call call = mCallList.getCall(0);
121             if (call.isRttActive()) {
122                 Intent intent = new Intent(Intent.ACTION_MAIN);
123                 intent.setClass(this, TestRttActivity.class);
124                 startActivity(intent);
125             }
126         });
127 
128         answerButton.setOnClickListener(view -> {
129             Call call = mCallList.getCall(0);
130             if (call.getState() == Call.STATE_RINGING) {
131                 call.answer(VideoProfile.STATE_AUDIO_ONLY);
132             }
133         });
134 
135         startRttButton.setOnClickListener(view -> {
136             Call call = mCallList.getCall(0);
137             if (!call.isRttActive()) {
138                 call.sendRttRequest();
139             }
140         });
141 
142         acceptRttButton.setOnClickListener(view -> {
143             Call call = mCallList.getCall(0);
144             if (!call.isRttActive()) {
145                 call.respondToRttRequest(mCallList.getLastRttRequestId(), true);
146             }
147         });
148     }
149 
150     /** ${inheritDoc} */
151     @Override
onDestroy()152     protected void onDestroy() {
153         super.onDestroy();
154     }
155 
156     @Override
onPause()157     protected void onPause() {
158         super.onPause();
159     }
160 
161     @Override
onStart()162     protected void onStart() {
163         super.onStart();
164     }
165 
166     @Override
onResume()167     protected void onResume() {
168         super.onResume();
169     }
170 }
171