diff options
author | wilsonshih <wilsonshih@google.com> | 2018-12-06 12:52:31 +0800 |
---|---|---|
committer | wilsonshih <wilsonshih@google.com> | 2018-12-06 14:34:29 +0800 |
commit | b5d1ab9320285f9504d83d7536b642685574963d (patch) | |
tree | 1ba8293a29ef8827a451fb392d63584aca67d9e1 /packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java | |
parent | d830ca25a19239709b7c644204baeb64d2785080 (diff) |
Prevent Keyguard dialog from showing on private displays.
Add an explicit check if the display is private.
Also add some debug log.
Bug: 113840485
Test: atest ActivityManagerDisplayKeyguardTests
Test: atest SystemUITests
Change-Id: I72898555730e93e0c64f78f205a23977feb9a513
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java index e051317b96b6..583dac7996ae 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java @@ -28,6 +28,7 @@ import android.os.Bundle; import android.util.Log; import android.util.SparseArray; import android.view.Display; +import android.view.DisplayInfo; import android.view.View; import android.view.WindowManager; @@ -45,6 +46,7 @@ public class KeyguardDisplayManager { private final Context mContext; private boolean mShowing; + private final DisplayInfo mTmpDisplayInfo = new DisplayInfo(); private final SparseArray<Presentation> mPresentations = new SparseArray<>(); @@ -86,6 +88,22 @@ public class KeyguardDisplayManager { mDisplayService.registerDisplayListener(mDisplayListener, null /* handler */); } + private boolean isKeyguardShowable(Display display) { + if (display == null) { + if (DEBUG) Log.i(TAG, "Cannot show Keyguard on null display"); + return false; + } + if (display.getDisplayId() == DEFAULT_DISPLAY) { + if (DEBUG) Log.i(TAG, "Do not show KeyguardPresentation on the default display"); + return false; + } + display.getDisplayInfo(mTmpDisplayInfo); + if ((mTmpDisplayInfo.flags & Display.FLAG_PRIVATE) != 0) { + if (DEBUG) Log.i(TAG, "Do not show KeyguardPresentation on a private display"); + return false; + } + return true; + } /** * @param display The display to show the presentation on. * @return {@code true} if a presentation was added. @@ -93,7 +111,7 @@ public class KeyguardDisplayManager { * was already there. */ private boolean showPresentation(Display display) { - if (display == null || display.getDisplayId() == DEFAULT_DISPLAY) return false; + if (!isKeyguardShowable(display)) return false; if (DEBUG) Log.i(TAG, "Keyguard enabled on display: " + display); final int displayId = display.getDisplayId(); Presentation presentation = mPresentations.get(displayId); |