mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
* fix(ui): changing the language restarts the launcher instead of leaving it frozen * fix(ui): a launcher restart no longer starts the startup session * fix(ui): a stopping launcher no longer clears the hooks its replacement set * fix(ui): a launcher restart keeps a pending session switch * fix(ui): a launcher restart hands its state over in-process, not through intent extras
28 lines
720 B
Kotlin
28 lines
720 B
Kotlin
package com.droiddeck.launcher
|
|
|
|
import android.os.Bundle
|
|
import android.os.SystemClock
|
|
|
|
/**
|
|
* State a restarting launcher passes to its replacement inside this process. Intent extras are not used
|
|
* because FrontEndActivity is exported and any app could fill them.
|
|
*/
|
|
internal object LauncherHandoff {
|
|
private const val LIFETIME_MS = 10_000L
|
|
private var state: Bundle? = null
|
|
private var at = 0L
|
|
|
|
@Synchronized
|
|
fun put(carried: Bundle) {
|
|
state = carried
|
|
at = SystemClock.elapsedRealtime()
|
|
}
|
|
|
|
@Synchronized
|
|
fun take(): Bundle? {
|
|
val carried = state
|
|
state = null
|
|
return carried?.takeIf { SystemClock.elapsedRealtime() - at <= LIFETIME_MS }
|
|
}
|
|
}
|