Class UpdateService

java.lang.Object
com.kosdev.kos.core.primary.service.update.UpdateService

public final class UpdateService extends Object
This service handles USB based updates to the device. The service is very simple and provides two key functions:
  • Find available updates: The service will mount each attached storage device (usb drive) and search all the kabs in the root directory to see if there are any compatible manifest chains.
  • Install a particular chain: Using the results from the fist step to identify a particular manifestId and deviceId, install the release.
This service automatically search all connected usb storage devices and will only mount them while they are needed, allowing them to be removed immediately upon completion of the installation.

This service can be used in conjunction with StorageService which generates events when usb storage devices are inserted / removed. This can be used to trigger the check for available updates which effectively identifies updates immediately upon device insertion.

This service also supports the concept of an internal update. This is designed for use by recovery-style tools and use cases. It allows a single release to be copied to the /mnt/datafs/update directory which can then be installed via api/endpoint. If the update is compatible with the device, the update will be installed and activated and the device will reboot immediately. The update will automatically be removed from disk to minimize the space impact. This allows remote updates in the event the is an issue with standard OTA and it is not practical to have a user perform a usb update.

Since:
1
Version:
9
  • Method Details

    • getAvailableUpdates

      public List<UpdateInfo> getAvailableUpdates()
      Return the list of available software that exists on storage devices that can be installed on this device. This automatically iterates through all available usb storage devices to check for compatible manifest chains, utilizing ManifestChainResolver . The results of all compatible releases are returned such that they can be presented for a user to pick from the options and trigger an install.
      Since:
      1
    • installUpdate

      public FutureWork installUpdate(String manifestId, String deviceId)
      Install an update with the specified manifestId on the storage device with the specified deviceId. This information is available in UpdateInfo objects returned from getAvailableUpdates() . This will mount the storage device for the duration of the install and then unmount it when complete, allowing it to be safely removed immediately after install.

      As this process is meant to be triggered from a user in front of the device, it will activate the new release once installed. For deferred updates such as those delivered over the air, refer to OTAService which provides extensive OTA functionality.

      Parameters:
      manifestId - id of the first manifest in the chain
      deviceId - id of the storage device that contains the update
      Since:
      1
    • installUpdate

      public FutureWork installUpdate(String manifestId, File dir)
      Install an update with the specified manifestId from the specified directory. This can be used to install from an internal source such as an internal drive which is not detected by the standard update process which is primarily focused at usb storage devices. This can be used along with ManifestChainResolver to support installations from internal sources with minimal effort.

      As this process is meant to be triggered from a user in front of the device, it will activate the new release once installed. For deferred updates such as those delivered over the air, refer to OTAService which provides extensive OTA functionality.

      Parameters:
      manifestId - id of the first manifest in the chain
      dir - the directory to install from
      Since:
      1
    • installInternalUpdate

      public void installInternalUpdate(boolean reboot)
      Install the release contained in the internal update directory. This is designed for emergency use cases where OTA is not accessible and it is not practical for a user to perform a usb update. Using remote access to the device, a release can be installed into /mnt/datafs/update and this api can be used to install it. As this is not intended to be used by a ui, this does not return a future. Instead will either return successfully or throw an exception. This is designed to make the output compatible with command line tooling such as curl.

      The update must be installed as a collection of KAB files, not a zip file of KAB's. This api will examine all the KAB's and find the head of the manifest chain automatically. The update must be compatible with the device for the install to be successful.

      After a successful install, the contents of the /mnt/datafs/update will be deleted in order to recover the disk space.

      If the reboot flag is true and the install is successful, the device will automatically reboot after the configured delay ( internalUpdateRebootDelayMs config property). If reboot is false the update will still be activated so the next reboot will run the newly installed update.

      Since:
      9