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
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
index e051317..583dac7 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.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 @@
private final Context mContext;
private boolean mShowing;
+ private final DisplayInfo mTmpDisplayInfo = new DisplayInfo();
private final SparseArray<Presentation> mPresentations = new SparseArray<>();
@@ -86,6 +88,22 @@
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 @@
* 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);