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 38 abstract class AudioWiredDeviceBaseActivity extends PassFailButtons.Activity { 39 private static final String TAG = AudioWiredDeviceBaseActivity.class.getSimpleName(); 40 41 private OnBtnClickListener mBtnClickListener = new OnBtnClickListener(); 42 enableTestButtons(boolean enabled)43 abstract protected void enableTestButtons(boolean enabled); 44 recordWiredPortFound(boolean found)45 private void recordWiredPortFound(boolean found) { 46 getReportLog().addValue( 47 "User Reported Wired Port", 48 found ? 1.0 : 0, 49 ResultType.NEUTRAL, 50 ResultUnit.NONE); 51 } 52 setup()53 protected void setup() { 54 // The "Honor" system buttons 55 ((Button)findViewById(R.id.audio_wired_no)).setOnClickListener(mBtnClickListener); 56 ((Button)findViewById(R.id.audio_wired_yes)).setOnClickListener(mBtnClickListener); 57 58 enableTestButtons(false); 59 } 60 61 private class OnBtnClickListener implements OnClickListener { 62 @Override onClick(View v)63 public void onClick(View v) { 64 switch (v.getId()) { 65 case R.id.audio_wired_no: 66 Log.i(TAG, "User denies wired device existence"); 67 enableTestButtons(false); 68 recordWiredPortFound(false); 69 break; 70 71 case R.id.audio_wired_yes: 72 Log.i(TAG, "User confirms wired device existence"); 73 enableTestButtons(true); 74 recordWiredPortFound(true); 75 break; 76 } 77 } 78 } 79 80 }