1 /*
2  * Copyright (C) 2021 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.server.telecom.callaudiotest;
18 
19 import android.app.Activity;
20 import android.content.Intent;
21 import android.content.SharedPreferences;
22 import android.net.Uri;
23 import android.os.Bundle;
24 import android.view.View;
25 import android.widget.Button;
26 import android.widget.CheckBox;
27 import android.widget.CompoundButton;
28 import android.widget.EditText;
29 
30 /**
31  * Activity to configure the auto answer behavior.
32  */
33 public class CallAudioTestActivity extends Activity {
34     private static final int RESULT_PICK_FILE = 1;
35     public static final String AUDIO_TEST_PREFS = "audio_test_prefs";
36     public static final String AUTO_ANSWER_ENABLED = "auto_answer_enabled";
37     private CheckBox mEnable;
38 
39     @Override
onCreate(Bundle savedInstanceState)40     public void onCreate(Bundle savedInstanceState) {
41         super.onCreate(savedInstanceState);
42 
43         setContentView(R.layout.call_audio_test_activity);
44         mEnable = findViewById(R.id.enableAutoAnswer);
45         mEnable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
46             @Override
47             public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
48                 SharedPreferences prefs = getSharedPreferences(AUDIO_TEST_PREFS, MODE_PRIVATE);
49                 SharedPreferences.Editor edit = prefs.edit();
50                 edit.putBoolean(AUTO_ANSWER_ENABLED, isChecked);
51                 edit.apply();
52             }
53         });
54         loadPreferences();
55     }
56 
loadPreferences()57     private void loadPreferences() {
58         SharedPreferences prefs = getSharedPreferences(AUDIO_TEST_PREFS, MODE_PRIVATE);
59         mEnable.setChecked(prefs.getBoolean(AUTO_ANSWER_ENABLED, false));
60     }
61 }
62