Update window with FLAG_SECURE when bouncer is showing
This will prevent bouncer interactions from showing up in
screenrecords or screenshots.
Fixes: 215005011
Test: atest NotificationShadeWindowControllerImpl && take screenshot
with bouncer up
Change-Id: I3f59df865dc2dd13d4b9ac54bb2dacb7b23f0aa1
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java
index ffbf282..67b4dbb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java
@@ -30,6 +30,7 @@
import android.graphics.PixelFormat;
import android.graphics.Region;
import android.os.Binder;
+import android.os.Build;
import android.os.RemoteException;
import android.os.Trace;
import android.util.Log;
@@ -327,6 +328,16 @@
Trace.setCounter("display_max_refresh_rate",
(long) mLpChanged.preferredMaxDisplayRefreshRate);
}
+
+ if (state.mBouncerShowing && !isDebuggable()) {
+ mLpChanged.flags |= LayoutParams.FLAG_SECURE;
+ } else {
+ mLpChanged.flags &= ~LayoutParams.FLAG_SECURE;
+ }
+ }
+
+ protected boolean isDebuggable() {
+ return Build.IS_DEBUGGABLE;
}
private void adjustScreenOrientation(State state) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java
index 79cbed8..ddccd83 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java
@@ -18,6 +18,7 @@
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
+import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import static com.google.common.truth.Truth.assertThat;
@@ -92,7 +93,12 @@
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mKeyguardViewMediator, mKeyguardBypassController,
mColorExtractor, mDumpManager, mKeyguardStateController,
- mScreenOffAnimationController, mAuthController);
+ mScreenOffAnimationController, mAuthController) {
+ @Override
+ protected boolean isDebuggable() {
+ return false;
+ }
+ };
mNotificationShadeWindowController.setScrimsVisibilityListener((visibility) -> {});
mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);
@@ -232,6 +238,22 @@
}
@Test
+ public void setKeyguardShowing_enablesSecureFlag() {
+ mNotificationShadeWindowController.setBouncerShowing(true);
+
+ verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
+ assertThat((mLayoutParameters.getValue().flags & FLAG_SECURE) != 0).isTrue();
+ }
+
+ @Test
+ public void setKeyguardNotShowing_disablesSecureFlag() {
+ mNotificationShadeWindowController.setBouncerShowing(false);
+
+ verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
+ assertThat((mLayoutParameters.getValue().flags & FLAG_SECURE) == 0).isTrue();
+ }
+
+ @Test
public void rotationBecameAllowed_layoutParamsUpdated() {
mNotificationShadeWindowController.setKeyguardShowing(true);
when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(false);