b9a766d909
* Added support for running applications from SD card (FAPs - Flipper Application Packages) * Added plugin_dist target for fbt to build FAPs * All apps of type FlipperAppType.EXTERNAL and FlipperAppType.PLUGIN are built as FAPs by default * Updated VSCode configuration for new fbt features - re-deploy stock configuration to use them * Added debugging support for FAPs with fbt debug & VSCode * Added public firmware API with automated versioning Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: あく <alleteam@gmail.com>
108 lines
3.3 KiB
C
108 lines
3.3 KiB
C
#include "../updater_i.h"
|
|
#include "updater_scene.h"
|
|
|
|
#include <update_util/update_operation.h>
|
|
#include <furi_hal.h>
|
|
|
|
void updater_scene_loadcfg_apply_callback(GuiButtonType result, InputType type, void* context) {
|
|
furi_assert(context);
|
|
Updater* updater = context;
|
|
if(type != InputTypeShort) {
|
|
return;
|
|
}
|
|
|
|
if(result == GuiButtonTypeRight) {
|
|
view_dispatcher_send_custom_event(updater->view_dispatcher, UpdaterCustomEventStartUpdate);
|
|
} else if(result == GuiButtonTypeLeft) {
|
|
view_dispatcher_send_custom_event(
|
|
updater->view_dispatcher, UpdaterCustomEventCancelUpdate);
|
|
}
|
|
}
|
|
|
|
void updater_scene_loadcfg_on_enter(void* context) {
|
|
Updater* updater = (Updater*)context;
|
|
UpdaterManifestProcessingState* pending_upd = updater->pending_update =
|
|
malloc(sizeof(UpdaterManifestProcessingState));
|
|
pending_upd->manifest = update_manifest_alloc();
|
|
|
|
if(update_manifest_init(pending_upd->manifest, string_get_cstr(updater->startup_arg))) {
|
|
widget_add_string_element(
|
|
updater->widget, 64, 12, AlignCenter, AlignCenter, FontPrimary, "Update");
|
|
|
|
widget_add_text_box_element(
|
|
updater->widget,
|
|
5,
|
|
20,
|
|
118,
|
|
32,
|
|
AlignCenter,
|
|
AlignCenter,
|
|
string_get_cstr(pending_upd->manifest->version),
|
|
true);
|
|
|
|
widget_add_button_element(
|
|
updater->widget,
|
|
GuiButtonTypeRight,
|
|
"Install",
|
|
updater_scene_loadcfg_apply_callback,
|
|
updater);
|
|
} else {
|
|
widget_add_string_element(
|
|
updater->widget, 64, 24, AlignCenter, AlignCenter, FontPrimary, "Invalid manifest");
|
|
}
|
|
|
|
widget_add_button_element(
|
|
updater->widget,
|
|
GuiButtonTypeLeft,
|
|
"Cancel",
|
|
updater_scene_loadcfg_apply_callback,
|
|
updater);
|
|
|
|
view_dispatcher_switch_to_view(updater->view_dispatcher, UpdaterViewWidget);
|
|
}
|
|
|
|
bool updater_scene_loadcfg_on_event(void* context, SceneManagerEvent event) {
|
|
Updater* updater = (Updater*)context;
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeBack) {
|
|
view_dispatcher_stop(updater->view_dispatcher);
|
|
consumed = true;
|
|
} else if(event.type == SceneManagerEventTypeCustom) {
|
|
switch(event.event) {
|
|
case UpdaterCustomEventStartUpdate:
|
|
updater->preparation_result =
|
|
update_operation_prepare(string_get_cstr(updater->startup_arg));
|
|
if(updater->preparation_result == UpdatePrepareResultOK) {
|
|
furi_hal_power_reset();
|
|
} else {
|
|
#ifndef FURI_RAM_EXEC
|
|
scene_manager_next_scene(updater->scene_manager, UpdaterSceneError);
|
|
#endif
|
|
}
|
|
consumed = true;
|
|
break;
|
|
case UpdaterCustomEventCancelUpdate:
|
|
view_dispatcher_stop(updater->view_dispatcher);
|
|
consumed = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void updater_scene_loadcfg_on_exit(void* context) {
|
|
Updater* updater = (Updater*)context;
|
|
|
|
if(updater->pending_update) {
|
|
update_manifest_free(updater->pending_update->manifest);
|
|
string_clear(updater->pending_update->message);
|
|
}
|
|
|
|
widget_reset(updater->widget);
|
|
free(updater->pending_update);
|
|
}
|