diff options
| author | 2017-03-08 18:09:35 -0800 | |
|---|---|---|
| committer | 2017-03-10 16:12:26 -0800 | |
| commit | 3a47ec2edd04546d82ba1df331c7af778858a281 (patch) | |
| tree | fec80e56639dc58eda413d0a65f3311fa37dc36b | |
| parent | 61f31c7b3a2de5b4b5acedfc5a0d0fa27a03ce69 (diff) | |
Add API to get compatibility display id
Add an API to get the compatibility display ID from CompatibilityDisplay
in the framework.
Testing Done: Compiled, built and used this API from ActivityManager and
it works.
Bug: 36071574
Change-Id: Ie4d1eb6a6befa7dbc3413519de20e2762529079d
Signed-off-by: Karthik Ravi Shankar <karthikrs@google.com>
4 files changed, 54 insertions, 4 deletions
diff --git a/core/java/android/service/vr/IVrManager.aidl b/core/java/android/service/vr/IVrManager.aidl index 10e417784700..6034c1820972 100644 --- a/core/java/android/service/vr/IVrManager.aidl +++ b/core/java/android/service/vr/IVrManager.aidl @@ -50,5 +50,13 @@ interface IVrManager { * @param enabled true if the device should be placed in persistent VR mode. */ void setPersistentVrModeEnabled(in boolean enabled); + + /** + * Return current virtual display id. + * + * @return {@link android.view.Display.INVALID_DISPLAY} if there is no virtual display + * currently, else return the display id of the virtual display + */ + int getCompatibilityDisplayId(); } diff --git a/services/core/java/com/android/server/vr/CompatibilityDisplay.java b/services/core/java/com/android/server/vr/CompatibilityDisplay.java index 5e17daa0f153..8f95cc74c914 100644 --- a/services/core/java/com/android/server/vr/CompatibilityDisplay.java +++ b/services/core/java/com/android/server/vr/CompatibilityDisplay.java @@ -1,6 +1,8 @@ package com.android.server.vr; +import static android.view.Display.INVALID_DISPLAY; + import android.app.Service; import android.content.BroadcastReceiver; import android.content.Context; @@ -86,10 +88,8 @@ class CompatibilityDisplay { startVirtualDisplay(); } } else { - // TODO: Remove conditional when launching apps 2D doesn't force VrMode to stop. - if (!DEBUG) { - stopVirtualDisplay(); - } + // Stop virtual display to test exit condition + stopVirtualDisplay(); } } @@ -138,6 +138,19 @@ class CompatibilityDisplay { } } + public int getVirtualDisplayId() { + synchronized(vdLock) { + if (mVirtualDisplay != null) { + int virtualDisplayId = mVirtualDisplay.getDisplay().getDisplayId(); + if (DEBUG) { + Log.e(TAG, "VD id: " + virtualDisplayId); + } + return virtualDisplayId; + } + } + return INVALID_DISPLAY; + } + private void startVirtualDisplay() { if (DEBUG) { Log.d(TAG, "Request to start VD, DM:" + mDisplayManager); diff --git a/services/core/java/com/android/server/vr/VrManagerInternal.java b/services/core/java/com/android/server/vr/VrManagerInternal.java index 58e4bdc36e6a..210aa44c0c03 100644 --- a/services/core/java/com/android/server/vr/VrManagerInternal.java +++ b/services/core/java/com/android/server/vr/VrManagerInternal.java @@ -90,6 +90,15 @@ public abstract class VrManagerInternal { public abstract void setPersistentVrModeEnabled(boolean enabled); /** + * Return {@link android.view.Display.INVALID_DISPLAY} if there exists no virtual display + * currently or the display id of the current virtual display. + * + * @return {@link android.view.Display.INVALID_DISPLAY} if there is no virtual display + * currently, else return the display id of the virtual display + */ + public abstract int getCompatibilityDisplayId(); + + /** * Adds listener that reports state changes to persistent VR mode. */ public abstract void addPersistentVrModeStateListener(PersistentVrStateListener listener); diff --git a/services/core/java/com/android/server/vr/VrManagerService.java b/services/core/java/com/android/server/vr/VrManagerService.java index 8a23173ca208..a00115cba2a2 100644 --- a/services/core/java/com/android/server/vr/VrManagerService.java +++ b/services/core/java/com/android/server/vr/VrManagerService.java @@ -15,6 +15,8 @@ */ package com.android.server.vr; +import static android.view.Display.INVALID_DISPLAY; + import android.Manifest; import android.app.ActivityManager; import android.app.AppOpsManager; @@ -392,6 +394,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC } @Override + public int getCompatibilityDisplayId() { + return VrManagerService.this.getCompatibilityDisplayId(); + } + + @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) { @@ -495,6 +502,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC } @Override + public int getCompatibilityDisplayId() { + return VrManagerService.this.getCompatibilityDisplayId(); + } + + @Override public void addPersistentVrModeStateListener(PersistentVrStateListener listener) { VrManagerService.this.addPersistentVrModeStateListener(listener); } @@ -1054,6 +1066,14 @@ public class VrManagerService extends SystemService implements EnabledComponentC } } + private int getCompatibilityDisplayId() { + if (mCompatibilityDisplay != null) { + return mCompatibilityDisplay.getVirtualDisplayId(); + } + Slog.w(TAG, "CompatibilityDisplay is null!"); + return INVALID_DISPLAY; + } + private void setPersistentModeAndNotifyListenersLocked(boolean enabled) { if (mPersistentVrModeEnabled == enabled) { return; |