Skip to content

Commit

Permalink
Don't wrap sendLifecycleEvents twice
Browse files Browse the repository at this point in the history
  • Loading branch information
mrober committed Oct 20, 2023
1 parent 746da95 commit 7818e15
Showing 1 changed file with 7 additions and 12 deletions.
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

0 comments on commit 7818e15

Please sign in to comment.