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
Log.d(TAG, "Attempting to parse dateTime string $currentDateTimeStr as LocalDateTime and applying UTC offset.") // New Log
115
-
// Parse ISO 8601 string to milliseconds since epoch
116
-
val currentUtcTimeMs =LocalDateTime.parse(currentDateTimeStr).atOffset(ZoneOffset.UTC).toInstant().toEpochMilli() // Modified Line
111
+
Log.d(TAG, "Attempting to parse dateTime string $currentDateTimeStr as LocalDateTime and applying UTC offset.")
112
+
val currentUtcTimeMs =LocalDateTime.parse(currentDateTimeStr).atOffset(ZoneOffset.UTC).toInstant().toEpochMilli()
117
113
118
-
Log.i(TAG, "Successfully parsed dateTime string $currentDateTimeStr to UTC milliseconds: $currentUtcTimeMs using LocalDateTime.parse().atOffset(ZoneOffset.UTC)") // Modified Log
114
+
Log.i(TAG, "Successfully parsed dateTime string $currentDateTimeStr to UTC milliseconds: $currentUtcTimeMs using LocalDateTime.parse().atOffset(ZoneOffset.UTC)")
119
115
120
116
val trialState =TrialManager.getTrialState(applicationContext, currentUtcTimeMs)
121
117
Log.i(TAG, "Current trial state from TrialManager: $trialState (based on time $currentUtcTimeMs)")
@@ -132,20 +128,22 @@ class TrialTimerService : Service() {
// This case should ideally not be returned by TrialManager if currentUtcTimeMs is available.
139
+
// However, if it does occur, it implies an issue. We broadcast available time.
142
140
Log.w(TAG, "TrialState: INTERNET_UNAVAILABLE_CANNOT_VERIFY from TrialManager, but we just fetched time. This is unexpected. Broadcasting ACTION_INTERNET_TIME_AVAILABLE anyway.")
Log.e(TAG, "Failed to fetch internet time. HTTP Response code: $responseCode - $responseMessage")
151
149
connection.disconnect()
@@ -159,22 +157,22 @@ class TrialTimerService : Service() {
159
157
} catch (e:SocketTimeoutException) {
160
158
Log.e(TAG, "Failed to fetch internet time: Socket Timeout after $CONNECTION_TIMEOUT_MS ms (connect) or $READ_TIMEOUT_MS ms (read). Attempt ${attempt +1}", e)
161
159
} catch (e:MalformedURLException) {
162
-
Log.e(TAG, "Failed to fetch internet time: Malformed URL \t$TIME_API_URL\t. Stopping timer logic.", e)
163
-
stopTimerLogic() // URL is wrong, no point in retrying
160
+
Log.e(TAG, "Failed to fetch internet time: Malformed URL $TIME_API_URL. Stopping timer logic.", e)
161
+
stopTimerLogic()
164
162
return@launch
165
163
} catch (e:IOException) {
166
164
Log.e(TAG, "Failed to fetch internet time: IO Exception (e.g., network issue, connection reset). Attempt ${attempt +1}", e)
167
165
} catch (e:JSONException) {
168
166
Log.e(TAG, "Failed to parse JSON response from time API. Response might not be valid JSON. Attempt ${attempt +1}", e)
169
-
} catch (e:DateTimeParseException) { // This catch block will now likely not be hit for this specific issue, but good to keep for other parsing issues.
167
+
} catch (e:DateTimeParseException) {
170
168
Log.e(TAG, "Failed to parse date/time string from time API response. API format might have changed. Attempt ${attempt +1}", e)
171
169
} catch (e:Exception) {
172
170
Log.e(TAG, "An unexpected error occurred while fetching or processing internet time. Attempt ${attempt +1}", e)
0 commit comments