Class MitacOtaManager


  • public class MitacOtaManager
    extends ApiBindBase
    This class provides OTA related APIs.
    • Developer Guides

    • System Properties for OTA status

      We provided below system properties for OTA status, you can use SystemUtilities.getSystemProp(String) to get the value
      Below 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);
                        }
                   });
            }
        }
       
    • Constructor Detail

      • MitacOtaManager

        public MitacOtaManager​(android.content.Context context)
    • 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 - The Context ask to upgrade image
        listener - The callback MitacOtaManager.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 - The Context ask to upgrade image
        needReboot - whether reboot device after OTA updating. Updating will be applied after device reboot. It can't trigger next OTA updating before reboot.
        listener - The callback MitacOtaManager.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 - The Context ask to upgrade image
        updateFilePath - 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 callback MitacOtaManager.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 - The Context ask to upgrade image
        listener - The callback MitacOtaManager.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 - The Context ask to upgrade image
        needReboot - whether reboot device after OTA updating. Updating will be applied after device reboot. It can't trigger next OTA updating before reboot.
        listener - The callback MitacOtaManager.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 - The Context ask to upgrade image
        updateFilePath - 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 callback MitacOtaManager.UpdateOtaListener to get progress and result