mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-18 04:34:45 -07:00
Preload extmainapps
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "loader.h"
|
||||
#include "loader_i.h"
|
||||
#include "loader_menu.h"
|
||||
#include "loader_preload.h"
|
||||
#include <applications.h>
|
||||
#include <furi_hal.h>
|
||||
#include <core/dangerous_defines.h>
|
||||
@@ -147,29 +148,38 @@ static Loader* loader_alloc() {
|
||||
loader->app.insomniac = false;
|
||||
ExtMainAppList_init(loader->ext_main_apps);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FuriString* path = furi_string_alloc();
|
||||
FuriString* name = furi_string_alloc();
|
||||
Stream* stream = file_stream_alloc(storage);
|
||||
if(file_stream_open(stream, XTREME_APPS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
while(stream_read_line(stream, path)) {
|
||||
furi_string_replace_all(path, "\r", "");
|
||||
furi_string_replace_all(path, "\n", "");
|
||||
const Icon* icon;
|
||||
if(!loader_menu_load_fap_meta(storage, path, name, &icon)) continue;
|
||||
ExtMainAppList_push_back(
|
||||
loader->ext_main_apps,
|
||||
(ExtMainApp){
|
||||
.name = strdup(furi_string_get_cstr(name)),
|
||||
.path = strdup(furi_string_get_cstr(path)),
|
||||
.icon = icon});
|
||||
if(furi_hal_is_normal_boot()) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) {
|
||||
if(FLIPPER_APPS[i].app != NULL) continue;
|
||||
if(storage_common_exists(storage, FLIPPER_APPS[i].appid)) {
|
||||
void* preload = loader_preload(storage, FLIPPER_APPS[i].appid);
|
||||
FLIPPER_APPS[i].preload = preload;
|
||||
}
|
||||
}
|
||||
FuriString* path = furi_string_alloc();
|
||||
FuriString* name = furi_string_alloc();
|
||||
Stream* stream = file_stream_alloc(storage);
|
||||
if(file_stream_open(stream, XTREME_APPS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
while(stream_read_line(stream, path)) {
|
||||
furi_string_replace_all(path, "\r", "");
|
||||
furi_string_replace_all(path, "\n", "");
|
||||
const Icon* icon;
|
||||
if(!loader_menu_load_fap_meta(storage, path, name, &icon)) continue;
|
||||
ExtMainAppList_push_back(
|
||||
loader->ext_main_apps,
|
||||
(ExtMainApp){
|
||||
.name = strdup(furi_string_get_cstr(name)),
|
||||
.path = strdup(furi_string_get_cstr(path)),
|
||||
.icon = icon});
|
||||
}
|
||||
}
|
||||
file_stream_close(stream);
|
||||
stream_free(stream);
|
||||
furi_string_free(name);
|
||||
furi_string_free(path);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
file_stream_close(stream);
|
||||
stream_free(stream);
|
||||
furi_string_free(name);
|
||||
furi_string_free(path);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return loader;
|
||||
}
|
||||
|
||||
@@ -214,6 +224,10 @@ static void
|
||||
FURI_LOG_I(TAG, "Starting %s", app->name);
|
||||
|
||||
if(app->app == NULL) {
|
||||
if(app->preload != NULL) {
|
||||
loader_preload_start(app->preload, app->appid);
|
||||
return;
|
||||
}
|
||||
args = app->appid;
|
||||
app = loader_find_application_by_name_in_list(
|
||||
FAP_LOADER_APP_NAME, FLIPPER_APPS, FLIPPER_APPS_COUNT);
|
||||
|
||||
Reference in New Issue
Block a user