mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
fix(onboarding): no wireless-debugging step on first run when the session runs outside the child-process count (#3639)
Before the runtime is installed, the rootfs has no native hook yet, so the child-process check assumed the next session would be counted and showed "Finish setup" for wireless debugging. The session stages the hook from the APK before it starts, so predict the next session from the setting and the rootfs loader instead; a runtime still to be installed will have one.
This commit is contained in:
1 parent
8b3cc7eb15
commit
7138f95c90
3 files changed
+23
-4
No files matched your search
@@ -395,9 +395,10 @@ object GuestWorkers {
|
||||
private set
|
||||
|
||||
/** Whether the session runs its programs in workers: the native userland, and not turned off. */
|
||||
fun enabled(context: Context): Boolean =
|
||||
android.os.Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.session.SessionPrefs.childProcessHandoff(context) &&
|
||||
NativeGuest.enabled(context)
|
||||
fun enabled(context: Context): Boolean = handoffAllowed(context) && NativeGuest.enabled(context)
|
||||
|
||||
private fun handoffAllowed(context: Context): Boolean =
|
||||
android.os.Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.session.SessionPrefs.childProcessHandoff(context)
|
||||
|
||||
/** How the running session's root was started: in a worker (true) or counted (false); null with none running. */
|
||||
@Volatile var sessionRootUncounted: Boolean? = null
|
||||
@@ -408,7 +409,7 @@ object GuestWorkers {
|
||||
* the next one would start.
|
||||
*/
|
||||
fun limitHandled(context: Context): Boolean =
|
||||
sessionRootUncounted ?: (NativeGuest.sessionMode != false && enabled(context))
|
||||
sessionRootUncounted ?: (NativeGuest.sessionMode != false && handoffAllowed(context) && NativeGuest.nextSession(context))
|
||||
|
||||
/** Whether pid is a program running in one of the workers. */
|
||||
fun runsInWorker(pid: Int): Boolean = pid > 0 && synchronized(slots) { slots.any { it != null && it.started && it.pid == pid } }
|
||||
|
||||
@@ -24,6 +24,16 @@ object NativeGuest {
|
||||
fun enabled(context: Context): Boolean =
|
||||
SessionPrefs.nativeUserland(context) && available(LinuxRuntime.rootDir(context))
|
||||
|
||||
/**
|
||||
* Whether the next session will start natively. The session stages the hook from the APK before
|
||||
* it starts, so only the setting and the rootfs's loader decide, and a runtime still to be
|
||||
* installed will have one.
|
||||
*/
|
||||
fun nextSession(context: Context): Boolean =
|
||||
SessionPrefs.nativeUserland(context) && willRun(LinuxRuntime.rootDir(context), LinuxRuntime.isInstalled(context))
|
||||
|
||||
internal fun willRun(root: File, installed: Boolean): Boolean = !installed || loader(root) != null
|
||||
|
||||
/** The mode the running session started in; null between sessions. */
|
||||
@Volatile var sessionMode: Boolean? = null
|
||||
|
||||
|
||||
Reference in new issue
Block a user