@@ -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
244245static 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
254258static 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