update_operation.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <storage/storage.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #define UPDATE_OPERATION_ROOT_DIR_PACKAGE_MAGIC 0
  8. #define UPDATE_OPERATION_MAX_MANIFEST_PATH_LEN 255u
  9. #define UPDATE_OPERATION_MIN_MANIFEST_VERSION 2
  10. /*
  11. * Checks if supplied full manifest path is valid
  12. * @param full_path Full path to manifest file. Must be named UPDATE_MANIFEST_DEFAULT_NAME
  13. * @param out_manifest_dir Directory to apply update from, if supplied path is valid.
  14. * May be empty if update is in root update directory
  15. * @return bool if supplied path is valid and out_manifest_dir contains dir to apply
  16. */
  17. bool update_operation_get_package_dir_name(const char* full_path, FuriString* out_manifest_dir);
  18. /* When updating this enum, also update assets/protobuf/system.proto */
  19. typedef enum {
  20. UpdatePrepareResultOK,
  21. UpdatePrepareResultManifestPathInvalid,
  22. UpdatePrepareResultManifestFolderNotFound,
  23. UpdatePrepareResultManifestInvalid,
  24. UpdatePrepareResultStageMissing,
  25. UpdatePrepareResultStageIntegrityError,
  26. UpdatePrepareResultManifestPointerError,
  27. UpdatePrepareResultTargetMismatch,
  28. UpdatePrepareResultOutdatedManifestVersion,
  29. UpdatePrepareResultIntFull,
  30. UpdatePrepareResultUnspecifiedError,
  31. } UpdatePrepareResult;
  32. const char* update_operation_describe_preparation_result(const UpdatePrepareResult value);
  33. /*
  34. * Validates next stage and sets up registers to apply update after restart
  35. * @param manifest_dir_path Full path to manifest for update to apply
  36. * @return UpdatePrepareResult validation & arm result
  37. */
  38. UpdatePrepareResult update_operation_prepare(const char* manifest_file_path);
  39. /*
  40. * Gets filesystem path for current update package
  41. * @param storage Storage API
  42. * @param out_path Path to manifest. Must be initialized
  43. * @return true if path was restored successfully
  44. */
  45. bool update_operation_get_current_package_manifest_path(Storage* storage, FuriString* out_path);
  46. /*
  47. * Checks if an update operation step is pending after reset
  48. */
  49. bool update_operation_is_armed();
  50. /*
  51. * Cancels pending update operation
  52. */
  53. void update_operation_disarm();
  54. #ifdef __cplusplus
  55. }
  56. #endif