summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/ContextImpl.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 613e231b9ada..e3380e0bf12a 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -3144,6 +3144,14 @@ class ContextImpl extends Context {
if (mIsExplicitDeviceId) {
return;
}
+
+ if ((displayId == Display.DEFAULT_DISPLAY || displayId == Display.INVALID_DISPLAY)
+ && mDeviceId == DEVICE_ID_DEFAULT) {
+ // DEFAULT_DISPLAY & INVALID_DISPLAY are associated with default device.
+ // Return early avoiding instantiating VDM when it's not needed.
+ return;
+ }
+
VirtualDeviceManager vdm = getSystemService(VirtualDeviceManager.class);
if (vdm != null) {
int deviceId = vdm.getDeviceIdForDisplayId(displayId);