com.eloview.homesdk.otaManager

## Class OTA

- java.lang.Object
- - com.eloview.homesdk.consts.Consts
  - - com.eloview.homesdk.accountManager.AccountManager
    - - com.eloview.homesdk.otaManager.OTA

- All Implemented Interfaces:
    java.lang.Cloneable

      public class OTA
      extends AccountManager

  OTA class allows you to download and install OS upgrade files securely

  OS Upgrade Example:
  1. Get an auth token using `getEloAccessToken`
  2. Check if new updates are available using `checkEloOTAStatus`. The `OTA_CHECK_STATUS_NEW` flag lets us know if a new update is available.
  3. (Not for Android Q) Download the new OS using `startDownloadEloOTAPackage`. Download progress callbacks are received with `OTA_DOWNLOAD_REMOTE_FILE_PERCENTAGE`. A successful download is characterized by the `OTA_DOWNLOAD_REMOTE_FILE_SUCCESS` callback message.
  4. (Not for Android Q) Verify the integrity of the OS upgrade file using `verifyEloOTA`. The `OTA_VERIFY_SIGN_SUCCESS` callback message signifies that the upgrade can be applied.
  5. (Not for Android Q) Install the new OS using `applyEloOTA`, this process can take up to 10 minutes and the system reboots during the installation. Most partitions on the device are changed during the installation. The userdata partition will not be touched by the OTA update, all app data will remain intact.
  6. (Only for Android Q) Download, verify and install the OS Update using `downloadApplyABOTA`. Returns status codes `OTA_DOWNLOAD_REMOTE_FILE_PERCENTAGE` for download progress `OTA_APPLY_IN_PROGRESS` while applying OTA, `Consts.GENERIC_ERROR` For any errors that occur while downloading and applying OTA.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEVICE_NOT_SUPPORT_GMS` Deice won't support GMS upgrade from AOSP image.
    `static int` | `EV_RESPONSE`
    `static OTA` | `instance`
    `static int` | `OS360_RESPONSE_AVAILABLE`
    `static int` | `OS360_RESPONSE_UNAVAILABLE`
    `static int` | `OTA_APPLY_FILE_ERROR` The OTA was not applied due to some error.
    `static int` | `OTA_APPLY_IN_PROGRESS` The OTA is currently being applied.
    `static int` | `OTA_CHECK_STATUS_GENERIC_ERROR` Could not retrieve info about the remote OTA package.
    `static int` | `OTA_CHECK_STATUS_NEW` There is a new OTA package available, please update.
    `static int` | `OTA_CHECK_STATUS_OLD` The latest available OTA package is older than the current system.
    `static int` | `OTA_CHECK_STATUS_SAME` The latest available OTA package is the same as the current system.
    `static int` | `OTA_DIRECTORY_CLEARED` The OTA directory has been deleted
    `static int` | `OTA_DOWNLOAD_GENERIC_ERROR` There was an unknown error while downloading the OTA package.
    `static int` | `OTA_DOWNLOAD_LOCAL_FILE_ERROR` Local OTA package could not be copied due to an error.
    `static int` | `OTA_DOWNLOAD_LOCAL_FILE_PERCENTAGE` Progress of copying the OTA package from local source.
    `static int` | `OTA_DOWNLOAD_LOCAL_FILE_SUCCESS` Local OTA package has been copied successfully.
    `static int` | `OTA_DOWNLOAD_REMOTE_FILE_ALREADY_DOWNLOADED` A new OTA package is already present on the device and can be installed.
    `static int` | `OTA_DOWNLOAD_REMOTE_FILE_ERROR` There was an error downloading the OTA package.
    `static int` | `OTA_DOWNLOAD_REMOTE_FILE_PERCENTAGE` Progress of the OTA package download.
    `static int` | `OTA_DOWNLOAD_REMOTE_FILE_SUCCESS` The remote file has downloaded successfully.
    `static int` | `OTA_EXISTING_ZIPFILE_READ_ERROR` The existing update zipfile could not be read
    `static int` | `OTA_VERIFY_FILE_ERROR` There was an error verifying the OTA package, the file may be corrupt.
    `static int` | `OTA_VERIFY_SIGN_ERROR` The OTA package signature is invalid.
    `static int` | `OTA_VERIFY_SIGN_PERCENTAGE` Progress of an OTA package verification.
    `static int` | `OTA_VERIFY_SIGN_SUCCESS` The OTA package signature was verified and is valid.
    `static int` | `OTA_VERSION_RESPONSE_AVAILABLE` A list of OTA versions available for download is available
    `static java.lang.String` | `property`

    - ### Fields inherited from class com.eloview.homesdk.accountManager.AccountManager

      `ACCESS_TOKEN_INVALID, ACCESS_TOKEN_VALID, API_ACCESS_TOKEN_INVALID, API_ACCESS_TOKEN_VALID, IS_USER_LOGIN_OAUTH, isPolaris, KEY_SERVER_ELO_POLARIS_DEV, KEY_SERVER_PRODUCTION_POLARIS, KEY_SERVER_QA_POLARIS, KEY_SERVER_STAGING_POLARIS, OAUTH_TOKEN_INVALID, OAUTH_TOKEN_VALID, REQUEST_AUTH_LOGIN, REQUEST_AUTH_LOGOUT, SETUP_OAUTH_ERROR, SETUP_OAUTH_SUCCESS, TOKEN_VERIFY_FAIL, TOKEN_VERIFY_SUCCESS`

    - ### Fields inherited from class com.eloview.homesdk.consts.Consts

      `ACTION_SET_EST_REQUEST, ELO_FOLDER, ELO_NETWORK_CONF_CSV_FILE, ELO_WIFI_CONFIG_FOLDER, GENERIC_ERROR, isFROM, OAUTH_PATH_TOKEN, OAUTH_PATH_VERIFY, REQUEST_TOKEN, STR_CUSTOM_ANIM_IMAGE_FILE, STR_CUSTOM_ANIM_VIDEO_FILE, STR_CUSTOM_BRAND_LOGO_FILE, STR_CUSTOM_BRAND_NAME_FILE, STR_CUSTOM_BRAND_POWERED_BY_LOGO_FILE, STR_CUSTOM_LOCALE_NAME_FILE, STR_CUSTOM_WALLPAPER, STR_ELO_PATH_FOR_CUSTOM_ANIMATION, STR_SDCARD_ELO_DIR_PATH, VERIFY_TOKEN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OTA()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `applyOTA(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` This method is used to install a new OTA package.
    `void` | `checkOTAStatus(android.content.Context context, java.lang.String accessToken, org.json.JSONObject jsonObject, android.os.Handler handler)` This method is used to check whether the OTA package currently installed on the device is newer or older than the latest package available on the server.
    `void` | `checkOTAStatus(android.content.Context context, java.lang.String accessToken, java.lang.String buildPropUrl, android.os.Handler handler)` This method is used to check whether the OTA package currently installed on the device is newer or older than the latest package available on the server.
    `void` | `downloadApplyABOTA(android.content.Context context, java.lang.String accessToken, java.lang.String otaURL, java.lang.String otaPath, java.lang.String otaVersion, android.os.Handler handler)` This method is used to download OTA file from remote http server or from local file path, VERIFY the OTA file and APPLY the update.
    `void` | `getAvailableVersions(android.content.Context context, java.lang.String accessToken, AndroidVersion androidVersion, android.os.Handler handler)` This method is used to retrieve the OTA package versions that are available on the server for download.
    `void` | `getOS360Details(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` This method is used to get os360 details
    `boolean` | `isOTAFromA10To12(java.lang.String currBuildVersion, java.lang.String requestedOTAVersion)` Checks if the requested OTA is from A10 to A12
    `void` | `startDownloadUpgradePackage(android.content.Context context, java.lang.String accessToken, java.lang.String otaURL, android.net.Uri uri, java.lang.String otaVersion, android.os.Handler handler)` This method is used to download OTA file from remote http server or from local file path.
    `void` | `verifyEloOTA(android.content.Context context, java.lang.String accessToken, android.os.Handler handler)` This method verifies the signature of the downloaded OTA package.

    - ### Methods inherited from class com.eloview.homesdk.accountManager.AccountManager

      `configureOAuthHostedUI, destroyOAuth, getBaseUri, getClientId, getEloAccessToken, getEloOAuthToken, getEnvironment, getProperty, isPolaris, isPolarisLocked, logoutOAuth, onOAuthActivityResult, selectEnvironment, setDefaultEnvironment, setProperty, stopOAuth, unregisterAccountManagerListener, verifyEloToken`

    - ### Methods inherited from class com.eloview.homesdk.consts.Consts

      `clone, getEloIntentWithFlag, getMigrate, isDevice7Inch, isDeviceM100`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### OTA_DOWNLOAD_REMOTE_FILE_SUCCESS

          public static final int OTA_DOWNLOAD_REMOTE_FILE_SUCCESS

      The remote file has downloaded successfully.
      See Also:
        Constant Field Values

    - #### OTA_DOWNLOAD_REMOTE_FILE_ERROR

          public static final int OTA_DOWNLOAD_REMOTE_FILE_ERROR

      There was an error downloading the OTA package.
      See Also:
        Constant Field Values

    - #### OTA_DOWNLOAD_REMOTE_FILE_PERCENTAGE

          public static final int OTA_DOWNLOAD_REMOTE_FILE_PERCENTAGE

      Progress of the OTA package download.
      See Also:
        Constant Field Values

    - #### OTA_DOWNLOAD_LOCAL_FILE_SUCCESS

          public static final int OTA_DOWNLOAD_LOCAL_FILE_SUCCESS

      Local OTA package has been copied successfully.
      See Also:
        Constant Field Values

    - #### OTA_DOWNLOAD_LOCAL_FILE_ERROR

          public static final int OTA_DOWNLOAD_LOCAL_FILE_ERROR

      Local OTA package could not be copied due to an error.
      See Also:
        Constant Field Values

    - #### OTA_DOWNLOAD_LOCAL_FILE_PERCENTAGE

          public static final int OTA_DOWNLOAD_LOCAL_FILE_PERCENTAGE

      Progress of copying the OTA package from local source.
      See Also:
        Constant Field Values

    - #### OTA_DOWNLOAD_GENERIC_ERROR

          public static final int OTA_DOWNLOAD_GENERIC_ERROR

      There was an unknown error while downloading the OTA package.
      See Also:
        Constant Field Values

    - #### OTA_VERIFY_SIGN_SUCCESS

          public static final int OTA_VERIFY_SIGN_SUCCESS

      The OTA package signature was verified and is valid.
      See Also:
        Constant Field Values

    - #### OTA_VERIFY_SIGN_ERROR

          public static final int OTA_VERIFY_SIGN_ERROR

      The OTA package signature is invalid.
      See Also:
        Constant Field Values

    - #### OTA_VERIFY_SIGN_PERCENTAGE

          public static final int OTA_VERIFY_SIGN_PERCENTAGE

      Progress of an OTA package verification.
      See Also:
        Constant Field Values

    - #### OTA_VERIFY_FILE_ERROR

          public static final int OTA_VERIFY_FILE_ERROR

      There was an error verifying the OTA package, the file may be corrupt.
      See Also:
        Constant Field Values

    - #### OTA_CHECK_STATUS_OLD

          public static final int OTA_CHECK_STATUS_OLD

      The latest available OTA package is older than the current system.
      See Also:
        Constant Field Values

    - #### OTA_CHECK_STATUS_NEW

          public static final int OTA_CHECK_STATUS_NEW

      There is a new OTA package available, please update.
      See Also:
        Constant Field Values

    - #### OTA_CHECK_STATUS_SAME

          public static final int OTA_CHECK_STATUS_SAME

      The latest available OTA package is the same as the current system.
      See Also:
        Constant Field Values

    - #### OTA_CHECK_STATUS_GENERIC_ERROR

          public static final int OTA_CHECK_STATUS_GENERIC_ERROR

      Could not retrieve info about the remote OTA package.
      See Also:
        Constant Field Values

    - #### OTA_APPLY_FILE_ERROR

          public static final int OTA_APPLY_FILE_ERROR

      The OTA was not applied due to some error.
      See Also:
        Constant Field Values

    - #### OTA_APPLY_IN_PROGRESS

          public static final int OTA_APPLY_IN_PROGRESS

      The OTA is currently being applied. Please wait.
      See Also:
        Constant Field Values

    - #### OTA_DOWNLOAD_REMOTE_FILE_ALREADY_DOWNLOADED

          public static final int OTA_DOWNLOAD_REMOTE_FILE_ALREADY_DOWNLOADED

      A new OTA package is already present on the device and can be installed.
      See Also:
        Constant Field Values

    - #### OTA_DIRECTORY_CLEARED

          public static final int OTA_DIRECTORY_CLEARED

      The OTA directory has been deleted
      See Also:
        Constant Field Values

    - #### OTA_EXISTING_ZIPFILE_READ_ERROR

          public static final int OTA_EXISTING_ZIPFILE_READ_ERROR

      The existing update zipfile could not be read
      See Also:
        Constant Field Values

    - #### OTA_VERSION_RESPONSE_AVAILABLE

          public static final int OTA_VERSION_RESPONSE_AVAILABLE

      A list of OTA versions available for download is available
      See Also:
        Constant Field Values

    - #### OS360_RESPONSE_AVAILABLE

          public static final int OS360_RESPONSE_AVAILABLE

      See Also:
        Constant Field Values

    - #### OS360_RESPONSE_UNAVAILABLE

          public static final int OS360_RESPONSE_UNAVAILABLE

      See Also:
        Constant Field Values

    - #### EV_RESPONSE

          public static final int EV_RESPONSE

      See Also:
        Constant Field Values

    - #### DEVICE_NOT_SUPPORT_GMS

          public static final int DEVICE_NOT_SUPPORT_GMS

      Deice won't support GMS upgrade from AOSP image.
      See Also:
        Constant Field Values

    - #### property

          public static java.lang.String property

    - #### instance

          public static OTA instance

  - ### Constructor Detail

    - #### OTA

          public OTA()

  - ### Method Detail

    - #### startDownloadUpgradePackage

          public void startDownloadUpgradePackage(android.content.Context context,
                                                  java.lang.String accessToken,
                                                  java.lang.String otaURL,
                                                  android.net.Uri uri,
                                                  java.lang.String otaVersion,
                                                  android.os.Handler handler)

      This method is used to download OTA file from remote http server or from local file path. A token is required prior to calling this function.
      1. otaURL will get first precedence. To ignore the otaURL argument an empty string can be provided. An online token is required to download OTA from otaURL.
      2. otaVersion will get second precedence. Ota versions can be procured by calling getAvailableVersions(). To ignore this argument, an empty string can be provided. An online token is required to download OTA by specifying version.
      3. otaUri (local file path) will get next precedence. Download from local path can be done without an online token.
      4. Fourth precedence falls to the elo default upgrade server. This is used if empty strings are provided for otaURL and otaVersion. This requires an online token.
      The OS upgrade files are downloaded using the Android Download Manager. Failures are possible; for example when an incorrect status, download URL, or a nonexistent version number is provided, the download manager will show STATUS_FAILED in logcat. More information on the behavior of the Android download manager and its constant values can be found at: ....
      Each time you trigger an OTA download using the API, the ota directory will be cleared. When the verify and apply APIs are used, the last download that was completed will be used.

      Before starting the download, this method will check if a previously downloaded OTA package exists. If it does, the package will be extracted and the version will be checked against the latest available version to see if avoiding the download is possible. If the existing OTA package cannot be read, the old package will be removed and a new download of the latest OTA package will be started.

      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `otaURL` - A custom download URL can be provided, or an empty string can be passed.
        `accessToken` - An authentication token received from the Elo servers.
        `otaVersion` - A custom OTA package version can be provided, or an empty string can be passed.
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `OTA_DOWNLOAD_REMOTE_FILE_SUCCESS`
        `OTA_DOWNLOAD_REMOTE_FILE_ERROR`
        `OTA_DOWNLOAD_REMOTE_FILE_PERCENTAGE`
        `OTA_DOWNLOAD_LOCAL_FILE_SUCCESS`
        `OTA_DOWNLOAD_LOCAL_FILE_ERROR`
        `OTA_DOWNLOAD_LOCAL_FILE_PERCENTAGE`
        `OTA_DOWNLOAD_REMOTE_FILE_ALREADY_DOWNLOADED`
        `OTA_CHECK_STATUS_NEW`
        `OTA_CHECK_STATUS_SAME`
        `OTA_CHECK_STATUS_OLD`
        `OTA_CHECK_STATUS_GENERIC_ERROR`
        `Consts.GENERIC_ERROR`
        `OTA_DOWNLOAD_GENERIC_ERROR`

    - #### downloadApplyABOTA

          public void downloadApplyABOTA(android.content.Context context,
                                         java.lang.String accessToken,
                                         java.lang.String otaURL,
                                         java.lang.String otaPath,
                                         java.lang.String otaVersion,
                                         android.os.Handler handler)

      This method is used to download OTA file from remote http server or from local file path, VERIFY the OTA file and APPLY the update. A token is required prior to calling this function.
      1. otaURL will get first precedence. To ignore the otaURL argument an empty string can be provided. An online token is required to download OTA from otaURL.
      2. otaVersion will get second precedence. Ota versions can be procured by calling getAvailableVersions(). To ignore this argument, an empty string can be provided. An online token is required to download OTA by specifying version.
      3. otaUri (local file path) will get next precedence. Download from local path can be done without an online token.
      4. Fourth precedence falls to the elo default upgrade server. This is used if empty strings are provided for otaURL and otaVersion. This requires an online token.
      The OS upgrade files are downloaded using the Android Update Engine. Failures are possible; for example when an incorrect status, download URL, or a nonexistent version number is provided, the download manager will show STATUS_FAILED in logcat. More information on the behavior of the Android download manager and its constant values can be found at: ....
      Each time you trigger an OTA download using the API, the ota directory will be cleared. When the verify and apply APIs are used, the last download that was completed will be used.

      Before starting the download, this method will check if a previously downloaded OTA package exists. If it does, the package will be extracted and the version will be checked against the latest available version to see if avoiding the download is possible. If the existing OTA package cannot be read, the old package will be removed and a new download of the latest OTA package will be started.

      IMPORTANT: If you have an OS360 subscription you can get all updates using the offline token. If you have an EloView account, you can get MR updates using the online token obtained from your EloView account and your device needs to be added to your account. If you have neither subscription you cannot get updates.

      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - An authentication token received from the Elo servers.
        `otaURL` - A custom download URL can be provided, or an empty string can be passed to use default URL.
        `otaPath` - A custom OTA path on the device (eg. /sdcard/Download/ota.zip)
        `otaVersion` - A custom OTA package version can be provided (eg. 5.5.11+p)
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `OTA_DOWNLOAD_REMOTE_FILE_PERCENTAGE`
        `OTA_APPLY_IN_PROGRESS`
        `Consts.GENERIC_ERROR`

    - #### verifyEloOTA

          public void verifyEloOTA(android.content.Context context,
                                   java.lang.String accessToken,
                                   android.os.Handler handler)

      This method verifies the signature of the downloaded OTA package. This method can run without an online token.
      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - An authentication token received from the Elo servers
        `handler` - A handler to receive one of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `OTA_VERIFY_SIGN_SUCCESS`
        `OTA_VERIFY_SIGN_ERROR`
        `OTA_VERIFY_SIGN_PERCENTAGE`
        `OTA_VERIFY_FILE_ERROR`

    - #### getAvailableVersions

          public void getAvailableVersions(android.content.Context context,
                                           java.lang.String accessToken,
                                           AndroidVersion androidVersion,
                                           android.os.Handler handler)

      This method is used to retrieve the OTA package versions that are available on the server for download. Elo only keeps a certain number of packages deployed. The list will always be a manageable size. The version numbers will be received as a comma separated string. The string will be in ascending order. An example of a response:
      "1.26.13,1.26.14,1.26.16,1.26.18. This function requires an online token."

      Provides the available OTA versions list for given AndroidVersion enumeration. If androidVersion is null it will provide the OTA versions according to the device OS version type.

      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - An authentication token received from the Elo servers
        `handler` - A handler to receive one of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `OTA_VERSION_RESPONSE_AVAILABLE`

        `androidVersion` - An AndroidVersion for which to get available OTA versions.

    - #### getOS360Details

          public void getOS360Details(android.content.Context context,
                                      java.lang.String accessToken,
                                      android.os.Handler handler)

      This method is used to get os360 details
      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - Access Token
        `handler` -

    - #### applyOTA

          public void applyOTA(android.content.Context context,
                               java.lang.String accessToken,
                               android.os.Handler handler)

      This method is used to install a new OTA package. This method can run without an online token.
      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - String
        `handler` - A handler to receive one or more of the following callback messages:

        `AccountManager.TOKEN_VERIFY_FAIL`
        `OTA_APPLY_FILE_ERROR`
        `OTA_APPLY_IN_PROGRESS`
        `Consts.GENERIC_ERROR`

    - #### checkOTAStatus

          public void checkOTAStatus(android.content.Context context,
                                     java.lang.String accessToken,
                                     java.lang.String buildPropUrl,
                                     android.os.Handler handler)

      This method is used to check whether the OTA package currently installed on the device is newer or older than the latest package available on the server. This method does not require an online token.
      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - String
        `buildPropUrl` - must be a string "http://build.prop_server_url" or "file://build.prop_local_file_path" build.prop is mandatory to check OTA version./
        `handler` - A handler to receive one or more of the following callback messages: whether it is new,old or same.

        `AccountManager.TOKEN_VERIFY_FAIL`
        `OTA_CHECK_STATUS_NEW`
        `OTA_CHECK_STATUS_SAME`
        `OTA_CHECK_STATUS_OLD`
        `OTA_CHECK_STATUS_GENERIC_ERROR`
        `Consts.GENERIC_ERROR`

    - #### checkOTAStatus

          public void checkOTAStatus(android.content.Context context,
                                     java.lang.String accessToken,
                                     org.json.JSONObject jsonObject,
                                     android.os.Handler handler)

      This method is used to check whether the OTA package currently installed on the device is newer or older than the latest package available on the server. This method does not require an online token.
      Parameters:
        `context` - A context object of the calling Class (Activity/Service).
        `accessToken` - String
        `jsonObject` - A Json object (elo-ota-config.json) corresponding to an OTA file. This is used to determine whether the OS is up-to-date or can be updated.

        `AccountManager.TOKEN_VERIFY_FAIL`
        `OTA_CHECK_STATUS_NEW`
        `OTA_CHECK_STATUS_SAME`
        `OTA_CHECK_STATUS_OLD`
        `OTA_CHECK_STATUS_GENERIC_ERROR`
        `Consts.GENERIC_ERROR`

    - #### isOTAFromA10To12

          public boolean isOTAFromA10To12(java.lang.String currBuildVersion,
                                          java.lang.String requestedOTAVersion)

      Checks if the requested OTA is from A10 to A12
      Parameters:
        `currBuildVersion` - String
        `requestedOTAVersion` - String
      Returns:
        boolean : true if upgrading from A10 to 12 else false