Allow api mismatch bypass again :C

for those who explicitly doesn't update their manually installed apps and want to ignore warnings and issues caused by using outdated apps
This commit is contained in:
MX 2023-06-29 05:38:44 +03:00
parent 5e2d01f159
commit 380734f804
No known key found for this signature in database
GPG key ID: 7CCC66B7DBDD1C83
2 changed files with 41 additions and 6 deletions

View file

@ -254,7 +254,8 @@ static LoaderStatus loader_start_external_app(
Storage* storage, Storage* storage,
const char* path, const char* path,
const char* args, const char* args,
FuriString* error_message) { FuriString* error_message,
bool ignore_mismatch) {
LoaderStatus status = loader_make_success_status(error_message); LoaderStatus status = loader_make_success_status(error_message);
do { do {
@ -266,10 +267,38 @@ static LoaderStatus loader_start_external_app(
FlipperApplicationPreloadStatus preload_res = FlipperApplicationPreloadStatus preload_res =
flipper_application_preload(loader->app.fap, path); flipper_application_preload(loader->app.fap, path);
if(preload_res != FlipperApplicationPreloadStatusSuccess) { if(preload_res != FlipperApplicationPreloadStatusSuccess) {
const char* err_msg = flipper_application_preload_status_to_string(preload_res); if(preload_res == FlipperApplicationPreloadStatusApiMismatch) {
status = loader_make_status_error( if(!ignore_mismatch) {
LoaderStatusErrorInternal, error_message, "Preload failed %s: %s", path, err_msg); DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
break; DialogMessage* message = dialog_message_alloc();
dialog_message_set_header(
message, "API Mismatch", 64, 0, AlignCenter, AlignTop);
dialog_message_set_buttons(message, "Cancel", NULL, "Continue");
dialog_message_set_text(
message,
"This app might not\nwork correctly\nContinue anyways?",
64,
32,
AlignCenter,
AlignCenter);
if(dialog_message_show(dialogs, message) == DialogMessageButtonRight) {
status = loader_make_status_error(
LoaderStatusErrorApiMismatch, error_message, "API Mismatch");
}
dialog_message_free(message);
furi_record_close(RECORD_DIALOGS);
break;
}
} else {
const char* err_msg = flipper_application_preload_status_to_string(preload_res);
status = loader_make_status_error(
LoaderStatusErrorInternal,
error_message,
"Preload failed %s: %s",
path,
err_msg);
break;
}
} }
FURI_LOG_I(TAG, "Mapping"); FURI_LOG_I(TAG, "Mapping");
@ -383,7 +412,12 @@ static LoaderStatus loader_do_start_by_name(
{ {
Storage* storage = furi_record_open(RECORD_STORAGE); Storage* storage = furi_record_open(RECORD_STORAGE);
if(storage_file_exists(storage, name)) { if(storage_file_exists(storage, name)) {
status = loader_start_external_app(loader, storage, name, args, error_message); status =
loader_start_external_app(loader, storage, name, args, error_message, false);
if(status == LoaderStatusErrorApiMismatch) {
status = loader_start_external_app(
loader, storage, name, args, error_message, true);
}
furi_record_close(RECORD_STORAGE); furi_record_close(RECORD_STORAGE);
break; break;
} }

View file

@ -15,6 +15,7 @@ typedef enum {
LoaderStatusErrorAppStarted, LoaderStatusErrorAppStarted,
LoaderStatusErrorUnknownApp, LoaderStatusErrorUnknownApp,
LoaderStatusErrorInternal, LoaderStatusErrorInternal,
LoaderStatusErrorApiMismatch,
} LoaderStatus; } LoaderStatus;
typedef enum { typedef enum {