[FL-2517, FL-2518, FL-2523] Updater UI overhaul (#1196)
* Updater: UI rework initial * Updater: further updates to UI, added a temporary parrot * Updater: additional checks on radio stack type before update * Second iteration of updater UI: additional handling of resource unpacking errors * updater: removed extra logging, renamed some stages * Updater: Changed "back" button icon on error screen * Archive: signed/unsigned fix * Updater: cancelling update also cancels LFS+resources processing; restored /ext/update/ folder magic to 0 * Updater: root dir fix Co-authored-by: nminaylov <nm29719@gmail.com>
This commit is contained in:
@@ -27,7 +27,6 @@ static bool update_task_pre_update(UpdateTask* update_task) {
|
||||
path_concat(
|
||||
string_get_cstr(update_task->update_path), LFS_BACKUP_DEFAULT_FILENAME, backup_file_path);
|
||||
|
||||
update_task->state.total_stages = 1;
|
||||
update_task_set_progress(update_task, UpdateTaskStageLfsBackup, 0);
|
||||
/* to avoid bootloops */
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
|
||||
@@ -62,22 +61,18 @@ static bool update_task_post_update(UpdateTask* update_task) {
|
||||
string_t file_path;
|
||||
string_init(file_path);
|
||||
|
||||
/* status text is too long, too few stages to bother with a counter */
|
||||
update_task->state.total_stages = 0;
|
||||
|
||||
TarArchive* archive = tar_archive_alloc(update_task->storage);
|
||||
do {
|
||||
CHECK_RESULT(update_task_parse_manifest(update_task));
|
||||
path_concat(
|
||||
string_get_cstr(update_task->update_path), LFS_BACKUP_DEFAULT_FILENAME, file_path);
|
||||
|
||||
bool unpack_resources = !string_empty_p(update_task->manifest->resource_bundle);
|
||||
|
||||
update_task_set_progress(update_task, UpdateTaskStageLfsRestore, 0);
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
|
||||
update_operation_disarm();
|
||||
|
||||
CHECK_RESULT(lfs_backup_unpack(update_task->storage, string_get_cstr(file_path)));
|
||||
|
||||
if(unpack_resources) {
|
||||
if(update_task->state.groups & UpdateTaskStageGroupResources) {
|
||||
TarUnpackProgress progress = {
|
||||
.update_task = update_task,
|
||||
.total_files = 0,
|
||||
@@ -90,20 +85,19 @@ static bool update_task_post_update(UpdateTask* update_task) {
|
||||
string_get_cstr(update_task->manifest->resource_bundle),
|
||||
file_path);
|
||||
|
||||
TarArchive* archive = tar_archive_alloc(update_task->storage);
|
||||
tar_archive_set_file_callback(archive, update_task_resource_unpack_cb, &progress);
|
||||
success = tar_archive_open(archive, string_get_cstr(file_path), TAR_OPEN_MODE_READ);
|
||||
if(success) {
|
||||
progress.total_files = tar_archive_get_entries_count(archive);
|
||||
if(progress.total_files > 0) {
|
||||
tar_archive_unpack_to(archive, EXT_PATH);
|
||||
}
|
||||
CHECK_RESULT(
|
||||
tar_archive_open(archive, string_get_cstr(file_path), TAR_OPEN_MODE_READ));
|
||||
|
||||
progress.total_files = tar_archive_get_entries_count(archive);
|
||||
if(progress.total_files > 0) {
|
||||
CHECK_RESULT(tar_archive_unpack_to(archive, EXT_PATH));
|
||||
}
|
||||
tar_archive_free(archive);
|
||||
}
|
||||
success = true;
|
||||
} while(false);
|
||||
|
||||
tar_archive_free(archive);
|
||||
string_clear(file_path);
|
||||
return success;
|
||||
}
|
||||
@@ -116,18 +110,17 @@ int32_t update_task_worker_backup_restore(void* context) {
|
||||
FuriHalRtcBootMode boot_mode = furi_hal_rtc_get_boot_mode();
|
||||
if((boot_mode != FuriHalRtcBootModePreUpdate) && (boot_mode != FuriHalRtcBootModePostUpdate)) {
|
||||
/* no idea how we got here. Clear to normal boot */
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
|
||||
update_operation_disarm();
|
||||
return UPDATE_TASK_NOERR;
|
||||
}
|
||||
|
||||
update_task->state.current_stage_idx = 0;
|
||||
|
||||
if(!update_operation_get_current_package_path(update_task->storage, update_task->update_path)) {
|
||||
return UPDATE_TASK_FAILED;
|
||||
}
|
||||
|
||||
/* Waiting for BT service to 'start', so we don't race for boot mode */
|
||||
/* Waiting for BT service to 'start', so we don't race for boot mode flag */
|
||||
furi_record_open("bt");
|
||||
furi_record_close("bt");
|
||||
|
||||
if(boot_mode == FuriHalRtcBootModePreUpdate) {
|
||||
success = update_task_pre_update(update_task);
|
||||
@@ -135,13 +128,11 @@ int32_t update_task_worker_backup_restore(void* context) {
|
||||
success = update_task_post_update(update_task);
|
||||
}
|
||||
|
||||
furi_record_close("bt");
|
||||
|
||||
if(success) {
|
||||
update_task_set_progress(update_task, UpdateTaskStageCompleted, 100);
|
||||
} else {
|
||||
update_task_set_progress(update_task, UpdateTaskStageError, update_task->state.progress);
|
||||
if(!success) {
|
||||
update_task_set_progress(update_task, UpdateTaskStageError, 0);
|
||||
return UPDATE_TASK_FAILED;
|
||||
}
|
||||
|
||||
return success ? UPDATE_TASK_NOERR : UPDATE_TASK_FAILED;
|
||||
update_task_set_progress(update_task, UpdateTaskStageCompleted, 100);
|
||||
return UPDATE_TASK_NOERR;
|
||||
}
|
||||
|
Reference in New Issue
Block a user