From 63db6fe9b7d5fd69b9e9546a282c7b91dd810fd7 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Mon, 28 Sep 2026 09:24:19 -0400 Subject: [PATCH] Child-process check: read the Developer options toggle too Developer options' "Disable child process restrictions" writes only the feature-flag property persist.sys.fflag.override.settings_enable_monitor_phantom_procs, never the global setting. Android (FeatureFlagUtils.isEnabled) uses the global setting when it is set and that property otherwise, but the check read only the global setting, so a device switched off in Developer options stayed flagged as unset however often Check again was pressed. The check now follows Android's order, and the Setup card no longer says "On" for a setting that is unset or unreadable. --- .../launcher/core/PhantomProcessLimit.kt | 28 ++++++++++++++++-- .../droiddeck/launcher/ui/FrontEndSetup.kt | 7 ++++- .../launcher/core/PhantomProcessLimitTest.kt | 29 +++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 app/src/test/java/com/droiddeck/launcher/core/PhantomProcessLimitTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt b/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt index 3c21f6ff63..103bf05563 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt @@ -23,18 +23,40 @@ object PhantomProcessLimit { fun read(resolver: ContentResolver, sdk: Int = Build.VERSION.SDK_INT): PhantomProcessStatus { if (sdk < Build.VERSION_CODES.S) return PhantomProcessStatus.NOT_APPLICABLE - val value = try { + val global = try { Settings.Global.getString(resolver, SETTING) } catch (_: Exception) { return PhantomProcessStatus.UNREADABLE } - return when (value?.trim()?.lowercase()) { + return status(global, systemProperty(OVERRIDE_PROPERTY)) + } + + /** + * The value Android itself acts on, in FeatureFlagUtils.isEnabled's order: the global setting + * when it is set, otherwise the feature-flag override property. Developer options' "Disable + * child process restrictions" writes only the property, so a device switched off there has no + * global setting at all and must not be reported as unset. + */ + fun status(global: String?, override: String?): PhantomProcessStatus { + val value = global?.trim()?.lowercase()?.takeIf { it.isNotEmpty() } + ?: override?.trim()?.lowercase()?.takeIf { it.isNotEmpty() } + return when (value) { "false", "0" -> PhantomProcessStatus.DISABLED - null, "" -> PhantomProcessStatus.UNSET + null -> PhantomProcessStatus.UNSET else -> PhantomProcessStatus.ENABLED } } + private const val OVERRIDE_PROPERTY = "persist.sys.fflag.override.$SETTING" + + private fun systemProperty(name: String): String? = try { + Class.forName("android.os.SystemProperties") + .getMethod("get", String::class.java) + .invoke(null, name) as? String + } catch (_: Exception) { + null + } + fun blocksSteam(status: PhantomProcessStatus): Boolean = status != PhantomProcessStatus.NOT_APPLICABLE && status != PhantomProcessStatus.DISABLED diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index debd674448..a8a225dfe4 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -208,7 +208,12 @@ internal fun SetupPanel( CheckRow( if (limitBlocks) CheckState.WARN else CheckState.OK, "Child-process limit", - if (limitBlocks) "On · Android may close Steam. Turning it off takes a minute" else PhantomProcessLimit.title(s.phantomProcessStatus), + when (s.phantomProcessStatus) { + PhantomProcessStatus.ENABLED -> "On · Android may close Steam. Turning it off takes a minute" + PhantomProcessStatus.UNSET -> "Not set · the ROM default may close Steam. Turning it off takes a minute" + PhantomProcessStatus.UNREADABLE -> "Could not be checked · turning it off takes a minute" + else -> PhantomProcessLimit.title(s.phantomProcessStatus) + }, ) { if (limitBlocks) PrimaryButton(if (showLimitDetails) "Hide" else "Fix it", compact = true) { showLimitDetails = !showLimitDetails } else if (s.phantomProcessStatus != PhantomProcessStatus.NOT_APPLICABLE) { diff --git a/app/src/test/java/com/droiddeck/launcher/core/PhantomProcessLimitTest.kt b/app/src/test/java/com/droiddeck/launcher/core/PhantomProcessLimitTest.kt new file mode 100644 index 0000000000..a7cfc80a92 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/core/PhantomProcessLimitTest.kt @@ -0,0 +1,29 @@ +package com.droiddeck.launcher.core + +import org.junit.Assert.assertEquals +import org.junit.Test + +class PhantomProcessLimitTest { + @Test + fun developerOptionsToggleAloneCountsAsOff() { + assertEquals(PhantomProcessStatus.DISABLED, PhantomProcessLimit.status(null, "false")) + } + + @Test + fun globalSettingWinsOverTheProperty() { + assertEquals(PhantomProcessStatus.DISABLED, PhantomProcessLimit.status("false", "true")) + assertEquals(PhantomProcessStatus.ENABLED, PhantomProcessLimit.status("true", "false")) + } + + @Test + fun emptyGlobalFallsThroughToTheProperty() { + assertEquals(PhantomProcessStatus.ENABLED, PhantomProcessLimit.status("", "true")) + assertEquals(PhantomProcessStatus.DISABLED, PhantomProcessLimit.status(" ", "0")) + } + + @Test + fun neitherSetIsUnset() { + assertEquals(PhantomProcessStatus.UNSET, PhantomProcessLimit.status(null, null)) + assertEquals(PhantomProcessStatus.UNSET, PhantomProcessLimit.status("", "")) + } +}