Merge "Add settings for altering VR display behavior." into nyc-dev
am: 6ada702
* commit '6ada702993227233fd362e98de93cc9e798dc75d':
Add settings for altering VR display behavior.
Change-Id: Iaf8584c47a91b0a49c4075e6d4fcef10afc3ae11
This commit is contained in:
@@ -6042,6 +6042,33 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public static final String ENABLED_VR_LISTENERS = "enabled_vr_listeners";
|
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.
|
* This are the settings to be backed up.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -17,16 +17,16 @@
|
|||||||
package com.android.server.lights;
|
package com.android.server.lights;
|
||||||
|
|
||||||
import com.android.server.SystemService;
|
import com.android.server.SystemService;
|
||||||
import com.android.server.vr.VrManagerInternal;
|
|
||||||
import com.android.server.vr.VrManagerService;
|
import com.android.server.vr.VrManagerService;
|
||||||
import com.android.server.vr.VrStateListener;
|
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.service.vr.IVrManager;
|
import android.service.vr.IVrManager;
|
||||||
import android.service.vr.IVrStateCallbacks;
|
import android.service.vr.IVrStateCallbacks;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -36,6 +36,7 @@ public class LightsService extends SystemService {
|
|||||||
static final boolean DEBUG = false;
|
static final boolean DEBUG = false;
|
||||||
|
|
||||||
final LightImpl mLights[] = new LightImpl[LightsManager.LIGHT_ID_COUNT];
|
final LightImpl mLights[] = new LightImpl[LightsManager.LIGHT_ID_COUNT];
|
||||||
|
private boolean mVrModeEnabled;
|
||||||
|
|
||||||
private final class LightImpl extends Light {
|
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() {
|
private final IVrStateCallbacks mVrStateCallbacks = new IVrStateCallbacks.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onVrStateChanged(boolean enabled) throws RemoteException {
|
public void onVrStateChanged(boolean enabled) throws RemoteException {
|
||||||
LightImpl l = mLights[LightsManager.LIGHT_ID_BACKLIGHT];
|
LightImpl l = mLights[LightsManager.LIGHT_ID_BACKLIGHT];
|
||||||
if (enabled) {
|
int vrDisplayMode = getVrDisplayMode();
|
||||||
if (DEBUG) Slog.v(TAG, "VR mode enabled, setting brightness to low persistence");
|
|
||||||
l.enableLowPersistence();
|
|
||||||
|
|
||||||
|
// 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 {
|
} else {
|
||||||
if (DEBUG) Slog.v(TAG, "VR mode disabled, resetting brightnes");
|
if (mVrModeEnabled) {
|
||||||
l.disableLowPersistence();
|
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) {
|
if (userManager == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return userManager.getProfileIdsWithDisabled(ActivityManager.getCurrentUser());
|
return userManager.getEnabledProfileIds(ActivityManager.getCurrentUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArraySet<ComponentName> loadComponentNames(PackageManager pm, int userId,
|
public static ArraySet<ComponentName> loadComponentNames(PackageManager pm, int userId,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import java.util.Set;
|
|||||||
public class SettingsObserver {
|
public class SettingsObserver {
|
||||||
|
|
||||||
private final String mSecureSettingName;
|
private final String mSecureSettingName;
|
||||||
private final BroadcastReceiver mSettingRestorReceiver;
|
private final BroadcastReceiver mSettingRestoreReceiver;
|
||||||
private final ContentObserver mContentObserver;
|
private final ContentObserver mContentObserver;
|
||||||
private final Set<SettingChangeListener> mSettingsListeners = new ArraySet<>();
|
private final Set<SettingChangeListener> mSettingsListeners = new ArraySet<>();
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ public class SettingsObserver {
|
|||||||
@NonNull final Uri settingUri, @NonNull final String secureSettingName) {
|
@NonNull final Uri settingUri, @NonNull final String secureSettingName) {
|
||||||
|
|
||||||
mSecureSettingName = secureSettingName;
|
mSecureSettingName = secureSettingName;
|
||||||
mSettingRestorReceiver = new BroadcastReceiver() {
|
mSettingRestoreReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (Intent.ACTION_SETTING_RESTORED.equals(intent.getAction())) {
|
if (Intent.ACTION_SETTING_RESTORED.equals(intent.getAction())) {
|
||||||
@@ -117,7 +117,6 @@ public class SettingsObserver {
|
|||||||
*/
|
*/
|
||||||
public void addListener(@NonNull SettingChangeListener listener) {
|
public void addListener(@NonNull SettingChangeListener listener) {
|
||||||
mSettingsListeners.add(listener);
|
mSettingsListeners.add(listener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user