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.cts.verifier.R; 30 31 public class CtsVerifierInCallUi extends Activity { 32 TextView mCallNumber; 33 Button mButton; 34 35 @Override onCreate(Bundle savedInstanceState)36 protected void onCreate(Bundle savedInstanceState) { 37 super.onCreate(savedInstanceState); 38 39 View view = getLayoutInflater().inflate(R.layout.incall_screen, null); 40 setContentView(view); 41 setTurnScreenOn(true); 42 setShowWhenLocked(true); 43 KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); 44 km.requestDismissKeyguard(this, null); 45 46 mCallNumber = view.findViewById(R.id.incoming_call_number); 47 if (mCallNumber == null) { 48 finish(); 49 return; 50 } 51 52 mButton = view.findViewById(R.id.telecom_default_dialer_end_button); 53 if (mButton == null) { 54 finish(); 55 return; 56 } 57 58 mCallNumber.setText(getIntent().getStringExtra(EXTRA_CALL_NAME)); 59 mButton.setOnClickListener(v -> { 60 boolean pass = false; 61 if (km.isDeviceLocked()) { 62 pass = true; 63 } 64 CtsIncomingCall.getInstance().setAcceptWhenLocked(pass); 65 CtsIncomingCall.getInstance().disconnectCall(); 66 finish(); 67 }); 68 } 69 } 70