Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions firebase-sessions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

* [fixed] Make AQS resilient to background init in multi-process apps.

# 2.0.7
* [fixed] Removed extraneous logs that risk leaking internal identifiers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,16 @@ internal class SessionLifecycleService : Service() {

/** Generates a new session id and sends it everywhere it's needed */
private fun newSession() {
SessionGenerator.instance.generateNewSession()
Log.d(TAG, "Generated new session.")
broadcastSession()
SessionDatastore.instance.updateSessionId(SessionGenerator.instance.currentSession.sessionId)
try {
SessionGenerator.instance.generateNewSession()
Log.d(TAG, "Generated new session.")
broadcastSession()
SessionDatastore.instance.updateSessionId(
SessionGenerator.instance.currentSession.sessionId
)
} catch (ex: IllegalStateException) {
Log.w(TAG, "Failed to generate new session.", ex)
}
}

/**
Expand All @@ -149,10 +155,14 @@ internal class SessionLifecycleService : Service() {
if (hasForegrounded) {
sendSessionToClient(client, SessionGenerator.instance.currentSession.sessionId)
} else {
// Send the value from the datastore before the first foregrounding it exists
val storedSession = SessionDatastore.instance.getCurrentSessionId()
Log.d(TAG, "App has not yet foregrounded. Using previously stored session.")
storedSession?.let { sendSessionToClient(client, it) }
try {
// Send the value from the datastore before the first foregrounding it exists
val storedSession = SessionDatastore.instance.getCurrentSessionId()
Log.d(TAG, "App has not yet foregrounded. Using previously stored session.")
storedSession?.let { sendSessionToClient(client, it) }
} catch (ex: IllegalStateException) {
Log.w(TAG, "Failed to send session to client.", ex)
}
}
}

Expand Down
Loading