Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't wrap sendLifecycleEvents twice #5463

Merged
merged 1 commit into from
Oct 20, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import android.content.ServiceConnection
import android.os.Handler
import android.os.HandlerThread
import android.os.IBinder
import android.os.Looper
import android.os.Message
import android.os.Messenger
import android.os.RemoteException
Expand Down Expand Up @@ -60,7 +59,7 @@ internal object SessionLifecycleClient {
init {
handlerThread.start()
}

/**
* The callback class that will be used to receive updated session events from the
* [SessionLifecycleService].
Expand Down Expand Up @@ -150,16 +149,14 @@ internal object SessionLifecycleClient {
sendLifecycleEvent(SessionLifecycleService.BACKGROUNDED)
}

/**
* Perform initialization that requires cleanup
*/
/** Perform initialization that requires cleanup */
fun started() {
if (!handlerThread.isAlive) { handlerThread.start() }
if (!handlerThread.isAlive) {
handlerThread.start()
}
}

/**
* Cleanup initialization
*/
/** Cleanup initialization */
fun stopped() {
handlerThread.quit()
}
Expand All @@ -172,9 +169,7 @@ internal object SessionLifecycleClient {
private fun sendLifecycleEvent(messageCode: Int) {
val allMessages = drainQueue()
allMessages.add(Message.obtain(null, messageCode, 0, 0))
CoroutineScope(Dispatchers.instance.backgroundDispatcher).launch {
sendLifecycleEvents(allMessages)
}
sendLifecycleEvents(allMessages)
}

/**
Expand Down