Package com.mitac.api.libs
Class MitacOtaManager
- java.lang.Object
-
- com.mitac.api.libs.ApiBindBase
-
- com.mitac.api.libs.MitacOtaManager
-
public class MitacOtaManager extends ApiBindBase
This class provides OTA related APIs.-
Developer Guides
- download ota package and put it in the root folder of SD card or inner storage
- call
updateBaseOtaImage(android.content.Context, com.mitac.api.libs.MitacOtaManager.UpdateOtaListener)
orupdateRegionOtaImage(android.content.Context, com.mitac.api.libs.MitacOtaManager.UpdateOtaListener)
to ask system to upgrade ota image - get upgrade progress and upgrade result in UpdateOtaListener callback
-
System Properties for OTA status
We provided below system properties for OTA status, you can useSystemUtilities.getSystemProp(String)
to get the valueBelow are all properties for OTA properties name comments persist.sys.ota.base_update_version base image version need to be applied before reboot, which will be cleared after reboot. It is ro.build.display.id in new image as default, if base image does not contain display-id in metadata, it will be ro.build.date.utc persist.sys.ota.region_update_version region image version need to be applied before reboot, which will be cleared after reboot. It is persist.sys.rgimg.script_ver in new image as default sys.ota.need_delete_package Updater will delete package after applied update, which is the parameter named needDelete in method updateRegionOtaImage(Context, String, boolean, boolean, UpdateOtaListener)
sys.ota.need_reboot Updater will reboot after applied update, which is the parameter named needReboot in method updateRegionOtaImage(Context, String, boolean, boolean, UpdateOtaListener)
persist.sys.ota.update_type_flag An update is in processing, 0: base image or base + region; 1: region image; -1: no updating persist.sys.ota.update_apply_success boolean value to indicate the latest update is success or not after reboot -
Sample Code:
package com.mitac.api; public class MainActivity extends Activity { private MitacOtaManager mMitacOtaManager;
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mMitacOtaManager = new MitacOtaManager(getApplicationContext()); } private void updateBaseOta() { mitacOtaManager.updateBaseOtaImage(getApplicationContext(), new MitacOtaManager.UpdateOtaListener() {@Override
public void onError(int errorCode) { Log.d(TAG, "onError: " + errorCode); }@Override
public void onProgress(int progress) { Log.d(TAG, "onProgress: " + progress); } }); } private void updateRegionOta() { mitacOtaManager.updateRegionOtaImage(getApplicationContext(), new MitacOtaManager.UpdateOtaListener() {@Override
public void onError(int errorCode) { Log.d(TAG, "onError: " + errorCode); }@Override
public void onProgress(int progress) { Log.d(TAG, "onProgress: " + progress); } }); } }
-
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MitacOtaManager.UpdateOtaListener
OTA update's progress and result callback
-
Constructor Summary
Constructors Constructor Description MitacOtaManager(android.content.Context context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindService()
bind servicevoid
unbindService()
unbind servicevoid
updateBaseOtaImage(android.content.Context context, boolean needReboot, MitacOtaManager.UpdateOtaListener listener)
Auto update base OTA package.void
updateBaseOtaImage(android.content.Context context, MitacOtaManager.UpdateOtaListener listener)
Auto update base OTA package.void
updateBaseOtaImage(android.content.Context context, java.lang.String updateFilePath, boolean needReboot, boolean needDelete, MitacOtaManager.UpdateOtaListener listener)
Auto update base OTA package.void
updateRegionOtaImage(android.content.Context context, boolean needReboot, MitacOtaManager.UpdateOtaListener listener)
Auto update region OTA package.Region OTA package name should start with "RGIMG_" and end with "_OTA.zip".void
updateRegionOtaImage(android.content.Context context, MitacOtaManager.UpdateOtaListener listener)
Auto update region OTA package.Region OTA package name should start with "RGIMG_" and end with "_OTA.zip".void
updateRegionOtaImage(android.content.Context context, java.lang.String updateFilePath, boolean needReboot, boolean needDelete, MitacOtaManager.UpdateOtaListener listener)
Auto update region OTA package.
-
-
-
Method Detail
-
updateBaseOtaImage
public void updateBaseOtaImage(android.content.Context context, MitacOtaManager.UpdateOtaListener listener)
Auto update base OTA package. Base OTA package name should end with "_OTA.zip".Please put the OTA packages under internal storage root directory or external SD card root directory.- Parameters:
context
- TheContext
ask to upgrade imagelistener
- The callbackMitacOtaManager.UpdateOtaListener
to get progress and result
-
updateBaseOtaImage
public void updateBaseOtaImage(android.content.Context context, boolean needReboot, MitacOtaManager.UpdateOtaListener listener)
Auto update base OTA package. Base OTA package name should end with "_OTA.zip". Please put the OTA packages under internal storage root directory or external SD card root directory.- Parameters:
context
- TheContext
ask to upgrade imageneedReboot
- whether reboot device after OTA updating. Updating will be applied after device reboot. It can't trigger next OTA updating before reboot.listener
- The callbackMitacOtaManager.UpdateOtaListener
to get progress and result
-
updateBaseOtaImage
public void updateBaseOtaImage(android.content.Context context, java.lang.String updateFilePath, boolean needReboot, boolean needDelete, MitacOtaManager.UpdateOtaListener listener)
Auto update base OTA package.- Parameters:
context
- TheContext
ask to upgrade imageupdateFilePath
- The OTA package file that included absolute path, it should be started with /sdcard/needReboot
- whether reboot device after OTA updating. Updating will be applied after device reboot. It can't trigger next OTA updating before reboot.needDelete
- whether delete the OTA package on next reboot if updating successfully.listener
- The callbackMitacOtaManager.UpdateOtaListener
to get progress and result
-
updateRegionOtaImage
public void updateRegionOtaImage(android.content.Context context, MitacOtaManager.UpdateOtaListener listener)
Auto update region OTA package.Region OTA package name should start with "RGIMG_" and end with "_OTA.zip". Please put region the OTA packages under internal storage root directory or external SD card root directory.- Parameters:
context
- TheContext
ask to upgrade imagelistener
- The callbackMitacOtaManager.UpdateOtaListener
to get progress and result
-
updateRegionOtaImage
public void updateRegionOtaImage(android.content.Context context, boolean needReboot, MitacOtaManager.UpdateOtaListener listener)
Auto update region OTA package.Region OTA package name should start with "RGIMG_" and end with "_OTA.zip". Please put region the OTA packages under internal storage root directory or external SD card root directory.- Parameters:
context
- TheContext
ask to upgrade imageneedReboot
- whether reboot device after OTA updating. Updating will be applied after device reboot. It can't trigger next OTA updating before reboot.listener
- The callbackMitacOtaManager.UpdateOtaListener
to get progress and result
-
updateRegionOtaImage
public void updateRegionOtaImage(android.content.Context context, java.lang.String updateFilePath, boolean needReboot, boolean needDelete, MitacOtaManager.UpdateOtaListener listener)
Auto update region OTA package.- Parameters:
context
- TheContext
ask to upgrade imageupdateFilePath
- The OTA package file that included absolute path, it should be started with /sdcard/needReboot
- whether reboot device after OTA updating. Updating will be applied after device reboot. It can't trigger next OTA updating before reboot.needDelete
- whether delete the OTA package on next reboot if updating successfully.listener
- The callbackMitacOtaManager.UpdateOtaListener
to get progress and result
-
bindService
public void bindService()
Description copied from class:ApiBindBase
bind service- Specified by:
bindService
in classApiBindBase
-
unbindService
public void unbindService()
Description copied from class:ApiBindBase
unbind service- Specified by:
unbindService
in classApiBindBase
-
-