Loading services/core/java/com/android/server/am/ActivityManagerService.java +18 −0 Original line number Diff line number Diff line Loading @@ -1717,6 +1717,7 @@ public class ActivityManagerService extends IActivityManager.Stub static final int SERVICE_FOREGROUND_CRASH_MSG = 69; static final int DISPATCH_OOM_ADJ_OBSERVER_MSG = 70; static final int TOP_APP_KILLED_BY_LMK_MSG = 73; static final int NOTIFY_VR_KEYGUARD_MSG = 74; static final int FIRST_ACTIVITY_STACK_MSG = 100; static final int FIRST_BROADCAST_QUEUE_MSG = 200; Loading Loading @@ -2384,6 +2385,9 @@ public class ActivityManagerService extends IActivityManager.Stub case NOTIFY_VR_SLEEPING_MSG: { notifyVrManagerOfSleepState(msg.arg1 != 0); } break; case NOTIFY_VR_KEYGUARD_MSG: { notifyVrManagerOfKeyguardState(msg.arg1 != 0); } break; case HANDLE_TRUST_STORAGE_UPDATE_MSG: { synchronized (ActivityManagerService.this) { for (int i = mLruProcesses.size() - 1 ; i >= 0 ; i--) { Loading Loading @@ -3258,6 +3262,19 @@ public class ActivityManagerService extends IActivityManager.Stub vrService.onSleepStateChanged(isSleeping); } private void sendNotifyVrManagerOfKeyguardState(boolean isShowing) { mHandler.sendMessage( mHandler.obtainMessage(NOTIFY_VR_KEYGUARD_MSG, isShowing ? 1 : 0, 0)); } private void notifyVrManagerOfKeyguardState(boolean isShowing) { final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class); if (vrService == null) { return; } vrService.onKeyguardStateChanged(isShowing); } final void showAskCompatModeDialogLocked(ActivityRecord r) { Message msg = Message.obtain(); msg.what = SHOW_COMPAT_MODE_DIALOG_UI_MSG; Loading Loading @@ -12549,6 +12566,7 @@ public class ActivityManagerService extends IActivityManager.Stub Binder.restoreCallingIdentity(ident); } } sendNotifyVrManagerOfKeyguardState(showing); } @Override services/core/java/com/android/server/vr/VrManagerInternal.java +7 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,13 @@ public abstract class VrManagerInternal { */ public abstract void onScreenStateChanged(boolean isScreenOn); /** * Set whether the keyguard is currently active/showing. * * @param isShowing is {@code true} if the keyguard is active/showing. */ public abstract void onKeyguardStateChanged(boolean isShowing); /** * Return NO_ERROR if the given package is installed on the device and enabled as a * VrListenerService for the given current user, or a negative error code indicating a failure. Loading services/core/java/com/android/server/vr/VrManagerService.java +37 −19 Original line number Diff line number Diff line Loading @@ -115,11 +115,13 @@ public class VrManagerService extends SystemService implements EnabledComponentC /** Null set of sleep sleep flags. */ private static final int FLAG_NONE = 0; /** Flag set when the device is not sleeping. */ private static final int FLAG_AWAKE = 1; private static final int FLAG_AWAKE = 1 << 0; /** Flag set when the screen has been turned on. */ private static final int FLAG_SCREEN_ON = 2; private static final int FLAG_SCREEN_ON = 1 << 1; /** Flag set when the keyguard is not active. */ private static final int FLAG_KEYGUARD_UNLOCKED = 1 << 2; /** Flag indicating that all system sleep flags have been set.*/ private static final int FLAG_ALL = FLAG_AWAKE | FLAG_SCREEN_ON; private static final int FLAG_ALL = FLAG_AWAKE | FLAG_SCREEN_ON | FLAG_KEYGUARD_UNLOCKED; private static native void initializeNative(); private static native void setVrModeNative(boolean enabled); Loading Loading @@ -155,10 +157,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC private final NotificationAccessManager mNotifAccessManager = new NotificationAccessManager(); private INotificationManager mNotificationManager; /** Tracks the state of the screen and keyguard UI.*/ private int mSystemSleepFlags = FLAG_AWAKE; private int mSystemSleepFlags = FLAG_AWAKE | FLAG_KEYGUARD_UNLOCKED; /** * Set when ACTION_USER_UNLOCKED is fired. We shouldn't try to bind to the * vr service before then. * vr service before then. This gets set only once the first time the user unlocks the device * and stays true thereafter. */ private boolean mUserUnlocked; private Vr2dDisplay mVr2dDisplay; Loading Loading @@ -208,7 +211,6 @@ public class VrManagerService extends SystemService implements EnabledComponentC if (mBootsToVr) { setPersistentVrModeEnabled(true); } consumeAndApplyPendingStateLocked(); if (mBootsToVr && !mVrModeEnabled) { setVrMode(true, mDefaultVrService, 0, -1, null); } Loading @@ -230,28 +232,39 @@ public class VrManagerService extends SystemService implements EnabledComponentC } private void setSleepState(boolean isAsleep) { synchronized(mLock) { if (!isAsleep) { mSystemSleepFlags |= FLAG_AWAKE; } else { mSystemSleepFlags &= ~FLAG_AWAKE; setSystemState(FLAG_AWAKE, !isAsleep); } updateVrModeAllowedLocked(); private void setScreenOn(boolean isScreenOn) { setSystemState(FLAG_SCREEN_ON, isScreenOn); } private void setKeyguardShowing(boolean isShowing) { setSystemState(FLAG_KEYGUARD_UNLOCKED, !isShowing); } private void setScreenOn(boolean isScreenOn) { private void setSystemState(int flags, boolean isOn) { synchronized(mLock) { if (isScreenOn) { mSystemSleepFlags |= FLAG_SCREEN_ON; int oldState = mSystemSleepFlags; if (isOn) { mSystemSleepFlags |= flags; } else { mSystemSleepFlags &= ~FLAG_SCREEN_ON; mSystemSleepFlags &= ~flags; } if (oldState != mSystemSleepFlags) { if (DBG) Slog.d(TAG, "System state: " + getStateAsString()); updateVrModeAllowedLocked(); } } } private String getStateAsString() { return new StringBuilder() .append((mSystemSleepFlags & FLAG_AWAKE) != 0 ? "awake, " : "") .append((mSystemSleepFlags & FLAG_SCREEN_ON) != 0 ? "screen_on, " : "") .append((mSystemSleepFlags & FLAG_KEYGUARD_UNLOCKED) != 0 ? "keyguard_off" : "") .toString(); } private void setUserUnlocked() { synchronized(mLock) { Loading Loading @@ -671,6 +684,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC VrManagerService.this.setScreenOn(isScreenOn); } @Override public void onKeyguardStateChanged(boolean isShowing) { VrManagerService.this.setKeyguardShowing(isShowing); } @Override public boolean isCurrentVrListener(String packageName, int userId) { return VrManagerService.this.isCurrentVrListener(packageName, userId); Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +18 −0 Original line number Diff line number Diff line Loading @@ -1717,6 +1717,7 @@ public class ActivityManagerService extends IActivityManager.Stub static final int SERVICE_FOREGROUND_CRASH_MSG = 69; static final int DISPATCH_OOM_ADJ_OBSERVER_MSG = 70; static final int TOP_APP_KILLED_BY_LMK_MSG = 73; static final int NOTIFY_VR_KEYGUARD_MSG = 74; static final int FIRST_ACTIVITY_STACK_MSG = 100; static final int FIRST_BROADCAST_QUEUE_MSG = 200; Loading Loading @@ -2384,6 +2385,9 @@ public class ActivityManagerService extends IActivityManager.Stub case NOTIFY_VR_SLEEPING_MSG: { notifyVrManagerOfSleepState(msg.arg1 != 0); } break; case NOTIFY_VR_KEYGUARD_MSG: { notifyVrManagerOfKeyguardState(msg.arg1 != 0); } break; case HANDLE_TRUST_STORAGE_UPDATE_MSG: { synchronized (ActivityManagerService.this) { for (int i = mLruProcesses.size() - 1 ; i >= 0 ; i--) { Loading Loading @@ -3258,6 +3262,19 @@ public class ActivityManagerService extends IActivityManager.Stub vrService.onSleepStateChanged(isSleeping); } private void sendNotifyVrManagerOfKeyguardState(boolean isShowing) { mHandler.sendMessage( mHandler.obtainMessage(NOTIFY_VR_KEYGUARD_MSG, isShowing ? 1 : 0, 0)); } private void notifyVrManagerOfKeyguardState(boolean isShowing) { final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class); if (vrService == null) { return; } vrService.onKeyguardStateChanged(isShowing); } final void showAskCompatModeDialogLocked(ActivityRecord r) { Message msg = Message.obtain(); msg.what = SHOW_COMPAT_MODE_DIALOG_UI_MSG; Loading Loading @@ -12549,6 +12566,7 @@ public class ActivityManagerService extends IActivityManager.Stub Binder.restoreCallingIdentity(ident); } } sendNotifyVrManagerOfKeyguardState(showing); } @Override
services/core/java/com/android/server/vr/VrManagerInternal.java +7 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,13 @@ public abstract class VrManagerInternal { */ public abstract void onScreenStateChanged(boolean isScreenOn); /** * Set whether the keyguard is currently active/showing. * * @param isShowing is {@code true} if the keyguard is active/showing. */ public abstract void onKeyguardStateChanged(boolean isShowing); /** * Return NO_ERROR if the given package is installed on the device and enabled as a * VrListenerService for the given current user, or a negative error code indicating a failure. Loading
services/core/java/com/android/server/vr/VrManagerService.java +37 −19 Original line number Diff line number Diff line Loading @@ -115,11 +115,13 @@ public class VrManagerService extends SystemService implements EnabledComponentC /** Null set of sleep sleep flags. */ private static final int FLAG_NONE = 0; /** Flag set when the device is not sleeping. */ private static final int FLAG_AWAKE = 1; private static final int FLAG_AWAKE = 1 << 0; /** Flag set when the screen has been turned on. */ private static final int FLAG_SCREEN_ON = 2; private static final int FLAG_SCREEN_ON = 1 << 1; /** Flag set when the keyguard is not active. */ private static final int FLAG_KEYGUARD_UNLOCKED = 1 << 2; /** Flag indicating that all system sleep flags have been set.*/ private static final int FLAG_ALL = FLAG_AWAKE | FLAG_SCREEN_ON; private static final int FLAG_ALL = FLAG_AWAKE | FLAG_SCREEN_ON | FLAG_KEYGUARD_UNLOCKED; private static native void initializeNative(); private static native void setVrModeNative(boolean enabled); Loading Loading @@ -155,10 +157,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC private final NotificationAccessManager mNotifAccessManager = new NotificationAccessManager(); private INotificationManager mNotificationManager; /** Tracks the state of the screen and keyguard UI.*/ private int mSystemSleepFlags = FLAG_AWAKE; private int mSystemSleepFlags = FLAG_AWAKE | FLAG_KEYGUARD_UNLOCKED; /** * Set when ACTION_USER_UNLOCKED is fired. We shouldn't try to bind to the * vr service before then. * vr service before then. This gets set only once the first time the user unlocks the device * and stays true thereafter. */ private boolean mUserUnlocked; private Vr2dDisplay mVr2dDisplay; Loading Loading @@ -208,7 +211,6 @@ public class VrManagerService extends SystemService implements EnabledComponentC if (mBootsToVr) { setPersistentVrModeEnabled(true); } consumeAndApplyPendingStateLocked(); if (mBootsToVr && !mVrModeEnabled) { setVrMode(true, mDefaultVrService, 0, -1, null); } Loading @@ -230,28 +232,39 @@ public class VrManagerService extends SystemService implements EnabledComponentC } private void setSleepState(boolean isAsleep) { synchronized(mLock) { if (!isAsleep) { mSystemSleepFlags |= FLAG_AWAKE; } else { mSystemSleepFlags &= ~FLAG_AWAKE; setSystemState(FLAG_AWAKE, !isAsleep); } updateVrModeAllowedLocked(); private void setScreenOn(boolean isScreenOn) { setSystemState(FLAG_SCREEN_ON, isScreenOn); } private void setKeyguardShowing(boolean isShowing) { setSystemState(FLAG_KEYGUARD_UNLOCKED, !isShowing); } private void setScreenOn(boolean isScreenOn) { private void setSystemState(int flags, boolean isOn) { synchronized(mLock) { if (isScreenOn) { mSystemSleepFlags |= FLAG_SCREEN_ON; int oldState = mSystemSleepFlags; if (isOn) { mSystemSleepFlags |= flags; } else { mSystemSleepFlags &= ~FLAG_SCREEN_ON; mSystemSleepFlags &= ~flags; } if (oldState != mSystemSleepFlags) { if (DBG) Slog.d(TAG, "System state: " + getStateAsString()); updateVrModeAllowedLocked(); } } } private String getStateAsString() { return new StringBuilder() .append((mSystemSleepFlags & FLAG_AWAKE) != 0 ? "awake, " : "") .append((mSystemSleepFlags & FLAG_SCREEN_ON) != 0 ? "screen_on, " : "") .append((mSystemSleepFlags & FLAG_KEYGUARD_UNLOCKED) != 0 ? "keyguard_off" : "") .toString(); } private void setUserUnlocked() { synchronized(mLock) { Loading Loading @@ -671,6 +684,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC VrManagerService.this.setScreenOn(isScreenOn); } @Override public void onKeyguardStateChanged(boolean isShowing) { VrManagerService.this.setKeyguardShowing(isShowing); } @Override public boolean isCurrentVrListener(String packageName, int userId) { return VrManagerService.this.isCurrentVrListener(packageName, userId); Loading