2022-04-13 23:50:25 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <storage/storage.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-05-06 19:26:25 +03:00
|
|
|
#define UPDATE_OPERATION_ROOT_DIR_PACKAGE_MAGIC 0
|
2024-07-15 20:02:45 +03:00
|
|
|
#define UPDATE_OPERATION_MAX_MANIFEST_PATH_LEN 255u
|
|
|
|
#define UPDATE_OPERATION_MIN_MANIFEST_VERSION 2
|
2022-05-06 19:26:25 +03:00
|
|
|
|
2022-04-13 23:50:25 +03:00
|
|
|
/*
|
|
|
|
* Checks if supplied full manifest path is valid
|
|
|
|
* @param full_path Full path to manifest file. Must be named UPDATE_MANIFEST_DEFAULT_NAME
|
|
|
|
* @param out_manifest_dir Directory to apply update from, if supplied path is valid.
|
|
|
|
* May be empty if update is in root update directory
|
|
|
|
* @return bool if supplied path is valid and out_manifest_dir contains dir to apply
|
|
|
|
*/
|
2022-10-05 18:15:23 +03:00
|
|
|
bool update_operation_get_package_dir_name(const char* full_path, FuriString* out_manifest_dir);
|
2022-04-13 23:50:25 +03:00
|
|
|
|
2022-05-11 12:45:01 +03:00
|
|
|
/* When updating this enum, also update assets/protobuf/system.proto */
|
2022-04-13 23:50:25 +03:00
|
|
|
typedef enum {
|
|
|
|
UpdatePrepareResultOK,
|
|
|
|
UpdatePrepareResultManifestPathInvalid,
|
|
|
|
UpdatePrepareResultManifestFolderNotFound,
|
|
|
|
UpdatePrepareResultManifestInvalid,
|
|
|
|
UpdatePrepareResultStageMissing,
|
|
|
|
UpdatePrepareResultStageIntegrityError,
|
2023-07-14 16:45:16 +03:00
|
|
|
UpdatePrepareResultManifestPointerCreateError,
|
|
|
|
UpdatePrepareResultManifestPointerCheckError,
|
2022-05-11 12:45:01 +03:00
|
|
|
UpdatePrepareResultTargetMismatch,
|
|
|
|
UpdatePrepareResultOutdatedManifestVersion,
|
2022-07-04 16:36:12 +03:00
|
|
|
UpdatePrepareResultIntFull,
|
|
|
|
UpdatePrepareResultUnspecifiedError,
|
2022-04-13 23:50:25 +03:00
|
|
|
} UpdatePrepareResult;
|
|
|
|
|
|
|
|
const char* update_operation_describe_preparation_result(const UpdatePrepareResult value);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Validates next stage and sets up registers to apply update after restart
|
|
|
|
* @param manifest_dir_path Full path to manifest for update to apply
|
|
|
|
* @return UpdatePrepareResult validation & arm result
|
|
|
|
*/
|
|
|
|
UpdatePrepareResult update_operation_prepare(const char* manifest_file_path);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets filesystem path for current update package
|
|
|
|
* @param storage Storage API
|
2022-05-11 12:45:01 +03:00
|
|
|
* @param out_path Path to manifest. Must be initialized
|
2022-04-13 23:50:25 +03:00
|
|
|
* @return true if path was restored successfully
|
|
|
|
*/
|
2022-10-05 18:15:23 +03:00
|
|
|
bool update_operation_get_current_package_manifest_path(Storage* storage, FuriString* out_path);
|
2022-04-13 23:50:25 +03:00
|
|
|
|
|
|
|
/*
|
2022-05-06 19:26:25 +03:00
|
|
|
* Checks if an update operation step is pending after reset
|
2022-04-13 23:50:25 +03:00
|
|
|
*/
|
2024-03-25 13:53:32 +03:00
|
|
|
bool update_operation_is_armed(void);
|
2022-04-13 23:50:25 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Cancels pending update operation
|
|
|
|
*/
|
2024-03-25 13:53:32 +03:00
|
|
|
void update_operation_disarm(void);
|
2022-04-13 23:50:25 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2022-05-06 16:37:10 +03:00
|
|
|
#endif
|