Requires WMPF >= 2.1.0. It is recommended to read the Notes before use.
Unless otherwise specified, all other APIs can only be used after this API is successfully called. Retry if it fails.
Used to activate the device. The device activation status may expire. It is recommended to use registerDeviceActivationOutdatedEventListener to monitor the status and reactivate if necessary.
-
Note 1: For the same device, the hostAppId, productId, keyVersion, and deviceId passed to WMPFBoot.init should remain unchanged in the production environment. If these parameters change during development and debugging compared to the last activation, a DEVICE_CHANGED error will occur, and you need to manually clear the application data of the WMPF Service Apk.
-
Note 2: Starting from WMPF-cli 2.2, automatic activation is supported. In most cases, developers no longer need to explicitly call activateDevice. However, there are exceptions:
- If you want to verify the device activation status in advance, you can still call activateDevice directly.
- When registerDeviceActivationOutdatedEventListener detects that the device activation status has expired, you can reactivate when necessary (for example, during network switching).
Call Parameters
None
Return Parameters
None
Sample Code
val deviceApi = WMPF.getInstance().getDeviceApi()
deviceApi.activateDevice()
Lifecycle
After a WMPF process restart, this function should be called again to ensure the retention of wmpf-cli interface invocation permissions.
For the In-Vehicle WMPF:
- When WMPF attempts self-activation, it sends the broadcast
com.tencent.wmpf.ACTION_ACTIVATE_DEVICE; - After self-activation, WMPF notifies the client that WMPF activation is complete using the following methods. At this point, the wmpf-cli used for activation-free purposes can independently call the
activateDeviceinterface to activate.- Notify WMPF that device activation has been completed via ContentProvider insert
content://com.tencent.wmpf.cli.provider/deviceActivated(see WMPFClientProvider.setDeviceActivatedDelegate). - Send the broadcast
com.tencent.wmpf.ACTION_DEVICE_ACTIVATED(without setting the package name; for Android 8.0 and above, the first method is recommended).
- Notify WMPF that device activation has been completed via ContentProvider insert
Common Errors
package is not trusted- For in-vehicle systems with PAL that have integrated Tencent CarLink, the integrator should use the activation-free method to access wmpf-cli. In this case, the application package name for wmpf-cli must be added to the Tencent side to enable activation-free usage.
- For other scenarios, do not use the activation-free method to access wmpf-cli. Ensure that the
WMPFBoot.init(applicationContext, WMPFDevice)interface is used and that theWMPFDeviceinterface parameter passed is correct.
signature errindicates that the parameters found in the signature by the backend do not match the parameters passed to this interface. If the signature is verified to be correct, it is recommended to check the following:- Confirm that WMPF has been upgraded to v1.1.5 or higher;
- Confirm that the
productId,deviceId, and key version (keyVersion) used when generating the signature are consistent with the parameters passed toWMPFBoot.init. - When generating signatures in the developer backend, the recommended openssl version for the signature generation environment is 1.1.1. It has been confirmed that versions 1.0.x and 3.0.x have issues; developers can try other versions on their own.
- A successful signature verification only indicates that the parameters included in the signature match the parameters provided during verification; it does not guarantee that
activateDevicewill not throw an error.