Class FirmwareService

All Implemented Interfaces:
CtxEventListener, ContextHandleAware, HandleAware, Ready, ReadyListener

public final class FirmwareService extends AbstractService
Service that handles updating firmware on update-capable devices.
Version:
2023-10-05
  • Field Details

  • Method Details

    • onBeanReady

      public boolean onBeanReady()
      Description copied from class: ReadyBean
      Override in subclasses to be notified when all dependencies are ready. Return true to indicate that this bean is also ready. If the bean needs to call setReady() later due to some async processing, return false to prevent setReady() from being called automatically.

      It is recommended to override this method rather than onDependenciesReady() as a majority of the time it requires calling super.onDependneciesReady() or explicitly calling setReady() which defaults to a failure mode.

      Overrides:
      onBeanReady in class ReadyBean
      Returns:
    • getAvailableFirmware

      public List<FirmwareInfo> getAvailableFirmware(String boardType, String firmwareType)
      Return the list of available firmware with the specified board and firmware types;
      Parameters:
      boardType - the type of the board to match
      firmwareType - the type of firmware to match
    • getAvailableFirmware

      public List<FirmwareInfo> getAvailableFirmware(String boardType, String firmwareType, String boardRevision)
      Return the list of available firmware with the specified board and firmware types and an optional board revision. Board revisions allow different versions of a given board to have different firmware.
      Parameters:
      boardType - the type of the board to match
      firmwareType - the type of firmware to match
      boardRevision - optional revision to match
    • getNewestFirmware

      public FirmwareInfo getNewestFirmware(String boardType, String firmwareType, String ignoreVersion)
      Return the newest available firmware for the specified boardType and firmwareType.

      If the optional ignoreVersion is specified and it matches the newest version, null will be returned instead of the newest firmware. This allows the currently installed firmware version to be specified so that null is returned if already installed.

      This uses the default version comparator which supports four digit version numbers. To use custom version sorting, use the method with optional comparator.

      Parameters:
      boardType - the type of the board to match
      firmwareType - the type of firmware to match
      ignoreVersion - optional version to ignore
    • getNewestFirmware

      public FirmwareInfo getNewestFirmware(String boardType, String firmwareType, String boardRevision, String ignoreVersion)
      Return the newest available firmware for the specified boardType and firmwareType. If the optional boardRevision is specified, only firmware compatible with the specified revision will be considered.

      If the optional ignoreVersion is specified and it matches the newest version, null will be returned instead of the newest firmware. This allows the currently installed firmware version to be specified so that null is returned if already installed.

      This uses the default version comparator which supports four digit version numbers. To use custom version sorting, use the method with optional comparator.

      Parameters:
      boardType - the type of the board to match
      firmwareType - the type of firmware to match
      boardRevision - optional revision to match
      ignoreVersion - optional version to ignore
    • getNewestFirmware

      public FirmwareInfo getNewestFirmware(String boardType, String firmwareType, String boardRevision, String ignoreVersion, Comparator<FirmwareInfo> versionComparator)
      Return the newest available firmware for the specified boardType and firmwareType. If the optional boardRevision is specified, only firmware compatible with the specified revision will be considered.

      If the optional ignoreVersion is specified and it matches the newest version, null will be returned instead of the newest firmware. This allows the currently installed firmware version to be specified so that null is returned if already installed.

      This uses the specified comparator to compare version numbers. This allows custom versions to be used. When sorted with the comparator, the first available firmware in the resulting list is returned. If not specified, the default comparator will be used which supports four digit versions.

      Parameters:
      boardType - the type of the board to match
      firmwareType - the type of firmware to match
      boardRevision - optional revision to match
      ignoreVersion - optional version to ignore
      versionComparator - custom comparator for version numbers
    • addFirmware

      public void addFirmware(KabFile kab)
      Add a firmware kab file. This will process the firmware section from the kab descriptor and make the results searchable.
      Parameters:
      kab - the kab that contains firmware
    • updateFirmware

      public void updateFirmware(FirmwareUpdatableDevice device, FirmwareUpdater updater, FirmwareUpdateCallback callback)
      Queue the device for firmware update if needed. Devices will sit in this queue until firmware mgr finishes scanning all available firmware and then each device will be checked one at a time. If the firmware on a given device needs to be updated, that device will be put into the upgrade queue.
      Parameters:
      device - device to update
      updater - performs the actual update
      callback - callback to notify when device is ready
    • cancelUpdate

      public void cancelUpdate(FirmwareUpdatableDevice device)
      Called if a device is no longer valid. This will remove it from the update process, allowing a new instance of the device to queue a new job. If an update is in progress, it will be cancelled. It's the responsibility of the updater to leave the hardware in a valid state when cancelled.
    • queueUpdate

      public void queueUpdate(UpdateTask task)
      Queue an UpdateTask to be run. This should only be called with an UpdateTask provided to onUpdateRequired() where this method returned false. This provides a way for user code to start the otherwise blocked update. The most common reason for this flow is in the event that a user must confirm an update. This allows onUpdateRequired() to return false, user code can then hold the task and call queueUpdate() once the user confirms the update.
    • getHardwareService

      public HardwareService getHardwareService()