blob: a82b9949297c553e61986d3b4d5ae90c6180f20f [file] [log] [blame]
Paul McLeana7b5b952015-10-15 13:06:39 -06001/*
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
17package com.android.cts.verifier.audio;
18
19import com.android.cts.verifier.PassFailButtons;
20import com.android.cts.verifier.R;
21
22import com.android.compatibility.common.util.ReportLog;
23import com.android.compatibility.common.util.ResultType;
24import com.android.compatibility.common.util.ResultUnit;
25
26import android.content.Context;
27
28import android.os.Bundle;
29import android.os.Handler;
30
31import android.util.Log;
32
33import android.view.View;
34import android.view.View.OnClickListener;
35
36import android.widget.Button;
37//import android.widget.TextView;
38
39abstract class HeadsetHonorSystemActivity extends PassFailButtons.Activity {
40 private static final String TAG = "HeadsetHonorSystemActivity";
41
42 private OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
43
44 abstract protected void enableTestButtons(boolean enabled);
45
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
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
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}