@@ -127,10 +127,16 @@ internal class SessionLifecycleService : Service() {
127
127
128
128
/* * Generates a new session id and sends it everywhere it's needed */
129
129
private fun newSession () {
130
- SessionGenerator .instance.generateNewSession()
131
- Log .d(TAG , " Generated new session." )
132
- broadcastSession()
133
- SessionDatastore .instance.updateSessionId(SessionGenerator .instance.currentSession.sessionId)
130
+ try {
131
+ SessionGenerator .instance.generateNewSession()
132
+ Log .d(TAG , " Generated new session." )
133
+ broadcastSession()
134
+ SessionDatastore .instance.updateSessionId(
135
+ SessionGenerator .instance.currentSession.sessionId
136
+ )
137
+ } catch (ex: IllegalStateException ) {
138
+ Log .w(TAG , " Failed to generate new session." , ex)
139
+ }
134
140
}
135
141
136
142
/* *
@@ -149,10 +155,14 @@ internal class SessionLifecycleService : Service() {
149
155
if (hasForegrounded) {
150
156
sendSessionToClient(client, SessionGenerator .instance.currentSession.sessionId)
151
157
} else {
152
- // Send the value from the datastore before the first foregrounding it exists
153
- val storedSession = SessionDatastore .instance.getCurrentSessionId()
154
- Log .d(TAG , " App has not yet foregrounded. Using previously stored session." )
155
- storedSession?.let { sendSessionToClient(client, it) }
158
+ try {
159
+ // Send the value from the datastore before the first foregrounding it exists
160
+ val storedSession = SessionDatastore .instance.getCurrentSessionId()
161
+ Log .d(TAG , " App has not yet foregrounded. Using previously stored session." )
162
+ storedSession?.let { sendSessionToClient(client, it) }
163
+ } catch (ex: IllegalStateException ) {
164
+ Log .w(TAG , " Failed to send session to client." , ex)
165
+ }
156
166
}
157
167
}
158
168
0 commit comments