[Huawei Developers] Martin Bieber:
1.Device Selection Dialog Box

Any app that uses the HUAWEI DeviceVirtualization Engine must display the following dialog box for users to select capable devices to complete capability continuation.

The design of this dialog box must follow the HUAWEI DeviceVirtualization Engine Third-Party App UX Design Specifications, and DV Engine Icon Resources should be used.

2. Device Compatibility

Currently, DeviceVirtualization Engine supports only Huawei mobile phones. When an app invokes the APIs in DV Engine in an unsupported running environment, or on a Huawei phone running an unsupported EMUI version, the system throws NoClassDefFoundError.

Therefore, apps should check compatibility between the running environment and DV Engine version.

In the following example, CURRENT_KIT_VERSION is the HUAWEI DV Engine version that the app is compatible with. The app needs to record the version, and check whether the DV Engine version on the current mobile phone is the same as the DV Engine version that the app is compatible with. If not, compatibility processing is required.

boolean isSupport = true;

try {

// Obtain the running version of DV Kit.

String version = DvKit.getVersion();

if (version.compareTo(CURRENT_KIT_VERSION) < 0) {

// The current DV Kit version does not meet the app running requirements.

isSupport = false;

}

} catch (NoClassDefFoundError e) {

// The current running environment does not support the DV Kit.

isSupport = false;

Log.e(TAG, "DvKit not exist", e);

}

if (isSupport) {

// The current DV Kit version meets the app running requirements.

Intent intent = new Intent(MainActivity.this, DvKitDemoActivity.class);

startActivity(intent);

}

3.Development Process

To use the DV Engine service, you need to declare the permission to use virtual peripherals and the permission required for the app to invoke the corresponding API of the DV Engine service, such as the camera permission, audio permission, and body sensor permission.

When using the DV Engine capabilities, an app needs to apply for different Android permissions accordingly. These permissions need to be declared in the app code. The Android permissions corresponding to different DV Engine capabilities are as follows:

1. Virtual camera permission of DV Engine, which is mandatory for using camera capabilities.

android.permission.CAMERA

2. Virtual microphone permission of DV Engine, which is mandatory for using microphone capabilities.

android.permission.RECORD_AUDIO

3.Virtual sensor permission of DV Engine, which is mandatory for using sensor capabilities. The virtual sensors include body_sensor's heart rate monitor, accelerometer, barometer, and gyroscope.

android.permission.BODY_SENSORS

4. Virtual vibrator permission of DV Engine, which is mandatory for using vibrator capabilities.

android.permission.VIBRATE

5. Virtual device permission of DV Engine, which is mandatory for using the distributed virtual devices.

com.huawei.permission.DISTRIBUTED_VIRTUALDEVICE

This permission must be obtained before DV Engine is connected. Otherwise, the distributed virtualization capability cannot be used. You can call the requestPermissions method of Android to dynamically apply for the permission where appropriate in the process, based on the service.

Example:

To use the DV Engine service, you need to declare the permissions to use the camera, audio, and distributed virtual peripherals.

<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="com.huawei.permission.DISTRIBUTED_VIRTUALDEVICE"/>

The basic method is to create a basic DV Engine object, connect the object to the back-end service for initialization, and obtain the VirtualDeviceManager service through the object.

The VirtualDeviceManager service can be used to discover virtualized devices controllable from phones, together with their capabilities, which can be developed to meet service needs.

For example, when the VirtualDeviceManager service detects a TV and returns the display, microphone, speaker, and camera capabilities supported by the TV, the app can then enable the corresponding capabilities as required.