# Device Certification SDK (Android)

Note: License billing no longer supports devices certified using the Device Authentication SDK. Switch to as soon as possible. Use the WMPF to authenticate devices without maintaining the deviceToken, making access easier.

After integrating rpmbd, developers need to access the device authentication SDK in the Launcher application, which mainly provides the following capabilities:

  • Register deviceregisterDevice: Bind model_id and SN to the device.Once successful** model_id and SN cannot be modified **。
  • Get device credentialsgetDeviceToken:Device authentication is performed and credentials are obtained from the WeChat background, and the vopToken parameter of the [initByCaller]]](./voip-plugin/api/initByCaller.md) interface of the VOIP call plug-in is passed to the [interface when the call is initiated on the device.

# 1. Download the SDK

Download the aar file for the SDK at here .

It is recommended to use version 1.3 and above (IoT cards should use version 1.3.1 and above).Earlier versions do not support concurrent calls toregisterVoipDevice, so be careful not to repeat calls until the previous call returns.

  • V1.5.0 and above require integration ofvoipsdk-x.x-release.aarandsafeguard-release.aarTwo aar documents
  • V1.3.1 and below simply integratevoipsdk-x.x-release.aar

Note: Before using the device authentication SDK, you need to ensure that the rmpbd service is running properly.

# 2. Interface documentation (v1.5.0 and above)

# 2.1 Register deviceregisterDevice

Bind model_id and SN to the device. Once successful, AppID, model_id and SN cannot be replaced.

int registerDevice(String appid, String model_id, String sn, String sn_ticket) throws Exception

# Notes ( Read before calling )

  • Once the device is successfully registered, the SN is solidified into the EMMC / RPMB partition to identify the unique identity of the device.** SN and model_id are unchangeable once written .**
  • The SN used here must be registered as a deviceId through the WMPF addDevice interface and consistent with the deviceId used for WMPF device activation . Otherwise, the subsequent call cannot be initiated normally.
  • If the APK changes (the Android system thinks the application has changed), the certificate will be invalid (an error will be reported).cert fail),You can clean up the APK data and reapply it with the same , model_id, SN calling interfaces.
  • There will be network requests for the registration process, and the duration will vary depending on network conditions. Higher versions of Android do not allow network requests in the main thread, you can add processing or call the SDK in the thread.

# Parameter explaination

parameter type Introductions
appid String Weixin Mini Program of AppID
model_id String The model_id obtained from the "Weixin Mini Program administrative background" request when the device accesses
sn String The device serial number. Created by the vendor itself, the length cannot exceed 128 bytes. Characters only accept numbers, uppercase and lowercase letters, underlined (*), and hyphens (-).

The sn used here must be the same as the deviceId used by the WMPF activated device
sn_ticket String Access to the device ticket interface

# Return value

For other exceptions, please refer to Device Validation Common Problems

name value describe
OK 0 success
ERR_ARGS -1 Parameter Error
ERR_IO -2 General IO Error
ERR_KEY_IO -3 The KEY does not match.
ERR_RESPONSE -4 No response to network requests
ERR_PEM -5 Permission error
ERR_INVALID_KEY -6 KEY NOT AVAILABLE
ERR_SERVICE -7 The rpmbd service is not running
ERR_EMMC_UFS_CONFUSED -8 EMMC / UFS does not match. SN is already in there.
ERR_EMMC_UFS_IO -9 EMMC / UFSIO Error
ERR_REG_NOPEM -10 The key does not exist

# 2.2 Get device credentialsgetDeviceToken

Perform device authentication and obtain device credentials from the WeChat background.When the device initiates a call, it needs to pass this certificate to the voipToken parameter of the initByCaller interface of the VOIP call plug-in.

String getDeviceToken(String appid, String model_id) throws Exception

If the device is registered with the SDK v1.5 and above, you can use the no-parameter version.

String getDeviceToken() throws Exception

# Parameter explaination

parameter type Introductions
appid String Weixin Mini Program of AppID
model_id String The model_id obtained from the "Weixin Mini Program administrative background" request when the device accesses

# Note

  • Interface time is related to the network and normally will be around 1 second. Higher versions of Android do not allow to do in the main thread, you can add processing or in the thread to call the SDK.
  • The ticket has an hour validity and can be multiplexed by multiple calls within an hour. It is recommended that developers call getCallerTicket and cache it in advance before the user initiates the call to avoid getting it when the call is initiated, so as to shorten the user's waiting time when the call is initiated.

# 2.3 Get device SNgetDeviceSn(debugging only)

Gets the SN written by theregisterDeviceinterface.

String getDeviceSn()

# 2.4 Get device modelIdgetDeviceModelid(debugging only)

Gets the modelId written using theregisterDeviceinterface.Valid only if the device is registered with the SDK v1.5 and above.

String getDeviceModelid()

# 3. Interface documentation (v1.3.1 and below)

# 3.1 Initializationinit

The SDK is early, and other interfaces need to ensure that init succeeds before they are invoked.

boolean init()

# 3.2 Register deviceregisterVoipDevice

Reference 2.1registerDevice.

  • ** 1.3 With the following SDK, concurrent execution of this interface is strictly prohibited **, be sure to logically guarantee once the registerVoipDevice returns before calling again.

# 3.3getCallerTicket

Reference 2.2getDeviceToken

# 3.4 Get Device SNGetDeviceSn(debugging only)

getDeviceSn