From ac272d5e9f4b84e19fb83ff1bf8964e688f1c6b9 Mon Sep 17 00:00:00 2001 From: Linus Tufvesson Date: Mon, 30 Mar 2020 18:55:04 +0100 Subject: [PATCH] Use TYPE_PRIVATE_PRESENTATION for private presentations Detect if the Presenation is targeting a private virtual display, and if they are use the windowType TYPE_PRIVATE_PRESENTATION. Bug: 152652348 Bug: 141745510 Test: atest CtsWindowManagerDeviceTestCases:PresentationTest Test: atest CtsDisplayTestCases:android.display.cts.VirtualDisplayTest Change-Id: I58834636e092f992e403342e36b475dc60e8f20a --- core/java/android/app/Presentation.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/java/android/app/Presentation.java b/core/java/android/app/Presentation.java index eaee0602f4b72..7a18b8120d7ec 100644 --- a/core/java/android/app/Presentation.java +++ b/core/java/android/app/Presentation.java @@ -19,6 +19,7 @@ package android.app; import static android.content.Context.DISPLAY_SERVICE; import static android.content.Context.WINDOW_SERVICE; import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION; +import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; @@ -191,12 +192,16 @@ public class Presentation extends Dialog { mDisplay = display; mDisplayManager = (DisplayManager)getContext().getSystemService(DISPLAY_SERVICE); + final int windowType = + (display.getFlags() & Display.FLAG_PRIVATE) != 0 ? TYPE_PRIVATE_PRESENTATION + : TYPE_PRESENTATION; + final Window w = getWindow(); final WindowManager.LayoutParams attr = w.getAttributes(); attr.token = mToken; w.setAttributes(attr); w.setGravity(Gravity.FILL); - w.setType(TYPE_PRESENTATION); + w.setType(windowType); setCanceledOnTouchOutside(false); }