OTA UI BizBundle

Last Updated on : 2023-07-03 01:56:30download

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.

Configure build.gradle of module

dependencies {
  implementation 'com.thingclips.smart:thingsmart-bizbundle-ota:2.0.0-cube.2'
}

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
				}
			});