1 /* 2 * Copyright (C) 2020 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.cts.verifier.telecom; 18 19 import static com.android.cts.verifier.dialer.DialerCallTestService.EXTRA_CALL_NAME; 20 21 import android.app.Activity; 22 import android.app.KeyguardManager; 23 import android.content.Context; 24 import android.os.Bundle; 25 import android.view.View; 26 import android.widget.Button; 27 import android.widget.TextView; 28 29 import com.android.compatibility.common.util.ApiTest; 30 import com.android.cts.verifier.R; 31 32 @ApiTest(apis={"android.telecom.InCallService"}) 33 public class CtsVerifierInCallUi extends Activity { 34 TextView mCallNumber; 35 Button mButton; 36 37 @Override onCreate(Bundle savedInstanceState)38 protected void onCreate(Bundle savedInstanceState) { 39 super.onCreate(savedInstanceState); 40 41 View view = getLayoutInflater().inflate(R.layout.incall_screen, null); 42 setContentView(view); 43 setTurnScreenOn(true); 44 setShowWhenLocked(true); 45 KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); 46 km.requestDismissKeyguard(this, null); 47 48 mCallNumber = view.findViewById(R.id.incoming_call_number); 49 if (mCallNumber == null) { 50 finish(); 51 return; 52 } 53 54 mButton = view.findViewById(R.id.telecom_default_dialer_end_button); 55 if (mButton == null) { 56 finish(); 57 return; 58 } 59 60 mCallNumber.setText(getIntent().getStringExtra(EXTRA_CALL_NAME)); 61 mButton.setOnClickListener(v -> { 62 boolean pass = false; 63 if (km.isDeviceLocked()) { 64 pass = true; 65 } 66 CtsIncomingCall.getInstance().setAcceptWhenLocked(pass); 67 CtsIncomingCall.getInstance().disconnectCall(); 68 finish(); 69 }); 70 } 71 } 72