From 18f6305977190a1865ba9f676fea2b7d27671a98 Mon Sep 17 00:00:00 2001 From: MaxsTechReview Date: Fri, 30 Oct 2026 16:55:09 -0400 Subject: [PATCH] fix: banking apps no longer refuse to open while DroidDeck is installed (#1824) * fix: banking apps open again with DroidDeck installed; the shortcuts accessibility service is listed only once the user sets it up 0.6.7 added HomeButtonService, a key-filtering accessibility service, enabled in the manifest. Android lists it as an installed accessibility service on every phone, and banking apps such as UBS refuse to start while one from outside the Play Store is installed. The service is now disabled by default, turned on when the user opens the Shortcuts setup, turned back off if they leave it unset, and kept on for anyone who already uses it. * Keep the shortcuts service declared and turn it off at start unless the user chose it, so an update never drops their choice A failed read of the enabled-services setting now changes nothing. * Hide the unchosen shortcuts service right after an update, before DroidDeck is opened A package-replaced receiver in its own light process runs the same listing sync as startup. The manifest default stays enabled because Android drops an unavailable service from the enabled-services setting, which would erase the choice of users updating from 0.6.7. * Hide the shortcuts service as soon as the user turns it off in Accessibility settings --- app/src/main/AndroidManifest.xml | 6 ++ .../main/java/com/droiddeck/launcher/App.kt | 4 +- .../droiddeck/launcher/FrontEndActivity.kt | 6 +- .../launcher/core/ShortcutsListingReceiver.kt | 11 +++ .../launcher/core/SteamIntegration.kt | 28 ++++++ .../launcher/input/HomeButtonService.kt | 1 + .../core/SteamIntegrationShortcutsTest.kt | 97 +++++++++++++++++++ 7 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/droiddeck/launcher/core/ShortcutsListingReceiver.kt create mode 100644 app/src/test/java/com/droiddeck/launcher/core/SteamIntegrationShortcutsTest.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 95984f02e0..3040ee33be 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -69,6 +69,12 @@ + + + + + { if (!integrationState.shortcuts) shortcutsTried = true if (!HomeApp.isDefault(this)) configureIntegration(SteamIntegration.Feature.HOME) - else integrationSettings(SteamIntegration.shortcutSettings(this), android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS) + else { + SteamIntegration.setShortcutsListed(this, true) + integrationSettings(SteamIntegration.shortcutSettings(this), android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS) + } } } } @@ -1643,6 +1646,7 @@ class FrontEndActivity : ComponentActivity() { orientation = SessionPrefs.orientation(this) launcherOrientation = com.droiddeck.launcher.core.AppUiPrefs.orientation(this) requestedOrientation = launcherOrientation + SteamIntegration.syncShortcutsListing(this) refreshWifiDiscovery() com.droiddeck.launcher.stores.StoresState.refresh(this) com.droiddeck.launcher.stores.StoresState.libraryListener = { refreshAddedGames(); refresh() } diff --git a/app/src/main/java/com/droiddeck/launcher/core/ShortcutsListingReceiver.kt b/app/src/main/java/com/droiddeck/launcher/core/ShortcutsListingReceiver.kt new file mode 100644 index 0000000000..f9ee889bdf --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/core/ShortcutsListingReceiver.kt @@ -0,0 +1,11 @@ +package com.droiddeck.launcher.core + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent + +class ShortcutsListingReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + if (intent.action == Intent.ACTION_MY_PACKAGE_REPLACED) SteamIntegration.syncShortcutsListing(context) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/core/SteamIntegration.kt b/app/src/main/java/com/droiddeck/launcher/core/SteamIntegration.kt index 982b609474..d3188b3492 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/SteamIntegration.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/SteamIntegration.kt @@ -4,6 +4,7 @@ import android.accessibilityservice.AccessibilityServiceInfo import android.content.ComponentName import android.content.Context import android.content.Intent +import android.content.pm.PackageManager import android.net.Uri import android.provider.Settings import android.view.accessibility.AccessibilityManager @@ -55,6 +56,33 @@ object SteamIntegration { return mode == android.app.AppOpsManager.MODE_ERRORED || mode == android.app.AppOpsManager.MODE_IGNORED } + private fun shortcutsComponent(context: Context) = ComponentName(context, HomeButtonService::class.java) + + fun shortcutsChosen(context: Context): Boolean = shortcutsSelection(context) == true + + private fun shortcutsSelection(context: Context): Boolean? { + val target = shortcutsComponent(context) + val enabled = runCatching { + Settings.Secure.getString(context.contentResolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES) + }.getOrElse { return null }.orEmpty() + return enabled.split(':').any { ComponentName.unflattenFromString(it.trim()) == target } + } + + fun setShortcutsListed(context: Context, listed: Boolean) { + val packages = context.packageManager + val component = shortcutsComponent(context) + val state = if (listed) PackageManager.COMPONENT_ENABLED_STATE_ENABLED else PackageManager.COMPONENT_ENABLED_STATE_DISABLED + runCatching { + if (packages.getComponentEnabledSetting(component) != state) { + packages.setComponentEnabledSetting(component, state, PackageManager.DONT_KILL_APP) + } + } + } + + fun syncShortcutsListing(context: Context) { + shortcutsSelection(context)?.let { setShortcutsListed(context, it) } + } + fun dismissSuggestion(context: Context) { SessionPrefs.sessionPrefs(context).edit().putBoolean("steam_integration_seen", true).apply() } diff --git a/app/src/main/java/com/droiddeck/launcher/input/HomeButtonService.kt b/app/src/main/java/com/droiddeck/launcher/input/HomeButtonService.kt index b85fecb120..21ca4717d2 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/HomeButtonService.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/HomeButtonService.kt @@ -60,6 +60,7 @@ class HomeButtonService : AccessibilityService(), InputManager.InputDeviceListen override fun onUnbind(intent: Intent?): Boolean { HomeButtonShortcuts.release() + com.droiddeck.launcher.core.SteamIntegration.syncShortcutsListing(this) return super.onUnbind(intent) } diff --git a/app/src/test/java/com/droiddeck/launcher/core/SteamIntegrationShortcutsTest.kt b/app/src/test/java/com/droiddeck/launcher/core/SteamIntegrationShortcutsTest.kt new file mode 100644 index 0000000000..961d3d25ab --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/core/SteamIntegrationShortcutsTest.kt @@ -0,0 +1,97 @@ +package com.droiddeck.launcher.core + +import android.app.Application +import android.content.ComponentName +import android.content.Intent +import android.content.pm.PackageManager +import android.provider.Settings +import androidx.test.core.app.ApplicationProvider +import com.droiddeck.launcher.input.HomeButtonService +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [33], application = Application::class) +class SteamIntegrationShortcutsTest { + private val context: Application = ApplicationProvider.getApplicationContext() + private val service = ComponentName(context, HomeButtonService::class.java) + + private fun listed() = context.packageManager.queryIntentServices( + Intent("android.accessibilityservice.AccessibilityService").setPackage(context.packageName), 0, + ).any { ComponentName(it.serviceInfo.packageName, it.serviceInfo.name) == service } + + private fun choose(value: String?) = + Settings.Secure.putString(context.contentResolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, value) + + @Test fun theShortcutsServiceIsHiddenUntilChosen() { + assertTrue(listed()) + assertFalse(SteamIntegration.shortcutsChosen(context)) + SteamIntegration.syncShortcutsListing(context) + assertFalse(listed()) + assertEquals(PackageManager.COMPONENT_ENABLED_STATE_DISABLED, context.packageManager.getComponentEnabledSetting(service)) + } + + @Test fun anUpdateKeepsAServiceTheUserAlreadyTurnedOn() { + choose(service.flattenToString()) + SteamIntegration.syncShortcutsListing(context) + assertTrue(listed()) + assertTrue(SteamIntegration.shortcutsChosen(context)) + } + + @Test fun openingShortcutSetupListsTheServiceAndBackingOutHidesItAgain() { + SteamIntegration.setShortcutsListed(context, true) + assertTrue(listed()) + SteamIntegration.syncShortcutsListing(context) + assertFalse(listed()) + assertEquals(PackageManager.COMPONENT_ENABLED_STATE_DISABLED, context.packageManager.getComponentEnabledSetting(service)) + } + + @Test fun aChosenServiceStaysListed() { + choose("other.app/.Reader:" + service.flattenToShortString()) + assertTrue(SteamIntegration.shortcutsChosen(context)) + SteamIntegration.syncShortcutsListing(context) + assertTrue(listed()) + choose(service.flattenToString()) + assertTrue(SteamIntegration.shortcutsChosen(context)) + choose("other.app/.Reader") + assertFalse(SteamIntegration.shortcutsChosen(context)) + SteamIntegration.syncShortcutsListing(context) + assertFalse(listed()) + } + + @Test fun anUpdateHidesAnUnchosenServiceWithoutOpeningDroidDeck() { + val replaced = Intent(Intent.ACTION_MY_PACKAGE_REPLACED).setPackage(context.packageName) + assertTrue(context.packageManager.queryBroadcastReceivers(replaced, 0) + .any { it.activityInfo.name == ShortcutsListingReceiver::class.java.name }) + assertTrue(listed()) + ShortcutsListingReceiver().onReceive(context, replaced) + assertFalse(listed()) + } + + @Test fun anUpdateLeavesAChosenServiceListed() { + choose(service.flattenToString()) + ShortcutsListingReceiver().onReceive(context, Intent(Intent.ACTION_MY_PACKAGE_REPLACED)) + assertTrue(listed()) + assertTrue(SteamIntegration.shortcutsChosen(context)) + } + + @Test fun otherBroadcastsChangeNothing() { + ShortcutsListingReceiver().onReceive(context, Intent(Intent.ACTION_BOOT_COMPLETED)) + assertTrue(listed()) + } + + @Test fun turningTheServiceOffInSettingsHidesItAtOnce() { + choose(service.flattenToString()) + val running = org.robolectric.Robolectric.buildService(HomeButtonService::class.java).create().get() + running.onUnbind(null) + assertTrue(listed()) + choose("") + running.onUnbind(null) + assertFalse(listed()) + } +}