Skip to content

Commit ed5621e

Browse files
authored
Followup to #6699 (#6701)
1 parent de93104 commit ed5621e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

firebase-sessions/src/main/kotlin/com/google/firebase/sessions/SessionLifecycleService.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ internal class SessionLifecycleService : Service() {
128128
/** Generates a new session id and sends it everywhere it's needed */
129129
private fun newSession() {
130130
try {
131+
// TODO(mrober): Consider migrating to Dagger, or update [FirebaseSessionsRegistrar].
131132
SessionGenerator.instance.generateNewSession()
132133
Log.d(TAG, "Generated new session.")
133134
broadcastSession()
@@ -152,17 +153,17 @@ internal class SessionLifecycleService : Service() {
152153
}
153154

154155
private fun maybeSendSessionToClient(client: Messenger) {
155-
if (hasForegrounded) {
156-
sendSessionToClient(client, SessionGenerator.instance.currentSession.sessionId)
157-
} else {
158-
try {
156+
try {
157+
if (hasForegrounded) {
158+
sendSessionToClient(client, SessionGenerator.instance.currentSession.sessionId)
159+
} else {
159160
// Send the value from the datastore before the first foregrounding it exists
160161
val storedSession = SessionDatastore.instance.getCurrentSessionId()
161162
Log.d(TAG, "App has not yet foregrounded. Using previously stored session.")
162163
storedSession?.let { sendSessionToClient(client, it) }
163-
} catch (ex: IllegalStateException) {
164-
Log.w(TAG, "Failed to send session to client.", ex)
165164
}
165+
} catch (ex: IllegalStateException) {
166+
Log.w(TAG, "Failed to send session to client.", ex)
166167
}
167168
}
168169

0 commit comments

Comments
 (0)