mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
fix(handoff): requests name their session; stops of handed-off programs reported; cancellable look
This commit is contained in:
1 parent
be7f59d983
commit
d2f270d93c
5 files changed
+149
-9
No files matched your search
@@ -328,13 +328,12 @@ object GuestWorkers {
|
||||
* [guest]: one of the session's guest programs, which [guestPids] lists and [stopGuests] ends.
|
||||
* [commit] runs with the pid before the worker may run the program; false, and it does not.
|
||||
* [confirmed] runs once the worker has taken it on, just before it is told to run it; false, and it does not.
|
||||
* [owner]: the session asking (the one a guest's request names), else the latest.
|
||||
*/
|
||||
private fun start(context: Context, argv: List<String>, env: List<String>, fds: List<ParcelFileDescriptor>, targets: IntArray,
|
||||
guest: Boolean, onExit: (Int) -> Unit, commit: (Int) -> Boolean = { true },
|
||||
confirmed: () -> Boolean = { true }): Int {
|
||||
confirmed: () -> Boolean = { true }, owner: Int = session): Int {
|
||||
val app = context.applicationContext
|
||||
// The session asking: a cold bind can take long enough for it to stop and another to start
|
||||
val owner = session
|
||||
if (guest && owner <= stopped) {
|
||||
Log.w(TAG, "session $owner is stopping: not starting ${argv.firstOrNull()}")
|
||||
return -1
|
||||
@@ -737,7 +736,11 @@ object GuestWorkers {
|
||||
var answered = false
|
||||
// the hook's last word, sent once the worker has taken the program on and before it runs it
|
||||
var confirmedToHook = false
|
||||
val pid = start(app, command, env.map { (k, v) -> "$k=$v" }, programFds, targets, true, onExit = { code ->
|
||||
// The session whose guest asks, not the latest: a new session can start (serve()) while an
|
||||
// older one's guests are still sending, and that older one's teardown must find its programs.
|
||||
// A request that names none (a guest of an older build) is the latest's.
|
||||
val owner = request.optInt("session", 0).takeIf { it > 0 } ?: session
|
||||
val pid = start(app, command, env.map { (k, v) -> "$k=$v" }, programFds, targets, true, owner = owner, onExit = { code ->
|
||||
status = code
|
||||
if (table != null && slot >= 0) reportExit(table, slot, code, parent, child, worker)
|
||||
exited.countDown()
|
||||
|
||||
@@ -712,7 +712,10 @@ class SessionService : Service() {
|
||||
if (gen != sessionGen || !SessionState.running) 0
|
||||
else com.droiddeck.launcher.runtime.GuestWorkers.serve(this).also { guestWorkerSession = it }
|
||||
}
|
||||
if (ownWorkers > 0) guest.add("DD_SPAWN=" + com.droiddeck.launcher.runtime.GuestWorkers.socketName(this))
|
||||
if (ownWorkers > 0) {
|
||||
guest.add("DD_SPAWN=" + com.droiddeck.launcher.runtime.GuestWorkers.socketName(this))
|
||||
guest.add("DD_SPAWN_SESSION=$ownWorkers")
|
||||
}
|
||||
}
|
||||
// Proton builds up to 11.12 report X11 text fields under this name.
|
||||
guest.add("BL_LAUNCH_DIR=" + sessionRoot.path)
|
||||
|
||||
Reference in new issue
Block a user