diff options
| author | 2017-10-04 17:30:30 -0700 | |
|---|---|---|
| committer | 2017-10-04 17:50:23 -0700 | |
| commit | 1e90fc38dbf92d4204a4bfc242d53e38ed9d4a4d (patch) | |
| tree | eb1428aed77e56c5240e8fc3ab897f078e1a910d | |
| parent | 94e07022c2514e6b13311c5c8dcf3b4a3514aada (diff) | |
Add a flag to virtual display to indicates that content on this
display need to be destroyed once the display is removed.
Then apply this flag to VR virtual display.
Change-Id: Icb5aa1280b6ebac5941afda1cc1b94b258ce44f4
Bug: 67420451
Test: Manually. "adb shell am stack list" does not show contents
from virtual display anymore after it's released.
5 files changed, 24 insertions, 0 deletions
diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java index 6fbacaf32fd6..ae4f05a2ef94 100644 --- a/core/java/android/hardware/display/DisplayManager.java +++ b/core/java/android/hardware/display/DisplayManager.java @@ -278,6 +278,15 @@ public final class DisplayManager { */ public static final int VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT = 1 << 7; + /** + * Virtual display flag: Indicates that the contents will be destroyed once + * the display is removed. + * + * @see #createVirtualDisplay + * @hide + */ + public static final int VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL = 1 << 8; + /** @hide */ public DisplayManager(Context context) { mContext = context; diff --git a/services/core/java/com/android/server/display/DisplayDeviceInfo.java b/services/core/java/com/android/server/display/DisplayDeviceInfo.java index ef6de4c1ee51..fddb81ba2af7 100644 --- a/services/core/java/com/android/server/display/DisplayDeviceInfo.java +++ b/services/core/java/com/android/server/display/DisplayDeviceInfo.java @@ -98,6 +98,12 @@ final class DisplayDeviceInfo { public static final int FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD = 1 << 9; /** + * Flag: This display will destroy its content on removal. + * @hide + */ + public static final int FLAG_DESTROY_CONTENT_ON_REMOVAL = 1 << 10; + + /** * Touch attachment: Display does not receive touch. */ public static final int TOUCH_NONE = 0; diff --git a/services/core/java/com/android/server/display/LogicalDisplay.java b/services/core/java/com/android/server/display/LogicalDisplay.java index addad0b413a3..78a540790db6 100644 --- a/services/core/java/com/android/server/display/LogicalDisplay.java +++ b/services/core/java/com/android/server/display/LogicalDisplay.java @@ -238,6 +238,9 @@ final class LogicalDisplay { // For private displays by default content is destroyed on removal. mBaseDisplayInfo.removeMode = Display.REMOVE_MODE_DESTROY_CONTENT; } + if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_DESTROY_CONTENT_ON_REMOVAL) != 0) { + mBaseDisplayInfo.removeMode = Display.REMOVE_MODE_DESTROY_CONTENT; + } if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_PRESENTATION) != 0) { mBaseDisplayInfo.flags |= Display.FLAG_PRESENTATION; } diff --git a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java index d6ab88813f4d..f86d57634bff 100644 --- a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java +++ b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java @@ -24,6 +24,8 @@ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLI import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE; import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH; import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT; +import static android.hardware.display.DisplayManager + .VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL; import android.content.Context; import android.hardware.display.IVirtualDisplayCallback; @@ -363,6 +365,9 @@ public class VirtualDisplayAdapter extends DisplayAdapter { if ((mFlags & VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT) != 0) { mInfo.flags |= DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT; } + if ((mFlags & VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL) != 0) { + mInfo.flags |= DisplayDeviceInfo.FLAG_DESTROY_CONTENT_ON_REMOVAL; + } mInfo.type = Display.TYPE_VIRTUAL; mInfo.touch = ((mFlags & VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH) == 0) ? diff --git a/services/core/java/com/android/server/vr/Vr2dDisplay.java b/services/core/java/com/android/server/vr/Vr2dDisplay.java index 5721415c55f5..95d03d4bda49 100644 --- a/services/core/java/com/android/server/vr/Vr2dDisplay.java +++ b/services/core/java/com/android/server/vr/Vr2dDisplay.java @@ -296,6 +296,7 @@ class Vr2dDisplay { flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT; flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC; flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY; + flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL; mVirtualDisplay = mDisplayManager.createVirtualDisplay(null /* projection */, DISPLAY_NAME, mVirtualDisplayWidth, mVirtualDisplayHeight, mVirtualDisplayDpi, null /* surface */, flags, null /* callback */, null /* handler */, |