VROEMService Tutorials

List

Setup the Build Environment

  • Make sure Android Studio is installed.
  • Make sure to use Android API Level 23 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 VROEM library (wvr_oemlib.aar) are the bridge of communication between VIVE Wave™ Server and VROEMservice. For developers, you can reference the definition of these items in VROEM library.

Declare VROEMService

  1. Write AndroidManifest.xml

    You need to declare the action of VROEMservice in its AndroidManifest.xml, so that the VIVE Wave™ Server will find it.

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

    Note

    Make sure that there is only one VROEMService installed on your device, or the VIVE Wave™ Server might choose wrong one to use.

  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 infromation from VIVE Wave™ Server, you can customize your own features. And we implement IVROEMClient_api1 in VIVE Wave™ Server, thus they can communicate with each other.

    VROEMservice can do some environment checking when VR app is launching. And it returns the VRValidationResult to VIVE Wave™ Server. The VRValidationResult is generated after finishing whole environmental check.

    There are two situations of returning the VRValidationResult. VROEMservice may spend more time to do whole environmental check when launching first VR app. It just returns the VRValidationResult when launching VR app subsequently.

1). First VR app is launching

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

Below is the calling sequence of launching first VR app:

_images/VROEMService_FirstVRAPInit.png

2). Non-first VR app is launching

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

Below is the calling sequence of launching non-first VR app:

_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 VIVE Wave™ Server through broadcastServerReady().

VIVE Wave™ Server will stop if there is no VR APPs. Make sure that VROEMservice resets the VRValidationResult to null while VIVE Wave™ Server stops, this triggers that VROEMservice does environmental check after launching a VR APP.

Simple VROEMService

VIVE Wave™ provides a sample VROEMservice in SDK/samples/SimpleOEMService. You can reference it to add your own features. This simple OEMService has these functions:

  • Receive data and events from VIVE Wave™ Server
  • Check the environment of device and return validation result to VIVE Wave™ Server
  • Trigger recenter of controller when pressing system button of VR controller

Sample VROEMservice does environmental check when the first VR APP is launching. While doing the environmental check, the VRServerState should be VRServerState.VRServerState_CHECKING. After the environmental check is completed, VIVE Wave™ Server is running regularly so the VRServerState should be VRServerState.VRServerState_RUNNING. When VIVE Wave™ Server stops, the VRServerState should be VRServerState.VRServerState_STOP.

  • If VIVE Wave™ Server is doing the environmental check:

    Set VRServerState.VRServerState_CHECKING into VRServerState

  • If VIVE Wave™ Server is running regularly:

    Set VRServerState.VRServerState_RUNNING into VRServerState

  • If VIVE Wave™ Server is stopping:

    Set VRServerState.VRServerState_STOP into VRServerState