VROEMService Tutorials

List

Set Up the Build Environment

  • Make sure Android Studio is installed.
  • Make sure to use Android API Level 26 or later.
  • Download and import the VIVE Wave™ VROEMservice (wvr_oemlib.aar).
  • Add the required libraries in build.gradle.

VROEM Library Reference

The interfaces and classes in the VROEM library (wvr_oemlib.aar) act as a communication bridge between the VIVE Wave™ Server and VROEMservice. Click the items below to reference their definitions in the VROEM library.

Declare VROEMService

  1. Write AndroidManifest.xml

    You need to declare the action of VROEMservice in its AndroidManifest.xml for the VIVE Wave™ Server to find it.

    <intent-filter>
        <action android:name="vive.wave.action.VROEMSERVICE" />
    </intent-filter>
    

    Note

    Make sure that there is only one VROEMservice installed on your device.

  2. Implement : IVROEMService

    Write an Android service and extend IVROEMService.

    • onBind: must return the IBinder of IVROEMService.
    • getMinApiVersion
    • getMaxApiVersion
    • getApi: must return the IBinder of IVROEMService_api1
    private VROEMService_api1 mServiceApi1;
    
    private final IVROEMService.Stub mBinder = new IVROEMService.Stub() {
        @Override
        public int getMinApiVersion() throws RemoteException {
            return 1;
        }
    
        @Override
        public int getMaxApiVersion() throws RemoteException {
            return 1;
        }
    
        @Override
        public IBinder getApi(int version) throws RemoteException {
            switch (version) {
                case 1:
                    return mServiceApi1;
            }
            return null;
        }
    };
    
    @Override
    public IBinder onBind(Intent intent) {
        Log.d(TAG,"onBind");
        return mBinder;
    }
    
  3. Implement: IVROEMService_api1

    This is the core of VROEMservice. It receives events and gets information from the VIVE Wave™ Server and can be customized for your own features. We’ve also implemented IVROEMClient_api1 in the VIVE Wave™ Server so that they can communicate with each other.

    VROEMservice can check the environment when a VR app is launching, and it returns the VRValidationResult to the VIVE Wave™ Server. The VRValidationResult is generated after the whole environmental check is finished.

    There are two situations for returning the VRValidationResult. VROEMservice may spend more time to do a whole environmental check when the first VR app is launched. It just returns the VRValidationResult when subsequent VR apps are launched.

1). First VR app is launched.

VROEMservice does a complete environment check and it may spend more time. VROEMservice returns the result to VIVE Wave™ Server through broadcastServerReady().

Calling sequence of when first VR app is launched:

_images/VROEMService_FirstVRAPInit.png

2). Subsequent VR app is launched:

When subsequent VR apps are launching, VROEMservice returns the VRValidationResult that is generated by launching the first VR app.

Calling sequence of when a subsequent VR app is launched:

_images/VROEMService_NonFirstVRAPInit.png

The VRValidationResult is used to record the environmental check when the system launches the first VR app. While an app is launched, checkValidation() is used to check VRValidationResult.

If VRValidationResult does not exist, VROEMservice does the whole environmental check and then returns the result to the VIVE Wave™ Server through broadcastServerReady().

VIVE Wave™ Server will stop if there are no VR apps running. Make sure that VROEMservice resets the VRValidationResult to null when the VIVE Wave™ Server stops. This will trigger the VROEMservice to do an environmental check when a VR app is launched.

Sample VROEMService

VIVE Wave™ provides a VROEMservice sample in SDK/samples/wvr_simple_oemservice. This sample has the following functions:

  • Receive data and events from the VIVE Wave™ Server
  • Check the device environment and return the validation result to the VIVE Wave™ Server.
  • Recenter the controller when long pressing the System button of the controller.
  • Display the OverlayService sample when pressing the Menu button of the controller.

Note

You can add custom features to the VROEMservice sample.

The VROEMservice sample does an environmental check when the first VR app is launched.

  • When the VIVE Wave™ Server is doing the environmental check, set VRServerState to VRServerState.VRServerState_CHECKING.
  • When the VIVE Wave™ Server is running normally, set VRServerState to VRServerState.VRServerState_RUNNING.
  • When the VIVE Wave™ Server stops, set VRServerState to VRServerState.VRServerState_STOP.