Loading services/core/java/com/android/server/am/ActivityManagerService.java +13 −10 Original line number Diff line number Diff line Loading @@ -2385,9 +2385,13 @@ public class ActivityManagerService extends IActivityManager.Stub idleUids(); } break; case VR_MODE_CHANGE_MSG: { if (mVrController.onVrModeChanged((ActivityRecord) msg.obj)) { if (!mVrController.onVrModeChanged((ActivityRecord) msg.obj)) { return; } synchronized (ActivityManagerService.this) { if (mVrController.shouldDisableNonVrUiLocked()) { final boolean disableNonVrUi = mVrController.shouldDisableNonVrUiLocked(); mWindowManager.disableNonVrUi(disableNonVrUi); if (disableNonVrUi) { // If we are in a VR mode where Picture-in-Picture mode is unsupported, // then remove the pinned stack. final PinnedActivityStack pinnedStack = mStackSupervisor.getStack( Loading @@ -2397,7 +2401,6 @@ public class ActivityManagerService extends IActivityManager.Stub } } } } } break; case NOTIFY_VR_SLEEPING_MSG: { notifyVrManagerOfSleepState(msg.arg1 != 0); services/core/java/com/android/server/wm/AlertWindowNotification.java +11 −4 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ class AlertWindowNotification { private String mNotificationTag; private final NotificationManager mNotificationManager; private final String mPackageName; private boolean mCancelled; private boolean mPosted; private IconUtilities mIconUtilities; AlertWindowNotification(WindowManagerService service, String packageName) { Loading @@ -61,7 +61,9 @@ class AlertWindowNotification { mNotificationTag = CHANNEL_PREFIX + mPackageName; mRequestCode = sNextRequestCode++; mIconUtilities = new IconUtilities(mService.mContext); } void post() { // We can't create/post the notification while the window manager lock is held since it will // end up calling into activity manager. So, we post a message to do it later. mService.mH.post(this::onPostNotification); Loading @@ -76,16 +78,21 @@ class AlertWindowNotification { /** Don't call with the window manager lock held! */ private void onCancelNotification() { if (!mPosted) { // Notification isn't currently posted... return; } mPosted = false; mNotificationManager.cancel(mNotificationTag, NOTIFICATION_ID); mCancelled = true; } /** Don't call with the window manager lock held! */ private void onPostNotification() { if (mCancelled) { // Notification was cancelled, so nothing more to do... if (mPosted) { // Notification already posted... return; } mPosted = true; final Context context = mService.mContext; final PackageManager pm = context.getPackageManager(); Loading services/core/java/com/android/server/wm/Session.java +16 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ public class Session extends IWindowSession.Stub private final Set<WindowSurfaceController> mAlertWindowSurfaces = new HashSet<>(); final boolean mCanAddInternalSystemWindow; private AlertWindowNotification mAlertWindowNotification; private boolean mShowingAlertWindowNotificationAllowed; private boolean mClientDead = false; private float mLastReportedAnimatorScale; private String mPackageName; Loading @@ -95,6 +96,7 @@ public class Session extends IWindowSession.Stub mLastReportedAnimatorScale = service.getCurrentAnimatorScale(); mCanAddInternalSystemWindow = service.mContext.checkCallingOrSelfPermission( INTERNAL_SYSTEM_WINDOW) == PERMISSION_GRANTED; mShowingAlertWindowNotificationAllowed = mService.mShowAlertWindowNotifications; StringBuilder sb = new StringBuilder(); sb.append("Session{"); sb.append(Integer.toHexString(System.identityHashCode(this))); Loading Loading @@ -591,6 +593,9 @@ public class Session extends IWindowSession.Stub cancelAlertWindowNotification(); } else if (mAlertWindowNotification == null){ mAlertWindowNotification = new AlertWindowNotification(mService, mPackageName); if (mShowingAlertWindowNotificationAllowed) { mAlertWindowNotification.post(); } } } } Loading @@ -612,6 +617,17 @@ public class Session extends IWindowSession.Stub } } void setShowingAlertWindowNotificationAllowed(boolean allowed) { mShowingAlertWindowNotificationAllowed = allowed; if (mAlertWindowNotification != null) { if (allowed) { mAlertWindowNotification.post(); } else { mAlertWindowNotification.cancel(); } } } private void killSessionLocked() { if (mNumWindow > 0 || !mClientDead) { return; Loading services/core/java/com/android/server/wm/WindowManagerService.java +20 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,9 @@ public class WindowManagerService extends IWindowManager.Stub final DisplaySettings mDisplaySettings; /** If the system should display notifications for apps displaying an alert window. */ boolean mShowAlertWindowNotifications = true; /** * All currently active sessions with clients. */ Loading Loading @@ -7370,4 +7373,21 @@ public class WindowManagerService extends IWindowManager.Stub } } } /** Called to inform window manager if non-Vr UI shoul be disabled or not. */ public void disableNonVrUi(boolean disable) { synchronized (mWindowMap) { // Allow alert window notifications to be shown if non-vr UI is enabled. final boolean showAlertWindowNotifications = !disable; if (showAlertWindowNotifications == mShowAlertWindowNotifications) { return; } mShowAlertWindowNotifications = showAlertWindowNotifications; for (int i = mSessions.size() - 1; i >= 0; --i) { final Session s = mSessions.valueAt(i); s.setShowingAlertWindowNotificationAllowed(mShowAlertWindowNotifications); } } } } Loading
services/core/java/com/android/server/am/ActivityManagerService.java +13 −10 Original line number Diff line number Diff line Loading @@ -2385,9 +2385,13 @@ public class ActivityManagerService extends IActivityManager.Stub idleUids(); } break; case VR_MODE_CHANGE_MSG: { if (mVrController.onVrModeChanged((ActivityRecord) msg.obj)) { if (!mVrController.onVrModeChanged((ActivityRecord) msg.obj)) { return; } synchronized (ActivityManagerService.this) { if (mVrController.shouldDisableNonVrUiLocked()) { final boolean disableNonVrUi = mVrController.shouldDisableNonVrUiLocked(); mWindowManager.disableNonVrUi(disableNonVrUi); if (disableNonVrUi) { // If we are in a VR mode where Picture-in-Picture mode is unsupported, // then remove the pinned stack. final PinnedActivityStack pinnedStack = mStackSupervisor.getStack( Loading @@ -2397,7 +2401,6 @@ public class ActivityManagerService extends IActivityManager.Stub } } } } } break; case NOTIFY_VR_SLEEPING_MSG: { notifyVrManagerOfSleepState(msg.arg1 != 0);
services/core/java/com/android/server/wm/AlertWindowNotification.java +11 −4 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ class AlertWindowNotification { private String mNotificationTag; private final NotificationManager mNotificationManager; private final String mPackageName; private boolean mCancelled; private boolean mPosted; private IconUtilities mIconUtilities; AlertWindowNotification(WindowManagerService service, String packageName) { Loading @@ -61,7 +61,9 @@ class AlertWindowNotification { mNotificationTag = CHANNEL_PREFIX + mPackageName; mRequestCode = sNextRequestCode++; mIconUtilities = new IconUtilities(mService.mContext); } void post() { // We can't create/post the notification while the window manager lock is held since it will // end up calling into activity manager. So, we post a message to do it later. mService.mH.post(this::onPostNotification); Loading @@ -76,16 +78,21 @@ class AlertWindowNotification { /** Don't call with the window manager lock held! */ private void onCancelNotification() { if (!mPosted) { // Notification isn't currently posted... return; } mPosted = false; mNotificationManager.cancel(mNotificationTag, NOTIFICATION_ID); mCancelled = true; } /** Don't call with the window manager lock held! */ private void onPostNotification() { if (mCancelled) { // Notification was cancelled, so nothing more to do... if (mPosted) { // Notification already posted... return; } mPosted = true; final Context context = mService.mContext; final PackageManager pm = context.getPackageManager(); Loading
services/core/java/com/android/server/wm/Session.java +16 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ public class Session extends IWindowSession.Stub private final Set<WindowSurfaceController> mAlertWindowSurfaces = new HashSet<>(); final boolean mCanAddInternalSystemWindow; private AlertWindowNotification mAlertWindowNotification; private boolean mShowingAlertWindowNotificationAllowed; private boolean mClientDead = false; private float mLastReportedAnimatorScale; private String mPackageName; Loading @@ -95,6 +96,7 @@ public class Session extends IWindowSession.Stub mLastReportedAnimatorScale = service.getCurrentAnimatorScale(); mCanAddInternalSystemWindow = service.mContext.checkCallingOrSelfPermission( INTERNAL_SYSTEM_WINDOW) == PERMISSION_GRANTED; mShowingAlertWindowNotificationAllowed = mService.mShowAlertWindowNotifications; StringBuilder sb = new StringBuilder(); sb.append("Session{"); sb.append(Integer.toHexString(System.identityHashCode(this))); Loading Loading @@ -591,6 +593,9 @@ public class Session extends IWindowSession.Stub cancelAlertWindowNotification(); } else if (mAlertWindowNotification == null){ mAlertWindowNotification = new AlertWindowNotification(mService, mPackageName); if (mShowingAlertWindowNotificationAllowed) { mAlertWindowNotification.post(); } } } } Loading @@ -612,6 +617,17 @@ public class Session extends IWindowSession.Stub } } void setShowingAlertWindowNotificationAllowed(boolean allowed) { mShowingAlertWindowNotificationAllowed = allowed; if (mAlertWindowNotification != null) { if (allowed) { mAlertWindowNotification.post(); } else { mAlertWindowNotification.cancel(); } } } private void killSessionLocked() { if (mNumWindow > 0 || !mClientDead) { return; Loading
services/core/java/com/android/server/wm/WindowManagerService.java +20 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,9 @@ public class WindowManagerService extends IWindowManager.Stub final DisplaySettings mDisplaySettings; /** If the system should display notifications for apps displaying an alert window. */ boolean mShowAlertWindowNotifications = true; /** * All currently active sessions with clients. */ Loading Loading @@ -7370,4 +7373,21 @@ public class WindowManagerService extends IWindowManager.Stub } } } /** Called to inform window manager if non-Vr UI shoul be disabled or not. */ public void disableNonVrUi(boolean disable) { synchronized (mWindowMap) { // Allow alert window notifications to be shown if non-vr UI is enabled. final boolean showAlertWindowNotifications = !disable; if (showAlertWindowNotifications == mShowAlertWindowNotifications) { return; } mShowAlertWindowNotifications = showAlertWindowNotifications; for (int i = mSessions.size() - 1; i >= 0; --i) { final Session s = mSessions.valueAt(i); s.setShowingAlertWindowNotificationAllowed(mShowAlertWindowNotifications); } } } }