Merge "Add settings for altering VR display behavior." into nyc-dev
This commit is contained in:
@@ -6042,6 +6042,33 @@ public final class Settings {
|
||||
*/
|
||||
public static final String ENABLED_VR_LISTENERS = "enabled_vr_listeners";
|
||||
|
||||
/**
|
||||
* Behavior of the display while in VR mode.
|
||||
*
|
||||
* One of {@link #VR_DISPLAY_MODE_LOW_PERSISTENCE} or {@link #VR_DISPLAY_MODE_OFF}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String VR_DISPLAY_MODE = "vr_display_mode";
|
||||
|
||||
/**
|
||||
* Lower the display persistence while the system is in VR mode.
|
||||
*
|
||||
* @see PackageManager#FEATURE_VR_MODE_HIGH_PERFORMANCE
|
||||
*
|
||||
* @hide.
|
||||
*/
|
||||
public static final int VR_DISPLAY_MODE_LOW_PERSISTENCE = 0;
|
||||
|
||||
/**
|
||||
* Do not alter the display persistence while the system is in VR mode.
|
||||
*
|
||||
* @see PackageManager#FEATURE_VR_MODE_HIGH_PERFORMANCE
|
||||
*
|
||||
* @hide.
|
||||
*/
|
||||
public static final int VR_DISPLAY_MODE_OFF = 1;
|
||||
|
||||
/**
|
||||
* This are the settings to be backed up.
|
||||
*
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
package com.android.server.lights;
|
||||
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.vr.VrManagerInternal;
|
||||
import com.android.server.vr.VrManagerService;
|
||||
import com.android.server.vr.VrStateListener;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.service.vr.IVrManager;
|
||||
import android.service.vr.IVrStateCallbacks;
|
||||
import android.util.Slog;
|
||||
@@ -36,6 +36,7 @@ public class LightsService extends SystemService {
|
||||
static final boolean DEBUG = false;
|
||||
|
||||
final LightImpl mLights[] = new LightImpl[LightsManager.LIGHT_ID_COUNT];
|
||||
private boolean mVrModeEnabled;
|
||||
|
||||
private final class LightImpl extends Light {
|
||||
|
||||
@@ -179,17 +180,34 @@ public class LightsService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
private int getVrDisplayMode() {
|
||||
int currentUser = ActivityManager.getCurrentUser();
|
||||
return Settings.Secure.getIntForUser(getContext().getContentResolver(),
|
||||
Settings.Secure.VR_DISPLAY_MODE,
|
||||
/*default*/Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
|
||||
currentUser);
|
||||
}
|
||||
|
||||
private final IVrStateCallbacks mVrStateCallbacks = new IVrStateCallbacks.Stub() {
|
||||
@Override
|
||||
public void onVrStateChanged(boolean enabled) throws RemoteException {
|
||||
LightImpl l = mLights[LightsManager.LIGHT_ID_BACKLIGHT];
|
||||
if (enabled) {
|
||||
if (DEBUG) Slog.v(TAG, "VR mode enabled, setting brightness to low persistence");
|
||||
l.enableLowPersistence();
|
||||
int vrDisplayMode = getVrDisplayMode();
|
||||
|
||||
// User leaves VR mode before altering display settings.
|
||||
if (enabled && vrDisplayMode == Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE) {
|
||||
if (!mVrModeEnabled) {
|
||||
if (DEBUG)
|
||||
Slog.v(TAG, "VR mode enabled, setting brightness to low persistence");
|
||||
l.enableLowPersistence();
|
||||
mVrModeEnabled = true;
|
||||
}
|
||||
} else {
|
||||
if (DEBUG) Slog.v(TAG, "VR mode disabled, resetting brightnes");
|
||||
l.disableLowPersistence();
|
||||
if (mVrModeEnabled) {
|
||||
if (DEBUG) Slog.v(TAG, "VR mode disabled, resetting brightnes");
|
||||
l.disableLowPersistence();
|
||||
mVrModeEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -212,7 +212,7 @@ public class EnabledComponentsObserver implements SettingChangeListener {
|
||||
if (userManager == null) {
|
||||
return null;
|
||||
}
|
||||
return userManager.getProfileIdsWithDisabled(ActivityManager.getCurrentUser());
|
||||
return userManager.getEnabledProfileIds(ActivityManager.getCurrentUser());
|
||||
}
|
||||
|
||||
public static ArraySet<ComponentName> loadComponentNames(PackageManager pm, int userId,
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.Set;
|
||||
public class SettingsObserver {
|
||||
|
||||
private final String mSecureSettingName;
|
||||
private final BroadcastReceiver mSettingRestorReceiver;
|
||||
private final BroadcastReceiver mSettingRestoreReceiver;
|
||||
private final ContentObserver mContentObserver;
|
||||
private final Set<SettingChangeListener> mSettingsListeners = new ArraySet<>();
|
||||
|
||||
@@ -67,7 +67,7 @@ public class SettingsObserver {
|
||||
@NonNull final Uri settingUri, @NonNull final String secureSettingName) {
|
||||
|
||||
mSecureSettingName = secureSettingName;
|
||||
mSettingRestorReceiver = new BroadcastReceiver() {
|
||||
mSettingRestoreReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_SETTING_RESTORED.equals(intent.getAction())) {
|
||||
@@ -117,7 +117,6 @@ public class SettingsObserver {
|
||||
*/
|
||||
public void addListener(@NonNull SettingChangeListener listener) {
|
||||
mSettingsListeners.add(listener);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user