1. OTA BizBundle
1.1. Features
Device OTA refers to the process of downloading and updating the firmware of the device through the network. The OTA biz bundle can help you quickly integrate the device firmware upgrade capabilities.
1.2. BizBundle integration
1.2.1. Create project
Create your project in Android Studio, connect to the public SDK and configure Biz Bundle Framework.
1.2.2. Module's build.gradle configuration
dependencies {
implementation 'com.tuya.smart:tuyasmart-bizbundle-ota:3.22.0-6'
}
1.3. Function use
1.3.1. OTA availability
Determine whether the current device supports firmware upgrade capability.
Declaration
boolean isSupportUpgrade(String devId);
Parameters
Parameters | Description |
---|---|
devId | 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
}
}
1.3.2. Go to the OTA page
If the current device supports the firmware upgrade capability, you can go to the firmware upgrade page and start the upgrade process.
Declaration
void goFirmwareUpgrade(Context context, String devId);
Parameters
Parameters | Description |
---|---|
context | Activity context |
devId | 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
}
}
1.3.3. Customize logic of exiting the OTA page
For devices that support forced upgrades, if they are in the upgrading state, the biz bundle supports custom logic of exiting the OTA page. For example, during the firmware upgrade process, a forced upgrade device may need to return to the home page instead of directly returning to the previous page.
Declaration
void setOtaBehaviorListener(IOtaBehaviorListener callback);
Parameters
Parameters | Description |
---|---|
IOtaBehaviorListener | Behavior callback during firmware upgrade |
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
}
});