Skip to content

Commit 143b626

Browse files
committed
Fix crash when saving settings page during consents.
Signed-off-by: Katharine Berry <[email protected]>
1 parent 9c35ea4 commit 143b626

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/src/c/consent/consent.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ typedef struct {
3939
BitmapLayer* select_indicator_layer;
4040
ActionMenu* action_menu;
4141
int stage;
42+
int expected_app_response;
4243
EventHandle app_message_handle;
4344
} ConsentWindowData;
4445

@@ -242,6 +243,9 @@ static void prv_present_consent_menu(Window* window) {
242243
}
243244

244245
static void prv_consent_menu_select_callback(ActionMenu *action_menu, const ActionMenuItem *action, void *context) {
246+
Window *window = context;
247+
ConsentWindowData *data = window_get_user_data(window);
248+
data->expected_app_response = STAGE_LOCATION_CONSENT;
245249
bool choice = (int)action_menu_item_get_action_data(action);
246250
action_menu_freeze(action_menu);
247251
// We need to inform the phone of the user's choice.
@@ -254,10 +258,15 @@ static void prv_consent_menu_select_callback(ActionMenu *action_menu, const Acti
254258
static void prv_app_message_handler(DictionaryIterator *iter, void *context) {
255259
Window* window = context;
256260
ConsentWindowData* data = window_get_user_data(window);
261+
if (data->expected_app_response != STAGE_LOCATION_CONSENT) {
262+
APP_LOG(APP_LOG_LEVEL_WARNING, "Ignoring unexpected location consent response.");
263+
return;
264+
}
257265
Tuple *tuple = dict_find(iter, MESSAGE_KEY_LOCATION_ENABLED);
258266
if (tuple == NULL) {
259267
return;
260268
}
269+
data->expected_app_response = 0;
261270
APP_LOG(APP_LOG_LEVEL_INFO, "Got location enabled reply, dismissing dialog.");
262271
events_app_message_unsubscribe(data->app_message_handle);
263272
bool location_enabled = tuple->value->int16;

0 commit comments

Comments
 (0)