diff options
author | あく <alleteam@gmail.com> | 2022-04-15 19:31:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-15 19:31:25 +0300 |
commit | c209ec56fc0b5efe6c91d44a8663206b15f15b09 (patch) | |
tree | fddd2e6e5c3dc8763109487ec2b26b20c4ffdea8 /applications | |
parent | 9b654332113629f24b04b48b61e2c43c91a66fa8 (diff) |
Release Candidate Bug Fixes and Improvements (#1121)
* Notification: use all input for backlight, otherwise it is causing issues on repeat. Dolphin: rework debug tools.
* Notification: remove unused variable
* Applications: fix incorrect count in system apps list
* SubGhz: fix memory leak in settings
* SubGhz: fix incorrect frequency in newly created keys
* Loader: make cli command parallel safe
Diffstat (limited to 'applications')
-rw-r--r-- | applications/applications.c | 16 | ||||
-rw-r--r-- | applications/desktop/scenes/desktop_scene_debug.c | 4 | ||||
-rw-r--r-- | applications/desktop/views/desktop_view_debug.c | 14 | ||||
-rw-r--r-- | applications/dolphin/helpers/dolphin_deed.h | 5 | ||||
-rw-r--r-- | applications/dolphin/helpers/dolphin_state.c | 17 | ||||
-rw-r--r-- | applications/loader/loader.c | 9 | ||||
-rw-r--r-- | applications/notification/notification_app.c | 5 | ||||
-rw-r--r-- | applications/subghz/scenes/subghz_scene_read_raw.c | 3 | ||||
-rw-r--r-- | applications/subghz/scenes/subghz_scene_receiver.c | 3 | ||||
-rw-r--r-- | applications/subghz/scenes/subghz_scene_receiver_config.c | 12 | ||||
-rw-r--r-- | applications/subghz/scenes/subghz_scene_set_type.c | 4 | ||||
-rw-r--r-- | applications/subghz/subghz.c | 3 | ||||
-rw-r--r-- | applications/subghz/subghz_i.c | 2 | ||||
-rw-r--r-- | applications/subghz/subghz_setting.c | 44 | ||||
-rw-r--r-- | applications/subghz/subghz_setting.h | 9 |
15 files changed, 92 insertions, 58 deletions
diff --git a/applications/applications.c b/applications/applications.c index d5e7efd7..aba50fee 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -131,7 +131,7 @@ const FlipperApplication FLIPPER_SERVICES[] = { #endif }; -const size_t FLIPPER_SERVICES_COUNT = sizeof(FLIPPER_SERVICES) / sizeof(FlipperApplication); +const size_t FLIPPER_SERVICES_COUNT = COUNT_OF(FLIPPER_SERVICES); const FlipperApplication FLIPPER_SYSTEM_APPS[] = { #ifdef APP_UPDATER @@ -142,7 +142,7 @@ const FlipperApplication FLIPPER_SYSTEM_APPS[] = { #endif }; -const size_t FLIPPER_SYSTEM_APPS_COUNT = sizeof(FLIPPER_SERVICES) / sizeof(FlipperApplication); +const size_t FLIPPER_SYSTEM_APPS_COUNT = COUNT_OF(FLIPPER_SYSTEM_APPS); // Main menu APP const FlipperApplication FLIPPER_APPS[] = { @@ -181,7 +181,7 @@ const FlipperApplication FLIPPER_APPS[] = { }; -const size_t FLIPPER_APPS_COUNT = sizeof(FLIPPER_APPS) / sizeof(FlipperApplication); +const size_t FLIPPER_APPS_COUNT = COUNT_OF(FLIPPER_APPS); // On system start hooks const FlipperOnStartHook FLIPPER_ON_SYSTEM_START[] = { @@ -228,8 +228,7 @@ const FlipperOnStartHook FLIPPER_ON_SYSTEM_START[] = { #endif }; -const size_t FLIPPER_ON_SYSTEM_START_COUNT = - sizeof(FLIPPER_ON_SYSTEM_START) / sizeof(FlipperOnStartHook); +const size_t FLIPPER_ON_SYSTEM_START_COUNT = COUNT_OF(FLIPPER_ON_SYSTEM_START); // Plugin menu const FlipperApplication FLIPPER_PLUGINS[] = { @@ -246,7 +245,7 @@ const FlipperApplication FLIPPER_PLUGINS[] = { #endif }; -const size_t FLIPPER_PLUGINS_COUNT = sizeof(FLIPPER_PLUGINS) / sizeof(FlipperApplication); +const size_t FLIPPER_PLUGINS_COUNT = COUNT_OF(FLIPPER_PLUGINS); // Plugin menu const FlipperApplication FLIPPER_DEBUG_APPS[] = { @@ -307,7 +306,7 @@ const FlipperApplication FLIPPER_DEBUG_APPS[] = { #endif }; -const size_t FLIPPER_DEBUG_APPS_COUNT = sizeof(FLIPPER_DEBUG_APPS) / sizeof(FlipperApplication); +const size_t FLIPPER_DEBUG_APPS_COUNT = COUNT_OF(FLIPPER_DEBUG_APPS); #ifdef APP_ARCHIVE const FlipperApplication FLIPPER_ARCHIVE = @@ -352,5 +351,4 @@ const FlipperApplication FLIPPER_SETTINGS_APPS[] = { #endif }; -const size_t FLIPPER_SETTINGS_APPS_COUNT = - sizeof(FLIPPER_SETTINGS_APPS) / sizeof(FlipperApplication);
\ No newline at end of file +const size_t FLIPPER_SETTINGS_APPS_COUNT = COUNT_OF(FLIPPER_SETTINGS_APPS); diff --git a/applications/desktop/scenes/desktop_scene_debug.c b/applications/desktop/scenes/desktop_scene_debug.c index 99fcad87..4945f7ac 100644 --- a/applications/desktop/scenes/desktop_scene_debug.c +++ b/applications/desktop/scenes/desktop_scene_debug.c @@ -34,13 +34,13 @@ bool desktop_scene_debug_on_event(void* context, SceneManagerEvent event) { break; case DesktopDebugEventDeed: - dolphin_deed(dolphin, DolphinDeedIbuttonEmulate); + dolphin_deed(dolphin, DolphinDeedTestRight); desktop_debug_get_dolphin_data(desktop->debug_view); consumed = true; break; case DesktopDebugEventWrongDeed: - dolphin_deed(dolphin, DolphinDeedIbuttonRead); + dolphin_deed(dolphin, DolphinDeedTestLeft); desktop_debug_get_dolphin_data(desktop->debug_view); consumed = true; break; diff --git a/applications/desktop/views/desktop_view_debug.c b/applications/desktop/views/desktop_view_debug.c index 75a9bab1..6ac62b49 100644 --- a/applications/desktop/views/desktop_view_debug.c +++ b/applications/desktop/views/desktop_view_debug.c @@ -111,7 +111,10 @@ bool desktop_debug_input(InputEvent* event, void* context) { DesktopDebugView* debug_view = context; - if(event->type != InputTypeShort) return false; + if(event->type != InputTypeShort && event->type != InputTypeRepeat) { + return false; + } + DesktopViewStatsScreens current = 0; with_view_model( debug_view->view, (DesktopDebugViewModel * model) { @@ -125,11 +128,16 @@ bool desktop_debug_input(InputEvent* event, void* context) { return true; }); + size_t count = (event->type == InputTypeRepeat) ? 10 : 1; if(current == DesktopViewStatsMeta) { if(event->key == InputKeyLeft) { - debug_view->callback(DesktopDebugEventWrongDeed, debug_view->context); + while(count-- > 0) { + debug_view->callback(DesktopDebugEventWrongDeed, debug_view->context); + } } else if(event->key == InputKeyRight) { - debug_view->callback(DesktopDebugEventDeed, debug_view->context); + while(count-- > 0) { + debug_view->callback(DesktopDebugEventDeed, debug_view->context); + } } else if(event->key == InputKeyOk) { debug_view->callback(DesktopDebugEventSaveState, debug_view->context); } else { diff --git a/applications/dolphin/helpers/dolphin_deed.h b/applications/dolphin/helpers/dolphin_deed.h index 20e18d70..1f63db3f 100644 --- a/applications/dolphin/helpers/dolphin_deed.h +++ b/applications/dolphin/helpers/dolphin_deed.h @@ -52,7 +52,10 @@ typedef enum { DolphinDeedU2fAuthorized, - DolphinDeedMAX + DolphinDeedMAX, + + DolphinDeedTestLeft, + DolphinDeedTestRight, } DolphinDeed; typedef struct { diff --git a/applications/dolphin/helpers/dolphin_state.c b/applications/dolphin/helpers/dolphin_state.c index 08a7dae3..bfd467b8 100644 --- a/applications/dolphin/helpers/dolphin_state.c +++ b/applications/dolphin/helpers/dolphin_state.c @@ -126,6 +126,23 @@ uint32_t dolphin_state_xp_to_levelup(uint32_t icounter) { } void dolphin_state_on_deed(DolphinState* dolphin_state, DolphinDeed deed) { + // Special case for testing + if(deed > DolphinDeedMAX) { + if(deed == DolphinDeedTestLeft) { + dolphin_state->data.butthurt = + CLAMP(dolphin_state->data.butthurt + 1, BUTTHURT_MAX, BUTTHURT_MIN); + if(dolphin_state->data.icounter > 0) dolphin_state->data.icounter--; + dolphin_state->data.timestamp = dolphin_state_timestamp(); + dolphin_state->dirty = true; + } else if(deed == DolphinDeedTestRight) { + dolphin_state->data.butthurt = BUTTHURT_MIN; + if(dolphin_state->data.icounter < UINT32_MAX) dolphin_state->data.icounter++; + dolphin_state->data.timestamp = dolphin_state_timestamp(); + dolphin_state->dirty = true; + } + return; + } + DolphinApp app = dolphin_deed_get_app(deed); int8_t weight_limit = dolphin_deed_get_app_limit(app) - dolphin_state->data.icounter_daily_limit[app]; diff --git a/applications/loader/loader.c b/applications/loader/loader.c index 054562a2..dafe255a 100644 --- a/applications/loader/loader.c +++ b/applications/loader/loader.c @@ -101,6 +101,11 @@ const FlipperApplication* loader_find_application_by_name(const char* name) { } void loader_cli_open(Cli* cli, string_t args, Loader* instance) { + if(loader_is_locked(instance)) { + printf("Can't start, furi application is running"); + return; + } + string_t application_name; string_init(application_name); @@ -292,7 +297,7 @@ static Loader* loader_alloc() { #ifdef SRV_CLI instance->cli = furi_record_open("cli"); - cli_add_command(instance->cli, "loader", CliCommandFlagDefault, loader_cli, instance); + cli_add_command(instance->cli, "loader", CliCommandFlagParallelSafe, loader_cli, instance); #else UNUSED(loader_cli); #endif @@ -488,4 +493,4 @@ int32_t loader_srv(void* p) { FuriPubSub* loader_get_pubsub(Loader* instance) { return instance->pubsub; -}
\ No newline at end of file +} diff --git a/applications/notification/notification_app.c b/applications/notification/notification_app.c index 447bf903..1e2e2dde 100644 --- a/applications/notification/notification_app.c +++ b/applications/notification/notification_app.c @@ -418,11 +418,8 @@ static bool notification_save_settings(NotificationApp* app) { static void input_event_callback(const void* value, void* context) { furi_assert(value); furi_assert(context); - const InputEvent* event = value; NotificationApp* app = context; - if(event->type == InputTypePress) { - notification_message(app, &sequence_display_on); - } + notification_message(app, &sequence_display_on); } // App alloc diff --git a/applications/subghz/scenes/subghz_scene_read_raw.c b/applications/subghz/scenes/subghz_scene_read_raw.c index cbd64f8f..10248c35 100644 --- a/applications/subghz/scenes/subghz_scene_read_raw.c +++ b/applications/subghz/scenes/subghz_scene_read_raw.c @@ -127,8 +127,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving); } else { //Restore default setting - subghz->txrx->frequency = subghz_setting_get_frequency( - subghz->setting, subghz_setting_get_frequency_default_index(subghz->setting)); + subghz->txrx->frequency = subghz_setting_get_default_frequency(subghz->setting); subghz->txrx->preset = FuriHalSubGhzPresetOok650Async; if(!scene_manager_search_and_switch_to_previous_scene( subghz->scene_manager, SubGhzSceneSaved)) { diff --git a/applications/subghz/scenes/subghz_scene_receiver.c b/applications/subghz/scenes/subghz_scene_receiver.c index 8a5ee921..7183410b 100644 --- a/applications/subghz/scenes/subghz_scene_receiver.c +++ b/applications/subghz/scenes/subghz_scene_receiver.c @@ -120,8 +120,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { subghz_sleep(subghz); }; subghz->txrx->hopper_state = SubGhzHopperStateOFF; - subghz->txrx->frequency = subghz_setting_get_frequency( - subghz->setting, subghz_setting_get_frequency_default_index(subghz->setting)); + subghz->txrx->frequency = subghz_setting_get_default_frequency(subghz->setting); subghz->txrx->preset = FuriHalSubGhzPresetOok650Async; subghz->txrx->idx_menu_chosen = 0; subghz_receiver_set_rx_callback(subghz->txrx->receiver, NULL, subghz); diff --git a/applications/subghz/scenes/subghz_scene_receiver_config.c b/applications/subghz/scenes/subghz_scene_receiver_config.c index f2ae749f..d98f45af 100644 --- a/applications/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/subghz/scenes/subghz_scene_receiver_config.c @@ -111,19 +111,13 @@ static void subghz_scene_receiver_config_set_hopping_runing(VariableItem* item) sprintf( text_buf, "%lu.%02lu", - subghz_setting_get_frequency( - subghz->setting, subghz_setting_get_frequency_default_index(subghz->setting)) / - 1000000, - (subghz_setting_get_frequency( - subghz->setting, subghz_setting_get_frequency_default_index(subghz->setting)) % - 1000000) / - 10000); + subghz_setting_get_default_frequency(subghz->setting) / 1000000, + (subghz_setting_get_default_frequency(subghz->setting) % 1000000) / 10000); variable_item_set_current_value_text( (VariableItem*)scene_manager_get_scene_state( subghz->scene_manager, SubGhzSceneReceiverConfig), text_buf); - subghz->txrx->frequency = subghz_setting_get_frequency( - subghz->setting, subghz_setting_get_frequency_default_index(subghz->setting)); + subghz->txrx->frequency = subghz_setting_get_default_frequency(subghz->setting); variable_item_set_current_value_index( (VariableItem*)scene_manager_get_scene_state( subghz->scene_manager, SubGhzSceneReceiverConfig), diff --git a/applications/subghz/scenes/subghz_scene_set_type.c b/applications/subghz/scenes/subghz_scene_set_type.c index 4fb36467..22a15143 100644 --- a/applications/subghz/scenes/subghz_scene_set_type.c +++ b/applications/subghz/scenes/subghz_scene_set_type.c @@ -46,7 +46,7 @@ bool subghz_scene_set_type_submenu_gen_data_protocol( if(!subghz_protocol_decoder_base_serialize( subghz->txrx->decoder_result, subghz->txrx->fff_data, - subghz_setting_get_frequency_default_index(subghz->setting), + subghz_setting_get_default_frequency(subghz->setting), FuriHalSubGhzPresetOok650Async)) { FURI_LOG_E(TAG, "Unable to serialize"); break; @@ -213,7 +213,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { 0x2, 0x0003, "DoorHan", - subghz_setting_get_frequency_default_index(subghz->setting), + subghz_setting_get_default_frequency(subghz->setting), FuriHalSubGhzPresetOok650Async); generated_protocol = true; } else { diff --git a/applications/subghz/subghz.c b/applications/subghz/subghz.c index 80c69734..5a59d89b 100644 --- a/applications/subghz/subghz.c +++ b/applications/subghz/subghz.c @@ -130,8 +130,7 @@ SubGhz* subghz_alloc() { //init Worker & Protocol & History subghz->txrx = malloc(sizeof(SubGhzTxRx)); - subghz->txrx->frequency = subghz_setting_get_frequency( - subghz->setting, subghz_setting_get_frequency_default_index(subghz->setting)); + subghz->txrx->frequency = subghz_setting_get_default_frequency(subghz->setting); subghz->txrx->preset = FuriHalSubGhzPresetOok650Async; subghz->txrx->txrx_state = SubGhzTxRxStateSleep; subghz->txrx->hopper_state = SubGhzHopperStateOFF; diff --git a/applications/subghz/subghz_i.c b/applications/subghz/subghz_i.c index 5740ea9d..60938d17 100644 --- a/applications/subghz/subghz_i.c +++ b/applications/subghz/subghz_i.c @@ -246,7 +246,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) { break; } - if(!flipper_format_read_uint32(fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) { + if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { FURI_LOG_E(TAG, "Missing Frequency"); break; } diff --git a/applications/subghz/subghz_setting.c b/applications/subghz/subghz_setting.c index 98a8a16e..4d40d49e 100644 --- a/applications/subghz/subghz_setting.c +++ b/applications/subghz/subghz_setting.c @@ -152,12 +152,11 @@ static const uint32_t subghz_hopper_frequencies_region_jp[] = { }; static const uint32_t subghz_frequency_default_index_region_jp = 9; -LIST_DEF(frequencies_list, uint32_t) -LIST_DEF(hopper_frequencies_list, uint32_t) +LIST_DEF(FrequenciesList, uint32_t) struct SubGhzSetting { - frequencies_list_t frequencies; - hopper_frequencies_list_t hopper_frequencies; + FrequenciesList_t frequencies; + FrequenciesList_t hopper_frequencies; size_t frequencies_count; size_t hopper_frequencies_count; uint32_t frequency_default_index; @@ -165,15 +164,15 @@ struct SubGhzSetting { SubGhzSetting* subghz_setting_alloc(void) { SubGhzSetting* instance = malloc(sizeof(SubGhzSetting)); - frequencies_list_init(instance->frequencies); - hopper_frequencies_list_init(instance->hopper_frequencies); + FrequenciesList_init(instance->frequencies); + FrequenciesList_init(instance->hopper_frequencies); return instance; } void subghz_setting_free(SubGhzSetting* instance) { furi_assert(instance); - frequencies_list_clear(instance->frequencies); - hopper_frequencies_list_clear(instance->hopper_frequencies); + FrequenciesList_clear(instance->frequencies); + FrequenciesList_clear(instance->hopper_frequencies); free(instance); } @@ -184,18 +183,18 @@ void subghz_setting_load_default( const uint32_t frequency_default_index) { furi_assert(instance); size_t i = 0; - frequencies_list_clear(instance->frequencies); - hopper_frequencies_list_clear(instance->hopper_frequencies); + FrequenciesList_clear(instance->frequencies); + FrequenciesList_clear(instance->hopper_frequencies); i = 0; while(frequencies[i]) { - frequencies_list_push_back(instance->frequencies, frequencies[i]); + FrequenciesList_push_back(instance->frequencies, frequencies[i]); i++; } instance->frequencies_count = i; i = 0; while(hopper_frequencies[i]) { - hopper_frequencies_list_push_back(instance->hopper_frequencies, hopper_frequencies[i]); + FrequenciesList_push_back(instance->hopper_frequencies, hopper_frequencies[i]); i++; } instance->hopper_frequencies_count = i; @@ -206,8 +205,8 @@ void subghz_setting_load_default( void subghz_setting_load(SubGhzSetting* instance, const char* file_path) { furi_assert(instance); - frequencies_list_clear(instance->frequencies); - hopper_frequencies_list_clear(instance->hopper_frequencies); + FrequenciesList_clear(instance->frequencies); + FrequenciesList_clear(instance->hopper_frequencies); Storage* storage = furi_record_open("storage"); FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); @@ -246,7 +245,7 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) { fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) { if(furi_hal_subghz_is_frequency_valid(temp_data32)) { FURI_LOG_I(TAG, "Frequency loaded %lu", temp_data32); - frequencies_list_push_back(instance->frequencies, temp_data32); + FrequenciesList_push_back(instance->frequencies, temp_data32); i++; } else { FURI_LOG_E(TAG, "Frequency not supported %lu", temp_data32); @@ -263,7 +262,7 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) { fff_data_file, "Hopper_frequency", (uint32_t*)&temp_data32, 1)) { if(furi_hal_subghz_is_frequency_valid(temp_data32)) { FURI_LOG_I(TAG, "Hopper frequency loaded %lu", temp_data32); - hopper_frequencies_list_push_back(instance->hopper_frequencies, temp_data32); + FrequenciesList_push_back(instance->hopper_frequencies, temp_data32); i++; } else { FURI_LOG_E(TAG, "Hopper frequency not supported %lu", temp_data32); @@ -297,6 +296,8 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) { } } while(false); } + + string_clear(temp_str); flipper_format_free(fff_data_file); furi_record_close("storage"); @@ -347,15 +348,20 @@ size_t subghz_setting_get_hopper_frequency_count(SubGhzSetting* instance) { uint32_t subghz_setting_get_frequency(SubGhzSetting* instance, size_t idx) { furi_assert(instance); - return *frequencies_list_get(instance->frequencies, idx); + return *FrequenciesList_get(instance->frequencies, idx); } uint32_t subghz_setting_get_hopper_frequency(SubGhzSetting* instance, size_t idx) { furi_assert(instance); - return *hopper_frequencies_list_get(instance->hopper_frequencies, idx); + return *FrequenciesList_get(instance->hopper_frequencies, idx); } uint32_t subghz_setting_get_frequency_default_index(SubGhzSetting* instance) { furi_assert(instance); return instance->frequency_default_index; -}
\ No newline at end of file +} + +uint32_t subghz_setting_get_default_frequency(SubGhzSetting* instance) { + furi_assert(instance); + return *FrequenciesList_get(instance->frequencies, instance->frequency_default_index); +} diff --git a/applications/subghz/subghz_setting.h b/applications/subghz/subghz_setting.h index cdf60797..58a898c5 100644 --- a/applications/subghz/subghz_setting.h +++ b/applications/subghz/subghz_setting.h @@ -8,10 +8,19 @@ typedef struct SubGhzSetting SubGhzSetting; SubGhzSetting* subghz_setting_alloc(void); + void subghz_setting_free(SubGhzSetting* instance); + void subghz_setting_load(SubGhzSetting* instance, const char* file_path); + size_t subghz_setting_get_frequency_count(SubGhzSetting* instance); + size_t subghz_setting_get_hopper_frequency_count(SubGhzSetting* instance); + uint32_t subghz_setting_get_frequency(SubGhzSetting* instance, size_t idx); + uint32_t subghz_setting_get_hopper_frequency(SubGhzSetting* instance, size_t idx); + uint32_t subghz_setting_get_frequency_default_index(SubGhzSetting* instance); + +uint32_t subghz_setting_get_default_frequency(SubGhzSetting* instance); |