1 package android.app;
2 
3 
4 import android.annotation.RequiresPermission;
5 import android.annotation.SystemApi;
6 import android.annotation.SystemService;
7 import android.content.ComponentName;
8 import android.content.Context;
9 import android.os.RemoteException;
10 import android.service.vr.IVrManager;
11 
12 /**
13  * Used to control aspects of a devices Virtual Reality (VR) capabilities.
14  * @hide
15  */
16 @SystemApi
17 @SystemService(Context.VR_SERVICE)
18 public class VrManager {
19     private final IVrManager mService;
20 
21     /**
22      * {@hide}
23      */
VrManager(IVrManager service)24     public VrManager(IVrManager service) {
25         mService = service;
26     }
27 
28     /**
29      * Sets the persistent VR mode state of a device. When a device is in persistent VR mode it will
30      * remain in VR mode even if the foreground does not specify Vr mode being enabled. Mainly used
31      * by VR viewers to indicate that a device is placed in a VR viewer.
32      *
33      * @see Activity#setVrModeEnabled(boolean, ComponentName)
34      * @param enabled true if the device should be placed in persistent VR mode.
35      */
36     @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
setPersistentVrModeEnabled(boolean enabled)37     public void setPersistentVrModeEnabled(boolean enabled) {
38         try {
39             mService.setPersistentVrModeEnabled(enabled);
40         } catch (RemoteException e) {
41             e.rethrowFromSystemServer();
42         }
43     }
44 
45     /**
46      * Sets the resolution and DPI of the vr2d virtual display used to display 2D
47      * applications in VR mode.
48      *
49      * @param vr2dDisplayProp properties to be set to the virtual display for
50      * 2D applications in VR mode.
51      *
52      * {@hide}
53      */
54     @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
setVr2dDisplayProperties( Vr2dDisplayProperties vr2dDisplayProp)55     public void setVr2dDisplayProperties(
56             Vr2dDisplayProperties vr2dDisplayProp) {
57         try {
58             mService.setVr2dDisplayProperties(vr2dDisplayProp);
59         } catch (RemoteException e) {
60             e.rethrowFromSystemServer();
61         }
62     }
63 }
64