• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.settings;
18 
19 import android.app.Activity;
20 import android.app.ActivityManager;
21 import android.app.UiModeManager;
22 import android.app.WallpaperManager;
23 import android.app.admin.DevicePolicyManager;
24 import android.content.ContentResolver;
25 import android.content.Context;
26 import android.content.ComponentName;
27 import android.content.pm.PackageManager;
28 import android.content.res.Configuration;
29 import android.content.res.Resources;
30 import android.hardware.Sensor;
31 import android.hardware.SensorManager;
32 import android.os.Build;
33 import android.os.Bundle;
34 import android.os.SystemProperties;
35 import android.os.UserHandle;
36 import android.os.UserManager;
37 import android.provider.SearchIndexableResource;
38 import android.provider.Settings;
39 import android.support.v14.preference.SwitchPreference;
40 import android.support.v7.preference.DropDownPreference;
41 import android.support.v7.preference.ListPreference;
42 import android.support.v7.preference.Preference;
43 import android.support.v7.preference.Preference.OnPreferenceChangeListener;
44 import android.text.TextUtils;
45 import android.util.Log;
46 
47 import com.android.internal.logging.MetricsLogger;
48 import com.android.internal.logging.MetricsProto.MetricsEvent;
49 import com.android.internal.view.RotationPolicy;
50 import com.android.settings.accessibility.ToggleFontSizePreferenceFragment;
51 import com.android.settings.dashboard.SummaryLoader;
52 import com.android.settings.search.BaseSearchIndexProvider;
53 import com.android.settings.search.Indexable;
54 import com.android.settingslib.RestrictedLockUtils;
55 import com.android.settingslib.RestrictedPreference;
56 
57 import java.util.ArrayList;
58 import java.util.List;
59 
60 import static android.provider.Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED;
61 import static android.provider.Settings.Secure.CAMERA_GESTURE_DISABLED;
62 import static android.provider.Settings.Secure.DOUBLE_TAP_TO_WAKE;
63 import static android.provider.Settings.Secure.DOZE_ENABLED;
64 import static android.provider.Settings.Secure.WAKE_GESTURE_ENABLED;
65 import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
66 import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
67 import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
68 import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
69 
70 import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
71 
72 public class DisplaySettings extends SettingsPreferenceFragment implements
73         Preference.OnPreferenceChangeListener, Indexable {
74     private static final String TAG = "DisplaySettings";
75 
76     /** If there is no setting in the provider, use this. */
77     private static final int FALLBACK_SCREEN_TIMEOUT_VALUE = 30000;
78 
79     private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
80     private static final String KEY_FONT_SIZE = "font_size";
81     private static final String KEY_SCREEN_SAVER = "screensaver";
82     private static final String KEY_LIFT_TO_WAKE = "lift_to_wake";
83     private static final String KEY_DOZE = "doze";
84     private static final String KEY_TAP_TO_WAKE = "tap_to_wake";
85     private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
86     private static final String KEY_AUTO_ROTATE = "auto_rotate";
87     private static final String KEY_NIGHT_MODE = "night_mode";
88     private static final String KEY_CAMERA_GESTURE = "camera_gesture";
89     private static final String KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE
90             = "camera_double_tap_power_gesture";
91     private static final String KEY_WALLPAPER = "wallpaper";
92     private static final String KEY_VR_DISPLAY_PREF = "vr_display_pref";
93 
94     private Preference mFontSizePref;
95 
96     private TimeoutListPreference mScreenTimeoutPreference;
97     private ListPreference mNightModePreference;
98     private Preference mScreenSaverPreference;
99     private SwitchPreference mLiftToWakePreference;
100     private SwitchPreference mDozePreference;
101     private SwitchPreference mTapToWakePreference;
102     private SwitchPreference mAutoBrightnessPreference;
103     private SwitchPreference mCameraGesturePreference;
104     private SwitchPreference mCameraDoubleTapPowerGesturePreference;
105 
106     @Override
getMetricsCategory()107     protected int getMetricsCategory() {
108         return MetricsEvent.DISPLAY;
109     }
110 
111     @Override
onCreate(Bundle savedInstanceState)112     public void onCreate(Bundle savedInstanceState) {
113         super.onCreate(savedInstanceState);
114         final Activity activity = getActivity();
115         final ContentResolver resolver = activity.getContentResolver();
116 
117         addPreferencesFromResource(R.xml.display_settings);
118 
119         mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER);
120         if (mScreenSaverPreference != null
121                 && getResources().getBoolean(
122                         com.android.internal.R.bool.config_dreamsSupported) == false) {
123             getPreferenceScreen().removePreference(mScreenSaverPreference);
124         }
125 
126         mScreenTimeoutPreference = (TimeoutListPreference) findPreference(KEY_SCREEN_TIMEOUT);
127 
128         mFontSizePref = findPreference(KEY_FONT_SIZE);
129 
130         if (isAutomaticBrightnessAvailable(getResources())) {
131             mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
132             mAutoBrightnessPreference.setOnPreferenceChangeListener(this);
133         } else {
134             removePreference(KEY_AUTO_BRIGHTNESS);
135         }
136 
137         if (isLiftToWakeAvailable(activity)) {
138             mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE);
139             mLiftToWakePreference.setOnPreferenceChangeListener(this);
140         } else {
141             removePreference(KEY_LIFT_TO_WAKE);
142         }
143 
144         if (isDozeAvailable(activity)) {
145             mDozePreference = (SwitchPreference) findPreference(KEY_DOZE);
146             mDozePreference.setOnPreferenceChangeListener(this);
147         } else {
148             removePreference(KEY_DOZE);
149         }
150 
151         if (isTapToWakeAvailable(getResources())) {
152             mTapToWakePreference = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE);
153             mTapToWakePreference.setOnPreferenceChangeListener(this);
154         } else {
155             removePreference(KEY_TAP_TO_WAKE);
156         }
157 
158         if (isCameraGestureAvailable(getResources())) {
159             mCameraGesturePreference = (SwitchPreference) findPreference(KEY_CAMERA_GESTURE);
160             mCameraGesturePreference.setOnPreferenceChangeListener(this);
161         } else {
162             removePreference(KEY_CAMERA_GESTURE);
163         }
164 
165         if (isCameraDoubleTapPowerGestureAvailable(getResources())) {
166             mCameraDoubleTapPowerGesturePreference
167                     = (SwitchPreference) findPreference(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
168             mCameraDoubleTapPowerGesturePreference.setOnPreferenceChangeListener(this);
169         } else {
170             removePreference(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
171         }
172 
173         if (RotationPolicy.isRotationLockToggleVisible(activity)) {
174             DropDownPreference rotatePreference =
175                     (DropDownPreference) findPreference(KEY_AUTO_ROTATE);
176             int rotateLockedResourceId;
177             // The following block sets the string used when rotation is locked.
178             // If the device locks specifically to portrait or landscape (rather than current
179             // rotation), then we use a different string to include this information.
180             if (allowAllRotations(activity)) {
181                 rotateLockedResourceId = R.string.display_auto_rotate_stay_in_current;
182             } else {
183                 if (RotationPolicy.getRotationLockOrientation(activity)
184                         == Configuration.ORIENTATION_PORTRAIT) {
185                     rotateLockedResourceId =
186                             R.string.display_auto_rotate_stay_in_portrait;
187                 } else {
188                     rotateLockedResourceId =
189                             R.string.display_auto_rotate_stay_in_landscape;
190                 }
191             }
192             rotatePreference.setEntries(new CharSequence[] {
193                     activity.getString(R.string.display_auto_rotate_rotate),
194                     activity.getString(rotateLockedResourceId),
195             });
196             rotatePreference.setEntryValues(new CharSequence[] { "0", "1" });
197             rotatePreference.setValueIndex(RotationPolicy.isRotationLocked(activity) ?
198                     1 : 0);
199             rotatePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
200                 @Override
201                 public boolean onPreferenceChange(Preference preference, Object newValue) {
202                     final boolean locked = Integer.parseInt((String) newValue) != 0;
203                     MetricsLogger.action(getActivity(), MetricsEvent.ACTION_ROTATION_LOCK,
204                             locked);
205                     RotationPolicy.setRotationLock(activity, locked);
206                     return true;
207                 }
208             });
209         } else {
210             removePreference(KEY_AUTO_ROTATE);
211         }
212 
213         if (isVrDisplayModeAvailable(activity)) {
214             DropDownPreference vrDisplayPref =
215                     (DropDownPreference) findPreference(KEY_VR_DISPLAY_PREF);
216             vrDisplayPref.setEntries(new CharSequence[] {
217                     activity.getString(R.string.display_vr_pref_low_persistence),
218                     activity.getString(R.string.display_vr_pref_off),
219             });
220             vrDisplayPref.setEntryValues(new CharSequence[] { "0", "1" });
221 
222             final Context c = activity;
223             int currentUser = ActivityManager.getCurrentUser();
224             int current = Settings.Secure.getIntForUser(c.getContentResolver(),
225                             Settings.Secure.VR_DISPLAY_MODE,
226                             /*default*/Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
227                             currentUser);
228             vrDisplayPref.setValueIndex(current);
229             vrDisplayPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
230                 @Override
231                 public boolean onPreferenceChange(Preference preference, Object newValue) {
232                     int i = Integer.parseInt((String) newValue);
233                     int u = ActivityManager.getCurrentUser();
234                     if (!Settings.Secure.putIntForUser(c.getContentResolver(),
235                             Settings.Secure.VR_DISPLAY_MODE,
236                             i, u)) {
237                         Log.e(TAG, "Could not change setting for " +
238                                 Settings.Secure.VR_DISPLAY_MODE);
239                     }
240                     return true;
241                 }
242             });
243         } else {
244             removePreference(KEY_VR_DISPLAY_PREF);
245         }
246 
247         mNightModePreference = (ListPreference) findPreference(KEY_NIGHT_MODE);
248         if (mNightModePreference != null) {
249             final UiModeManager uiManager = (UiModeManager) getSystemService(
250                     Context.UI_MODE_SERVICE);
251             final int currentNightMode = uiManager.getNightMode();
252             mNightModePreference.setValue(String.valueOf(currentNightMode));
253             mNightModePreference.setOnPreferenceChangeListener(this);
254         }
255     }
256 
allowAllRotations(Context context)257     private static boolean allowAllRotations(Context context) {
258         return Resources.getSystem().getBoolean(
259                 com.android.internal.R.bool.config_allowAllRotations);
260     }
261 
isLiftToWakeAvailable(Context context)262     private static boolean isLiftToWakeAvailable(Context context) {
263         SensorManager sensors = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
264         return sensors != null && sensors.getDefaultSensor(Sensor.TYPE_WAKE_GESTURE) != null;
265     }
266 
isDozeAvailable(Context context)267     private static boolean isDozeAvailable(Context context) {
268         String name = Build.IS_DEBUGGABLE ? SystemProperties.get("debug.doze.component") : null;
269         if (TextUtils.isEmpty(name)) {
270             name = context.getResources().getString(
271                     com.android.internal.R.string.config_dozeComponent);
272         }
273         return !TextUtils.isEmpty(name);
274     }
275 
isTapToWakeAvailable(Resources res)276     private static boolean isTapToWakeAvailable(Resources res) {
277         return res.getBoolean(com.android.internal.R.bool.config_supportDoubleTapWake);
278     }
279 
isAutomaticBrightnessAvailable(Resources res)280     private static boolean isAutomaticBrightnessAvailable(Resources res) {
281         return res.getBoolean(com.android.internal.R.bool.config_automatic_brightness_available);
282     }
283 
isCameraGestureAvailable(Resources res)284     private static boolean isCameraGestureAvailable(Resources res) {
285         boolean configSet = res.getInteger(
286                 com.android.internal.R.integer.config_cameraLaunchGestureSensorType) != -1;
287         return configSet &&
288                 !SystemProperties.getBoolean("gesture.disable_camera_launch", false);
289     }
290 
isCameraDoubleTapPowerGestureAvailable(Resources res)291     private static boolean isCameraDoubleTapPowerGestureAvailable(Resources res) {
292         return res.getBoolean(
293                 com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled);
294     }
295 
isVrDisplayModeAvailable(Context context)296     private static boolean isVrDisplayModeAvailable(Context context) {
297         PackageManager pm = context.getPackageManager();
298         return pm.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE);
299     }
300 
updateTimeoutPreferenceDescription(long currentTimeout)301     private void updateTimeoutPreferenceDescription(long currentTimeout) {
302         TimeoutListPreference preference = mScreenTimeoutPreference;
303         String summary;
304         if (preference.isDisabledByAdmin()) {
305             summary = getString(R.string.disabled_by_policy_title);
306         } else if (currentTimeout < 0) {
307             // Unsupported value
308             summary = "";
309         } else {
310             final CharSequence[] entries = preference.getEntries();
311             final CharSequence[] values = preference.getEntryValues();
312             if (entries == null || entries.length == 0) {
313                 summary = "";
314             } else {
315                 int best = 0;
316                 for (int i = 0; i < values.length; i++) {
317                     long timeout = Long.parseLong(values[i].toString());
318                     if (currentTimeout >= timeout) {
319                         best = i;
320                     }
321                 }
322                 summary = getString(R.string.screen_timeout_summary, entries[best]);
323             }
324         }
325         preference.setSummary(summary);
326     }
327 
328     @Override
onResume()329     public void onResume() {
330         super.onResume();
331         updateState();
332 
333         final long currentTimeout = Settings.System.getLong(getActivity().getContentResolver(),
334                 SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
335         mScreenTimeoutPreference.setValue(String.valueOf(currentTimeout));
336         mScreenTimeoutPreference.setOnPreferenceChangeListener(this);
337         final DevicePolicyManager dpm = (DevicePolicyManager) getActivity().getSystemService(
338                 Context.DEVICE_POLICY_SERVICE);
339         if (dpm != null) {
340             final EnforcedAdmin admin = RestrictedLockUtils.checkIfMaximumTimeToLockIsSet(
341                     getActivity());
342             final long maxTimeout = dpm
343                     .getMaximumTimeToLockForUserAndProfiles(UserHandle.myUserId());
344             mScreenTimeoutPreference.removeUnusableTimeouts(maxTimeout, admin);
345         }
346         updateTimeoutPreferenceDescription(currentTimeout);
347 
348         disablePreferenceIfManaged(KEY_WALLPAPER, UserManager.DISALLOW_SET_WALLPAPER);
349     }
350 
updateState()351     private void updateState() {
352         updateFontSizeSummary();
353         updateScreenSaverSummary();
354 
355         // Update auto brightness if it is available.
356         if (mAutoBrightnessPreference != null) {
357             int brightnessMode = Settings.System.getInt(getContentResolver(),
358                     SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL);
359             mAutoBrightnessPreference.setChecked(brightnessMode != SCREEN_BRIGHTNESS_MODE_MANUAL);
360         }
361 
362         // Update lift-to-wake if it is available.
363         if (mLiftToWakePreference != null) {
364             int value = Settings.Secure.getInt(getContentResolver(), WAKE_GESTURE_ENABLED, 0);
365             mLiftToWakePreference.setChecked(value != 0);
366         }
367 
368         // Update doze if it is available.
369         if (mDozePreference != null) {
370             int value = Settings.Secure.getInt(getContentResolver(), DOZE_ENABLED, 1);
371             mDozePreference.setChecked(value != 0);
372         }
373 
374         // Update tap to wake if it is available.
375         if (mTapToWakePreference != null) {
376             int value = Settings.Secure.getInt(getContentResolver(), DOUBLE_TAP_TO_WAKE, 0);
377             mTapToWakePreference.setChecked(value != 0);
378         }
379 
380         // Update camera gesture #1 if it is available.
381         if (mCameraGesturePreference != null) {
382             int value = Settings.Secure.getInt(getContentResolver(), CAMERA_GESTURE_DISABLED, 0);
383             mCameraGesturePreference.setChecked(value == 0);
384         }
385 
386         // Update camera gesture #2 if it is available.
387         if (mCameraDoubleTapPowerGesturePreference != null) {
388             int value = Settings.Secure.getInt(
389                     getContentResolver(), CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
390             mCameraDoubleTapPowerGesturePreference.setChecked(value == 0);
391         }
392     }
393 
updateScreenSaverSummary()394     private void updateScreenSaverSummary() {
395         if (mScreenSaverPreference != null) {
396             mScreenSaverPreference.setSummary(
397                     DreamSettings.getSummaryTextWithDreamName(getActivity()));
398         }
399     }
400 
updateFontSizeSummary()401     private void updateFontSizeSummary() {
402         final Context context = mFontSizePref.getContext();
403         final float currentScale = Settings.System.getFloat(context.getContentResolver(),
404                 Settings.System.FONT_SCALE, 1.0f);
405         final Resources res = context.getResources();
406         final String[] entries = res.getStringArray(R.array.entries_font_size);
407         final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
408         final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(currentScale,
409                 strEntryValues);
410         mFontSizePref.setSummary(entries[index]);
411     }
412 
413     @Override
onPreferenceChange(Preference preference, Object objValue)414     public boolean onPreferenceChange(Preference preference, Object objValue) {
415         final String key = preference.getKey();
416         if (KEY_SCREEN_TIMEOUT.equals(key)) {
417             try {
418                 int value = Integer.parseInt((String) objValue);
419                 Settings.System.putInt(getContentResolver(), SCREEN_OFF_TIMEOUT, value);
420                 updateTimeoutPreferenceDescription(value);
421             } catch (NumberFormatException e) {
422                 Log.e(TAG, "could not persist screen timeout setting", e);
423             }
424         }
425         if (preference == mAutoBrightnessPreference) {
426             boolean auto = (Boolean) objValue;
427             Settings.System.putInt(getContentResolver(), SCREEN_BRIGHTNESS_MODE,
428                     auto ? SCREEN_BRIGHTNESS_MODE_AUTOMATIC : SCREEN_BRIGHTNESS_MODE_MANUAL);
429         }
430         if (preference == mLiftToWakePreference) {
431             boolean value = (Boolean) objValue;
432             Settings.Secure.putInt(getContentResolver(), WAKE_GESTURE_ENABLED, value ? 1 : 0);
433         }
434         if (preference == mDozePreference) {
435             boolean value = (Boolean) objValue;
436             Settings.Secure.putInt(getContentResolver(), DOZE_ENABLED, value ? 1 : 0);
437         }
438         if (preference == mTapToWakePreference) {
439             boolean value = (Boolean) objValue;
440             Settings.Secure.putInt(getContentResolver(), DOUBLE_TAP_TO_WAKE, value ? 1 : 0);
441         }
442         if (preference == mCameraGesturePreference) {
443             boolean value = (Boolean) objValue;
444             Settings.Secure.putInt(getContentResolver(), CAMERA_GESTURE_DISABLED,
445                     value ? 0 : 1 /* Backwards because setting is for disabling */);
446         }
447         if (preference == mCameraDoubleTapPowerGesturePreference) {
448             boolean value = (Boolean) objValue;
449             Settings.Secure.putInt(getContentResolver(), CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
450                     value ? 0 : 1 /* Backwards because setting is for disabling */);
451         }
452         if (preference == mNightModePreference) {
453             try {
454                 final int value = Integer.parseInt((String) objValue);
455                 final UiModeManager uiManager = (UiModeManager) getSystemService(
456                         Context.UI_MODE_SERVICE);
457                 uiManager.setNightMode(value);
458             } catch (NumberFormatException e) {
459                 Log.e(TAG, "could not persist night mode setting", e);
460             }
461         }
462         return true;
463     }
464 
465     @Override
getHelpResource()466     protected int getHelpResource() {
467         return R.string.help_uri_display;
468     }
469 
disablePreferenceIfManaged(String key, String restriction)470     private void disablePreferenceIfManaged(String key, String restriction) {
471         final RestrictedPreference pref = (RestrictedPreference) findPreference(key);
472         if (pref != null) {
473             pref.setDisabledByAdmin(null);
474             if (RestrictedLockUtils.hasBaseUserRestriction(getActivity(), restriction,
475                     UserHandle.myUserId())) {
476                 pref.setEnabled(false);
477             } else {
478                 pref.checkRestrictionAndSetDisabled(restriction);
479             }
480         }
481     }
482 
483     private static class SummaryProvider implements SummaryLoader.SummaryProvider {
484         private final Context mContext;
485         private final SummaryLoader mLoader;
486 
SummaryProvider(Context context, SummaryLoader loader)487         private SummaryProvider(Context context, SummaryLoader loader) {
488             mContext = context;
489             mLoader = loader;
490         }
491 
492         @Override
setListening(boolean listening)493         public void setListening(boolean listening) {
494             if (listening) {
495                 updateSummary();
496             }
497         }
498 
updateSummary()499         private void updateSummary() {
500             boolean auto = Settings.System.getInt(mContext.getContentResolver(),
501                     SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_AUTOMATIC)
502                     == SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
503             mLoader.setSummary(this, mContext.getString(auto ? R.string.display_summary_on
504                     : R.string.display_summary_off));
505         }
506     }
507 
508     public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
509             = new SummaryLoader.SummaryProviderFactory() {
510         @Override
511         public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
512                                                                    SummaryLoader summaryLoader) {
513             return new SummaryProvider(activity, summaryLoader);
514         }
515     };
516 
517     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
518             new BaseSearchIndexProvider() {
519                 @Override
520                 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
521                         boolean enabled) {
522                     ArrayList<SearchIndexableResource> result =
523                             new ArrayList<SearchIndexableResource>();
524 
525                     SearchIndexableResource sir = new SearchIndexableResource(context);
526                     sir.xmlResId = R.xml.display_settings;
527                     result.add(sir);
528 
529                     return result;
530                 }
531 
532                 @Override
533                 public List<String> getNonIndexableKeys(Context context) {
534                     ArrayList<String> result = new ArrayList<String>();
535                     if (!context.getResources().getBoolean(
536                             com.android.internal.R.bool.config_dreamsSupported)) {
537                         result.add(KEY_SCREEN_SAVER);
538                     }
539                     if (!isAutomaticBrightnessAvailable(context.getResources())) {
540                         result.add(KEY_AUTO_BRIGHTNESS);
541                     }
542                     if (!isLiftToWakeAvailable(context)) {
543                         result.add(KEY_LIFT_TO_WAKE);
544                     }
545                     if (!isDozeAvailable(context)) {
546                         result.add(KEY_DOZE);
547                     }
548                     if (!RotationPolicy.isRotationLockToggleVisible(context)) {
549                         result.add(KEY_AUTO_ROTATE);
550                     }
551                     if (!isTapToWakeAvailable(context.getResources())) {
552                         result.add(KEY_TAP_TO_WAKE);
553                     }
554                     if (!isCameraGestureAvailable(context.getResources())) {
555                         result.add(KEY_CAMERA_GESTURE);
556                     }
557                     if (!isCameraDoubleTapPowerGestureAvailable(context.getResources())) {
558                         result.add(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
559                     }
560                     if (!isVrDisplayModeAvailable(context)) {
561                         result.add(KEY_VR_DISPLAY_PREF);
562                     }
563                     return result;
564                 }
565             };
566 }
567