OTA UI BizBundle

Last Updated on : 2024-04-01 06:18:21download

An over-the-air (OTA) update enables automatic firmware download and updates over the network. OTA UI BizBundle helps you quickly integrate with firmware update capabilities.

Integrate with the UI BizBundle

Create a project

Integrate Smart Life App SDK for Android into your project with Android Studio and add the framework of the UI BizBundle to your project.

If you have integrated with the UI BizBundle v3.22.0, your project must depend on the Smart Life App SDK of the same version as the UI BizBundle.

Configure build.gradle of module


dependencies {
    api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:${biz_bom_version}")
    implementation 'com.thingclips.smart:thingsmart-bizbundle-ota'
    api "com.thingclips.smart:thingsmart:${sdk_version}}"
}

Implement features

Check support for firmware updates

Checks whether the current device supports OTA firmware updates.

API description

boolean isSupportUpgrade(String devId);

Parameters

Parameter Description
devId The device ID.

Example

AbsOtaCallerService absOtaCallerService = MicroContext.getServiceManager().findServiceByInterface(AbsOtaCallerService.class.getName());
		if (absOtaCallerService != null) {
			if (absOtaCallerService.isSupportUpgrade(devId)) {
				// support ota
			} else {
				// can not support ota ability
			}
		}

Access the firmware update page

Navigates to the firmware update page and starts the update if this feature is supported.

API description

void goFirmwareUpgrade(Context context, String devId);

Parameters

Parameter Description
context The context object of the firmware update activity.
devId The device ID.

Example

AbsOtaCallerService absOtaCallerService = MicroContext.getServiceManager().findServiceByInterface(AbsOtaCallerService.class.getName());
		if (absOtaCallerService != null) {
			if (absOtaCallerService.isSupportUpgrade(devId)) {
				absOtaCallerService.goFirmwareUpgrade(this, devId);
			} else {
				// This device can not support ota
			}
		}

Customizes the logic to exit update page

For the smart devices that support forced update, if they are running in the updating state, the UI BizBundle allows you to implement the logic of exiting the firmware update page by yourself. For example, during the firmware update, you might need to implement navigation to the app homepage, instead of returning to the higher-level page.

API description

void setOtaBehaviorListener(IOtaBehaviorListener callback);

Parameters

Parameter Description
IOtaBehaviorListener The callback that is executed when an action is implemented during the firmware update.

Example

AbsOtaCallerService absOtaCallerService = MicroContext.getServiceManager()
	.findServiceByInterface(AbsOtaCallerService.class.getName());
absOtaCallerService.setOtaBehaviorListener(new IOtaBehaviorListener() {
				@Override
				public void onBackPressedWhenForceUpgrading(Activity activity) {
					if (activity != null) {
					activity.finish();
					}
					// do something after OTA page closed
				}
			});