Merge "Add settings for altering VR display behavior." into nyc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0ce9075..e061f6e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6059,6 +6059,15 @@
applications in virtual reality mode.
</string>
+ <!-- Title for what display preferences are applied when device is in VR mode -->
+ <string name="display_vr_pref_title">When device is in VR mode</string>
+
+ <!-- [CHAR LIMIT=70] Put display into low-persistence mode, this decreases motion blur. -->
+ <string name="display_vr_pref_low_persistence">Use low motion blur settings</string>
+
+ <!-- [CHAR LIMIT=70] Do not change display settings. -->
+ <string name="display_vr_pref_off">Do nothing</string>
+
<!-- Sound & notification > Advanced section: Title for managing Do Not Disturb access option. [CHAR LIMIT=40] -->
<string name="manage_zen_access_title">Do Not Disturb access</string>
@@ -6938,7 +6947,7 @@
<!-- Description of allowing overlay setting [CHAR LIMIT=NONE] -->
<string name="allow_overlay_description">This permission allows an app to display on top of other apps you\u2019re using and may interfere with your use of the interface in other applications, or change what you think you are seeing in other applications.</string>
- <!-- Keyword for VR settinsg -->
+ <!-- Keyword for VR setting -->
<string name="keywords_vr_listener">vr virtual reality listener stereo helper service</string>
<!-- Keyword for SYSTEM_ALERT_WINDOW -->
<string name="keywords_system_alert_window">system alert window dialog draw on top other apps</string>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 54b17d3..816f27b 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -106,4 +106,9 @@
settings:keywords="@string/keywords_display_cast_screen"
android:fragment="com.android.settings.wfd.WifiDisplaySettings" />
+ <DropDownPreference
+ android:key="vr_display_pref"
+ android:summary="%s"
+ android:title="@string/display_vr_pref_title" />
+
</PreferenceScreen>
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 95b2879..8e389a9 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -17,12 +17,14 @@
package com.android.settings;
import android.app.Activity;
+import android.app.ActivityManager;
import android.app.UiModeManager;
import android.app.WallpaperManager;
import android.app.admin.DevicePolicyManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.ComponentName;
+import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.hardware.Sensor;
@@ -87,6 +89,7 @@
private static final String KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE
= "camera_double_tap_power_gesture";
private static final String KEY_WALLPAPER = "wallpaper";
+ private static final String KEY_VR_DISPLAY_PREF = "vr_display_pref";
private Preference mFontSizePref;
@@ -207,6 +210,40 @@
removePreference(KEY_AUTO_ROTATE);
}
+ if (isVrDisplayModeAvailable(activity)) {
+ DropDownPreference vrDisplayPref =
+ (DropDownPreference) findPreference(KEY_VR_DISPLAY_PREF);
+ vrDisplayPref.setEntries(new CharSequence[] {
+ activity.getString(R.string.display_vr_pref_low_persistence),
+ activity.getString(R.string.display_vr_pref_off),
+ });
+ vrDisplayPref.setEntryValues(new CharSequence[] { "0", "1" });
+
+ final Context c = activity;
+ int currentUser = ActivityManager.getCurrentUser();
+ int current = Settings.Secure.getIntForUser(c.getContentResolver(),
+ Settings.Secure.VR_DISPLAY_MODE,
+ /*default*/Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
+ currentUser);
+ vrDisplayPref.setValueIndex(current);
+ vrDisplayPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ int i = Integer.parseInt((String) newValue);
+ int u = ActivityManager.getCurrentUser();
+ if (!Settings.Secure.putIntForUser(c.getContentResolver(),
+ Settings.Secure.VR_DISPLAY_MODE,
+ i, u)) {
+ Log.e(TAG, "Could not change setting for " +
+ Settings.Secure.VR_DISPLAY_MODE);
+ }
+ return true;
+ }
+ });
+ } else {
+ removePreference(KEY_VR_DISPLAY_PREF);
+ }
+
mNightModePreference = (ListPreference) findPreference(KEY_NIGHT_MODE);
if (mNightModePreference != null) {
final UiModeManager uiManager = (UiModeManager) getSystemService(
@@ -256,6 +293,11 @@
com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled);
}
+ private static boolean isVrDisplayModeAvailable(Context context) {
+ PackageManager pm = context.getPackageManager();
+ return pm.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE);
+ }
+
private void updateTimeoutPreferenceDescription(long currentTimeout) {
TimeoutListPreference preference = mScreenTimeoutPreference;
String summary;
@@ -515,6 +557,9 @@
if (!isCameraDoubleTapPowerGestureAvailable(context.getResources())) {
result.add(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
}
+ if (!isVrDisplayModeAvailable(context)) {
+ result.add(KEY_VR_DISPLAY_PREF);
+ }
return result;
}
};