Merge "WM: Prevent secondary display focus while keyguard is up" into oc-dev am: f04714c59a

am: 6281d64277

Change-Id: Ic7b12c406ac5aea0e9f40b5f2c2f72c5efd87212
This commit is contained in:
Adrian Roos
2018-06-04 11:18:38 -07:00
committed by android-build-merger
7 changed files with 56 additions and 2 deletions

View File

@@ -610,6 +610,11 @@ public interface WindowManagerPolicy {
*/
void notifyKeyguardTrustedChanged();
/**
* The keyguard showing state has changed
*/
void onKeyguardShowingAndNotOccludedChanged();
/**
* Notifies the window manager that screen is being turned off.
*

View File

@@ -2150,6 +2150,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public void onTrustedChanged() {
mWindowManagerFuncs.notifyKeyguardTrustedChanged();
}
@Override
public void onShowingChanged() {
mWindowManagerFuncs.onKeyguardShowingAndNotOccludedChanged();
}
});
}

View File

@@ -86,6 +86,8 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
@Override // Binder interface
public void onShowingStateChanged(boolean showing) {
mIsShowing = showing;
mCallback.onShowingChanged();
}
@Override // Binder interface
@@ -119,6 +121,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
public interface StateCallback {
void onTrustedChanged();
void onShowingChanged();
}
public void dump(String prefix, PrintWriter pw) {

View File

@@ -165,10 +165,18 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
}
WindowState computeFocusedWindow() {
// While the keyguard is showing, we must focus anything besides the main display.
// Otherwise we risk input not going to the keyguard when the user expects it to.
final boolean forceDefaultDisplay = mService.mPolicy.isKeyguardShowingAndNotOccluded();
for (int i = mChildren.size() - 1; i >= 0; i--) {
final DisplayContent dc = mChildren.get(i);
final WindowState win = dc.findFocusedWindow();
if (win != null) {
if (forceDefaultDisplay && !dc.isDefaultDisplay) {
EventLog.writeEvent(0x534e4554, "71786287", win.mOwnerUid, "");
continue;
}
return win;
}
}

View File

@@ -2928,6 +2928,11 @@ public class WindowManagerService extends IWindowManager.Stub
mH.sendEmptyMessage(H.NOTIFY_KEYGUARD_TRUSTED_CHANGED);
}
@Override
public void onKeyguardShowingAndNotOccludedChanged() {
mH.sendEmptyMessage(H.RECOMPUTE_FOCUS);
}
@Override
public void screenTurningOff(ScreenOffListener listener) {
mTaskSnapshotController.screenTurningOff(listener);
@@ -4897,6 +4902,7 @@ public class WindowManagerService extends IWindowManager.Stub
public static final int NOTIFY_KEYGUARD_FLAGS_CHANGED = 56;
public static final int NOTIFY_KEYGUARD_TRUSTED_CHANGED = 57;
public static final int SET_HAS_OVERLAY_UI = 58;
public static final int RECOMPUTE_FOCUS = 61;
/**
* Used to denote that an integer field in a message will not be used.
@@ -5363,6 +5369,13 @@ public class WindowManagerService extends IWindowManager.Stub
mAmInternal.setHasOverlayUi(msg.arg1, msg.arg2 == 1);
}
break;
case RECOMPUTE_FOCUS: {
synchronized (mWindowMap) {
updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
true /* updateInputWindows */);
}
}
break;
}
if (DEBUG_WINDOW_TRACE) {
Slog.v(TAG_WM, "handleMessage: exit");

View File

@@ -313,6 +313,25 @@ public class DisplayContentTests extends WindowTestsBase {
assertEquals(window1, sWm.mRoot.computeFocusedWindow());
}
@Test
public void testKeyguard_preventsSecondaryDisplayFocus() throws Exception {
final WindowState keyguard = createWindow(null, TYPE_STATUS_BAR,
sWm.getDefaultDisplayContentLocked(), "keyguard");
assertEquals(keyguard, sWm.mRoot.computeFocusedWindow());
// Add a window to a second display, and it should be focused
final DisplayContent dc = createNewDisplay();
final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, dc, "win");
assertEquals(win, sWm.mRoot.computeFocusedWindow());
((TestWindowManagerPolicy)sWm.mPolicy).keyguardShowingAndNotOccluded = true;
try {
assertEquals(keyguard, sWm.mRoot.computeFocusedWindow());
} finally {
((TestWindowManagerPolicy)sWm.mPolicy).keyguardShowingAndNotOccluded = false;
}
}
/**
* This tests setting the maximum ui width on a display.
*/

View File

@@ -63,6 +63,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
private static WindowManagerService sWm = null;
int rotationToReport = 0;
boolean keyguardShowingAndNotOccluded = false;
private Runnable mRunnableWhenAddingSplashScreen;
@@ -420,7 +421,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
@Override
public boolean isKeyguardLocked() {
return false;
return keyguardShowingAndNotOccluded;
}
@Override
@@ -440,7 +441,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
@Override
public boolean isKeyguardShowingAndNotOccluded() {
return false;
return keyguardShowingAndNotOccluded;
}
@Override