1717#include "consent.h"
1818#include "../util/persist_keys.h"
1919#include "../util/style.h"
20+ #include "../version/version.h"
2021#include "../root_window.h"
2122
2223#include <pebble.h>
2324#include <pebble-events/pebble-events.h>
2425
26+
2527#define STAGE_LLM_WARNING 0
2628#define STAGE_GEMINI_CONSENT 1
2729#define STAGE_LOCATION_CONSENT 2
@@ -51,6 +53,7 @@ static void prv_present_consent_menu(Window* window);
5153static void prv_consent_menu_select_callback (ActionMenu * action_menu , const ActionMenuItem * action , void * context );
5254static void prv_action_menu_close (ActionMenu * action_menu , const ActionMenuItem * item , void * context );
5355static void prv_app_message_handler (DictionaryIterator * iter , void * context );
56+ static void prv_mark_consents_complete ();
5457
5558void consent_window_push () {
5659 Window * window = window_create ();
@@ -66,7 +69,24 @@ void consent_window_push() {
6669}
6770
6871bool must_present_consent () {
69- return !persist_exists (PERSIST_KEY_LOCATION_ENABLED );
72+ return persist_read_int (PERSIST_KEY_CONSENTS_COMPLETED ) < 1 ;
73+ }
74+
75+ void consent_migrate () {
76+ if (version_is_updated () && !version_is_first_launch ()) {
77+ // If we're updating from version 1.1 or older, consent agreement was implied by LOCATION_ENABLED being set
78+ // (either true or false).
79+ if (version_info_compare (version_get_last_launch (), (VersionInfo ) {1 , 1 }) <= 0 ) {
80+ APP_LOG (APP_LOG_LEVEL_INFO , "Performing consent migration from version 1.1." );
81+ // If the location enabled state is set, that's equivalent to consent agreement version 1.
82+ if (persist_exists (PERSIST_KEY_LOCATION_ENABLED )) {
83+ APP_LOG (APP_LOG_LEVEL_INFO , "Marking consent as 1." );;
84+ persist_write_int (PERSIST_KEY_CONSENTS_COMPLETED , 1 );
85+ } else {
86+ APP_LOG (APP_LOG_LEVEL_INFO , "Not marking consent." );;
87+ }
88+ }
89+ }
7090}
7191
7292static void prv_window_load (Window * window ) {
@@ -242,6 +262,7 @@ static void prv_app_message_handler(DictionaryIterator *iter, void *context) {
242262 events_app_message_unsubscribe (data -> app_message_handle );
243263 bool location_enabled = tuple -> value -> int16 ;
244264 persist_write_bool (PERSIST_KEY_LOCATION_ENABLED , location_enabled );
265+ prv_mark_consents_complete ();
245266 RootWindow * root_window = root_window_create ();
246267 action_menu_set_result_window (data -> action_menu , root_window_get_window (root_window ));
247268 action_menu_close (data -> action_menu , true);
@@ -251,3 +272,7 @@ static void prv_app_message_handler(DictionaryIterator *iter, void *context) {
251272static void prv_action_menu_close (ActionMenu * action_menu , const ActionMenuItem * item , void * context ) {
252273 action_menu_hierarchy_destroy (action_menu_get_root_level (action_menu ), NULL , NULL );
253274}
275+
276+ static void prv_mark_consents_complete () {
277+ persist_write_int (PERSIST_KEY_CONSENTS_COMPLETED , 1 );
278+ }
0 commit comments