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.cts.verifier.telecom; 18 19 import android.os.Bundle; 20 import android.telecom.PhoneAccount; 21 import android.view.View; 22 import android.widget.Button; 23 import android.widget.ImageView; 24 25 import com.android.compatibility.common.util.ApiTest; 26 import com.android.compatibility.common.util.CddTest; 27 import com.android.cts.verifier.PassFailButtons; 28 import com.android.cts.verifier.R; 29 30 /** 31 * Tests that a new {@link android.telecom.ConnectionService} be added and its associated 32 * {@link android.telecom.PhoneAccount} enabled using the calling accounts settings screen. 33 */ 34 @ApiTest(apis={"android.telecom.ConnectionService", "android.telecom.PhoneAccount"}) 35 @CddTest(requirement="3.2.3.5/C-2-3") 36 public class EnablePhoneAccountTestActivity extends PassFailButtons.Activity { 37 38 private Button mRegisterPhoneAccount; 39 private Button mConfirm; 40 private ImageView mStep1Status; 41 private ImageView mStep2Status; 42 43 @Override onCreate(Bundle savedInstanceState)44 protected void onCreate(Bundle savedInstanceState) { 45 super.onCreate(savedInstanceState); 46 View view = getLayoutInflater().inflate(R.layout.telecom_enable_phone_account, null); 47 setContentView(view); 48 setInfoResources(R.string.telecom_enable_phone_account_test, 49 R.string.telecom_enable_phone_account_info, -1); 50 setPassFailButtonClickListeners(); 51 getPassButton().setEnabled(false); 52 53 mRegisterPhoneAccount = (Button) view.findViewById( 54 R.id.telecom_enable_phone_account_register_button); 55 mRegisterPhoneAccount.setOnClickListener(v -> { 56 PhoneAccountUtils.registerTestPhoneAccount(this); 57 PhoneAccount account = PhoneAccountUtils.getPhoneAccount(this); 58 if (account != null) { 59 mConfirm.setEnabled(true); 60 mRegisterPhoneAccount.setEnabled(false); 61 mStep1Status.setImageResource(R.drawable.fs_good); 62 } else { 63 mStep1Status.setImageResource(R.drawable.fs_error); 64 } 65 }); 66 67 mConfirm = (Button) view.findViewById(R.id.telecom_enable_phone_account_confirm_button); 68 mConfirm.setOnClickListener(v -> { 69 PhoneAccount account = PhoneAccountUtils.getPhoneAccount(this); 70 if (account != null && account.isEnabled()) { 71 getPassButton().setEnabled(true); 72 mStep2Status.setImageResource(R.drawable.fs_good); 73 mConfirm.setEnabled(false); 74 PhoneAccountUtils.unRegisterTestPhoneAccount(this); 75 } else { 76 mStep2Status.setImageResource(R.drawable.fs_error); 77 } 78 }); 79 mConfirm.setEnabled(false); 80 81 mStep1Status = (ImageView) view.findViewById(R.id.step_1_status); 82 mStep2Status = (ImageView) view.findViewById(R.id.step_2_status); 83 } 84 85 } 86