1 /* 2 * Copyright (C) 2015 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.audio; 18 19 import com.android.cts.verifier.PassFailButtons; 20 import com.android.cts.verifier.R; 21 22 import com.android.compatibility.common.util.ReportLog; 23 import com.android.compatibility.common.util.ResultType; 24 import com.android.compatibility.common.util.ResultUnit; 25 26 import android.content.Context; 27 28 import android.os.Bundle; 29 import android.os.Handler; 30 31 import android.util.Log; 32 33 import android.view.View; 34 import android.view.View.OnClickListener; 35 36 import android.widget.Button; 37 //import android.widget.TextView; 38 39 abstract class HeadsetHonorSystemActivity extends PassFailButtons.Activity { 40 private static final String TAG = "HeadsetHonorSystemActivity"; 41 42 private OnBtnClickListener mBtnClickListener = new OnBtnClickListener(); 43 enableTestButtons(boolean enabled)44 abstract protected void enableTestButtons(boolean enabled); 45 recordHeadsetPortFound(boolean found)46 private void recordHeadsetPortFound(boolean found) { 47 getReportLog().addValue( 48 "User Reported Headset Port", 49 found ? 1.0 : 0, 50 ResultType.NEUTRAL, 51 ResultUnit.NONE); 52 } 53 setup()54 protected void setup() { 55 // The "Honor" system buttons 56 ((Button)findViewById(R.id.audio_general_headset_no)). 57 setOnClickListener(mBtnClickListener); 58 ((Button)findViewById(R.id.audio_general_headset_yes)). 59 setOnClickListener(mBtnClickListener); 60 61 enableTestButtons(false); 62 } 63 64 private class OnBtnClickListener implements OnClickListener { 65 @Override onClick(View v)66 public void onClick(View v) { 67 switch (v.getId()) { 68 case R.id.audio_general_headset_no: 69 Log.i(TAG, "User denies Headset Port existence"); 70 enableTestButtons(false); 71 recordHeadsetPortFound(false); 72 break; 73 74 case R.id.audio_general_headset_yes: 75 Log.i(TAG, "User confirms Headset Port existence"); 76 enableTestButtons(true); 77 recordHeadsetPortFound(true); 78 break; 79 } 80 } 81 } 82 83 }