You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
} else { // existingEndTimeInKeystore is null but isAwaitingFirstInternet is false
83
-
Log.d(TAG, "Trial not started: Not awaiting first internet, but no Keystore alias found. This might mean Keystore was cleared or failed to save previously.")
84
-
// This state implies something went wrong. It might be best to revert to awaiting state
85
-
// if we expect a trial to be possible. For now, just logging.
75
+
} else {
76
+
Log.d(TAG, "Trial not started: Not awaiting first internet (flag is false), but no Keystore alias found. This might mean Keystore was cleared or failed to save previously.")
86
77
}
87
78
}
88
79
}
@@ -97,23 +88,28 @@ object TrialManager {
97
88
}
98
89
99
90
val isAwaitingFirstInternetTime = prefs.getBoolean(KEY_TRIAL_AWAITING_FIRST_INTERNET_TIME, true)
100
-
val trialUtcEndTime = getTrialEndTimeFromKeystore(context)// Retrieve from Keystore
101
-
val confirmedExpired = prefs.getBoolean(KEY_TRIAL_CONFIRMED_EXPIRED, false)
Log.d(TAG, "getTrialState: Returning NOT_YET_STARTED_AWAITING_INTERNET (no Keystore alias, awaiting internet, not confirmed expired)")
106
+
Log.d(TAG, "getTrialState: Returning NOT_YET_STARTED_AWAITING_INTERNET (no Keystore alias, awaiting internet)")
113
107
TrialState.NOT_YET_STARTED_AWAITING_INTERNET
114
108
} else {
115
-
// If trialUtcEndTime exists OR not awaiting, but no current time to verify.
116
-
Log.d(TAG, "getTrialState: Returning INTERNET_UNAVAILABLE_CANNOT_VERIFY (Keystore alias might exist or not awaiting, but no current time, not confirmed expired)")
109
+
// This means either trial has started (endTime exists in Keystore) or it's not awaiting first internet,
110
+
// but we don't have current time to check. Or, endTime is null but we are not awaiting (inconsistent state).
111
+
// Or, Keystore has an end time which *might* be expired, but we can't be sure without current time.
112
+
Log.d(TAG, "getTrialState: Returning INTERNET_UNAVAILABLE_CANNOT_VERIFY (Keystore alias might exist or not awaiting, but no current time)")
// This implies prefs say trial started (not awaiting), but Keystore has no record.
130
-
// This could happen if Keystore entry was cleared or failed to save.
131
125
Log.e(TAG, "INCONSISTENCY: Trial marked as started (not awaiting internet in prefs), but no trial end time alias found in Keystore. Resetting to await internet.")
// No longer setting KEY_TRIAL_CONFIRMED_EXPIRED flag here. Expiry is purely based on time comparison.
147
140
TrialState.EXPIRED_INTERNET_TIME_CONFIRMED
148
141
}
149
142
}
150
143
else-> {
151
-
// Should not be reached if logic above is exhaustive.
152
144
Log.e(TAG, "Unhandled case in getTrialState. isAwaiting: $isAwaitingFirstInternetTime, endTimeFromKeystore: $trialUtcEndTime, currentTime: $currentUtcTimeMs. Defaulting to NOT_YET_STARTED_AWAITING_INTERNET.")
153
145
TrialState.NOT_YET_STARTED_AWAITING_INTERNET
154
146
}
@@ -160,11 +152,11 @@ object TrialManager {
160
152
val editor = getSharedPreferences(context).edit()
161
153
162
154
Log.d(TAG, "Deleting trial timestamp alias(es) from Keystore.")
0 commit comments