Loading core/java/android/service/vr/IVrManager.aidl +8 −0 Original line number Original line Diff line number Diff line Loading @@ -50,5 +50,13 @@ interface IVrManager { * @param enabled true if the device should be placed in persistent VR mode. * @param enabled true if the device should be placed in persistent VR mode. */ */ void setPersistentVrModeEnabled(in boolean enabled); 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(); } } services/core/java/com/android/server/vr/CompatibilityDisplay.java +17 −4 Original line number Original line Diff line number Diff line package com.android.server.vr; package com.android.server.vr; import static android.view.Display.INVALID_DISPLAY; import android.app.Service; import android.app.Service; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Context; Loading Loading @@ -86,12 +88,10 @@ class CompatibilityDisplay { startVirtualDisplay(); startVirtualDisplay(); } } } else { } else { // TODO: Remove conditional when launching apps 2D doesn't force VrMode to stop. // Stop virtual display to test exit condition if (!DEBUG) { stopVirtualDisplay(); stopVirtualDisplay(); } } } } } private void startDebugOnlyBroadcastReceiver(Context context) { private void startDebugOnlyBroadcastReceiver(Context context) { if (DEBUG) { if (DEBUG) { Loading Loading @@ -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() { private void startVirtualDisplay() { if (DEBUG) { if (DEBUG) { Log.d(TAG, "Request to start VD, DM:" + mDisplayManager); Log.d(TAG, "Request to start VD, DM:" + mDisplayManager); Loading services/core/java/com/android/server/vr/VrManagerInternal.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -89,6 +89,15 @@ public abstract class VrManagerInternal { */ */ public abstract void setPersistentVrModeEnabled(boolean enabled); 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. * Adds listener that reports state changes to persistent VR mode. */ */ Loading services/core/java/com/android/server/vr/VrManagerService.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ */ package com.android.server.vr; package com.android.server.vr; import static android.view.Display.INVALID_DISPLAY; import android.Manifest; import android.Manifest; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.AppOpsManager; import android.app.AppOpsManager; Loading Loading @@ -391,6 +393,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC VrManagerService.this.setPersistentVrModeEnabled(enabled); VrManagerService.this.setPersistentVrModeEnabled(enabled); } } @Override public int getCompatibilityDisplayId() { return VrManagerService.this.getCompatibilityDisplayId(); } @Override @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP) if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP) Loading Loading @@ -494,6 +501,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC VrManagerService.this.setPersistentVrModeEnabled(enabled); VrManagerService.this.setPersistentVrModeEnabled(enabled); } } @Override public int getCompatibilityDisplayId() { return VrManagerService.this.getCompatibilityDisplayId(); } @Override @Override public void addPersistentVrModeStateListener(PersistentVrStateListener listener) { public void addPersistentVrModeStateListener(PersistentVrStateListener listener) { VrManagerService.this.addPersistentVrModeStateListener(listener); VrManagerService.this.addPersistentVrModeStateListener(listener); Loading Loading @@ -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) { private void setPersistentModeAndNotifyListenersLocked(boolean enabled) { if (mPersistentVrModeEnabled == enabled) { if (mPersistentVrModeEnabled == enabled) { return; return; Loading Loading
core/java/android/service/vr/IVrManager.aidl +8 −0 Original line number Original line Diff line number Diff line Loading @@ -50,5 +50,13 @@ interface IVrManager { * @param enabled true if the device should be placed in persistent VR mode. * @param enabled true if the device should be placed in persistent VR mode. */ */ void setPersistentVrModeEnabled(in boolean enabled); 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(); } }
services/core/java/com/android/server/vr/CompatibilityDisplay.java +17 −4 Original line number Original line Diff line number Diff line package com.android.server.vr; package com.android.server.vr; import static android.view.Display.INVALID_DISPLAY; import android.app.Service; import android.app.Service; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Context; Loading Loading @@ -86,12 +88,10 @@ class CompatibilityDisplay { startVirtualDisplay(); startVirtualDisplay(); } } } else { } else { // TODO: Remove conditional when launching apps 2D doesn't force VrMode to stop. // Stop virtual display to test exit condition if (!DEBUG) { stopVirtualDisplay(); stopVirtualDisplay(); } } } } } private void startDebugOnlyBroadcastReceiver(Context context) { private void startDebugOnlyBroadcastReceiver(Context context) { if (DEBUG) { if (DEBUG) { Loading Loading @@ -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() { private void startVirtualDisplay() { if (DEBUG) { if (DEBUG) { Log.d(TAG, "Request to start VD, DM:" + mDisplayManager); Log.d(TAG, "Request to start VD, DM:" + mDisplayManager); Loading
services/core/java/com/android/server/vr/VrManagerInternal.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -89,6 +89,15 @@ public abstract class VrManagerInternal { */ */ public abstract void setPersistentVrModeEnabled(boolean enabled); 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. * Adds listener that reports state changes to persistent VR mode. */ */ Loading
services/core/java/com/android/server/vr/VrManagerService.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ */ package com.android.server.vr; package com.android.server.vr; import static android.view.Display.INVALID_DISPLAY; import android.Manifest; import android.Manifest; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.AppOpsManager; import android.app.AppOpsManager; Loading Loading @@ -391,6 +393,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC VrManagerService.this.setPersistentVrModeEnabled(enabled); VrManagerService.this.setPersistentVrModeEnabled(enabled); } } @Override public int getCompatibilityDisplayId() { return VrManagerService.this.getCompatibilityDisplayId(); } @Override @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP) if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP) Loading Loading @@ -494,6 +501,11 @@ public class VrManagerService extends SystemService implements EnabledComponentC VrManagerService.this.setPersistentVrModeEnabled(enabled); VrManagerService.this.setPersistentVrModeEnabled(enabled); } } @Override public int getCompatibilityDisplayId() { return VrManagerService.this.getCompatibilityDisplayId(); } @Override @Override public void addPersistentVrModeStateListener(PersistentVrStateListener listener) { public void addPersistentVrModeStateListener(PersistentVrStateListener listener) { VrManagerService.this.addPersistentVrModeStateListener(listener); VrManagerService.this.addPersistentVrModeStateListener(listener); Loading Loading @@ -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) { private void setPersistentModeAndNotifyListenersLocked(boolean enabled) { if (mPersistentVrModeEnabled == enabled) { if (mPersistentVrModeEnabled == enabled) { return; return; Loading