[conflict] [DO NOT MERGE] Update window with FLAG_SECURE when bouncer is showing am: c561831af7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19952040

Change-Id: Ie7874f87fa568f76047a9e08dae3d406b7b565f0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Matt Pietal
2022-09-27 19:49:39 +00:00
2 changed files with 42 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ import android.content.pm.ActivityInfo;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.os.Binder;
import android.os.Build;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.Trace;
@@ -248,6 +249,16 @@ public class StatusBarWindowController implements Callback, Dumpable, Configurat
}
Trace.setCounter("display_mode_id", mLpChanged.preferredDisplayModeId);
}
if (state.bouncerShowing && !isDebuggable()) {
mLpChanged.flags |= LayoutParams.FLAG_SECURE;
} else {
mLpChanged.flags &= ~LayoutParams.FLAG_SECURE;
}
}
protected boolean isDebuggable() {
return Build.IS_DEBUGGABLE;
}
private void adjustScreenOrientation(State state) {

View File

@@ -16,6 +16,8 @@
package com.android.systemui.statusbar.phone;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -40,6 +42,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -62,6 +65,8 @@ public class StatusBarWindowControllerTest extends SysuiTestCase {
private ConfigurationController mConfigurationController;
@Mock
private KeyguardBypassController mKeyguardBypassController;
@Captor
private ArgumentCaptor<WindowManager.LayoutParams> mLayoutParameters;
private StatusBarWindowController mStatusBarWindowController;
@@ -72,24 +77,27 @@ public class StatusBarWindowControllerTest extends SysuiTestCase {
mStatusBarWindowController = new StatusBarWindowController(mContext, mWindowManager,
mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mKeyguardBypassController);
mConfigurationController, mKeyguardBypassController) {
@Override
protected boolean isDebuggable() {
return false;
}
};
mStatusBarWindowController.add(mStatusBarView, 100 /* height */);
}
@Test
public void testSetDozing_hidesSystemOverlays() {
mStatusBarWindowController.setDozing(true);
ArgumentCaptor<WindowManager.LayoutParams> captor =
ArgumentCaptor.forClass(WindowManager.LayoutParams.class);
verify(mWindowManager).updateViewLayout(any(), captor.capture());
int flag = captor.getValue().privateFlags
verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
int flag = mLayoutParameters.getValue().privateFlags
& WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
assertThat(flag).isNotEqualTo(0);
reset(mWindowManager);
mStatusBarWindowController.setDozing(false);
verify(mWindowManager).updateViewLayout(any(), captor.capture());
flag = captor.getValue().privateFlags
verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
flag = mLayoutParameters.getValue().privateFlags
& WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
assertThat(flag).isEqualTo(0);
}
@@ -114,4 +122,20 @@ public class StatusBarWindowControllerTest extends SysuiTestCase {
mConfigurationController, mKeyguardBypassController);
mStatusBarWindowController.setForcePluginOpen(true);
}
@Test
public void setKeyguardShowing_enablesSecureFlag() {
mStatusBarWindowController.setBouncerShowing(true);
verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
assertThat((mLayoutParameters.getValue().flags & FLAG_SECURE) != 0).isTrue();
}
@Test
public void setKeyguardNotShowing_disablesSecureFlag() {
mStatusBarWindowController.setBouncerShowing(false);
verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
assertThat((mLayoutParameters.getValue().flags & FLAG_SECURE) == 0).isTrue();
}
}