• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.tv.settings.device.displaysound;
18 
19 import static android.provider.Settings.Secure.MINIMAL_POST_PROCESSING_ALLOWED;
20 
21 import android.os.Bundle;
22 import android.provider.Settings;
23 import android.text.TextUtils;
24 
25 import androidx.annotation.Keep;
26 import androidx.preference.Preference;
27 import androidx.preference.SwitchPreference;
28 
29 import com.android.internal.logging.nano.MetricsProto;
30 import com.android.tv.settings.R;
31 import com.android.tv.settings.SettingsPreferenceFragment;
32 
33 /**
34  * The "Advanced display settings" screen in TV Settings.
35  */
36 @Keep
37 public class AdvancedDisplayFragment extends SettingsPreferenceFragment {
38     private static final String KEY_GAME_MODE = "game_mode";
39 
40     @Override
getMetricsCategory()41     public int getMetricsCategory() {
42         return MetricsProto.MetricsEvent.DISPLAY;
43     }
44 
45     @Override
onCreatePreferences(Bundle bundle, String s)46     public void onCreatePreferences(Bundle bundle, String s) {
47         setPreferencesFromResource(R.xml.advanced_display, null);
48         SwitchPreference gameModePreference = findPreference(KEY_GAME_MODE);
49         gameModePreference.setChecked(getGameModeStatus() == 1);
50     }
51 
52     @Override
onPreferenceTreeClick(Preference preference)53     public boolean onPreferenceTreeClick(Preference preference) {
54         if (TextUtils.equals(preference.getKey(), KEY_GAME_MODE)) {
55             setGameModeStatus(((SwitchPreference) preference).isChecked() ? 1 : 0);
56         }
57         return super.onPreferenceTreeClick(preference);
58     }
59 
getGameModeStatus()60     private int getGameModeStatus() {
61         return Settings.Secure.getInt(getActivity().getContentResolver(),
62                 MINIMAL_POST_PROCESSING_ALLOWED,
63                 1);
64     }
65 
setGameModeStatus(int state)66     private void setGameModeStatus(int state) {
67         Settings.Secure.putInt(getActivity().getContentResolver(), MINIMAL_POST_PROCESSING_ALLOWED,
68                 state);
69     }
70 }
71