Skip to content

fix: never block the device's default launcher#238

Open
Raian256 wants to merge 3 commits into
nethical6:kt-rewritefrom
Raian256:feat/app-blocker-skip-launcher
Open

fix: never block the device's default launcher#238
Raian256 wants to merge 3 commits into
nethical6:kt-rewritefrom
Raian256:feat/app-blocker-skip-launcher

Conversation

@Raian256
Copy link
Copy Markdown

AppBlocker had no launcher exclusion: a launcher added to a Usage or Time block group would be force-stopped and the user sent to home, which is itself the launcher — an infinite block loop. Cache the launcher package in setupAppBlocker (refreshed via the existing refresh broadcast) and short-circuit doAppBlockerCheck before consulting either blocklist.

FocusModeBlocker's BLOCK_SELECTED branches did not consult essentialPackages, so a selected launcher would be blocked in both manual and auto focus. Added the essentialPackages guard to both BLOCK_SELECTED branches, plus the manual BLOCK_ALL_EXCEPT_SELECTED branch for symmetry (previously only covered indirectly via setupFocusMode mutating the group's packages set).

AppSuspendHelper.getPackagesToSuspend returned groupPackages.toList() unfiltered for BLOCK_SELECTED, so a selected launcher would be pm-suspended via Shizuku. Filter essentialPackages out of that branch too.

AppBlocker had no launcher exclusion: a launcher added to a Usage or
Time block group would be force-stopped and the user sent to home,
which is itself the launcher — an infinite block loop. Cache the
launcher package in setupAppBlocker (refreshed via the existing refresh
broadcast) and short-circuit doAppBlockerCheck before consulting either
blocklist.

FocusModeBlocker's BLOCK_SELECTED branches did not consult
essentialPackages, so a selected launcher would be blocked in both
manual and auto focus. Added the essentialPackages guard to both
BLOCK_SELECTED branches, plus the manual BLOCK_ALL_EXCEPT_SELECTED
branch for symmetry (previously only covered indirectly via
setupFocusMode mutating the group's packages set).

AppSuspendHelper.getPackagesToSuspend returned groupPackages.toList()
unfiltered for BLOCK_SELECTED, so a selected launcher would be
pm-suspended via Shizuku. Filter essentialPackages out of that branch
too.
The set of packages that must never be blocked (launcher, keyboard,
system UI, our own app) was open-coded in two blockers with subtly
different shapes — AppBlocker hardcoded systemui+self and tracked the
launcher in a separate field, while FocusModeBlocker built a Set inline
and also kept self-package as its own early-return clause. Adding
another category (e.g. dialer, an accessibility service the user grants
permission to) would have meant editing every site.

Extract getEssentialPackages(context) into utils as the single source
of truth. Both blockers now read from it. Drop the
currentFocusingGroup.packages.addAll(essentialPackages) mutation in
setupFocusMode — it was a workaround for BLOCK_ALL_EXCEPT_SELECTED not
consulting essentialPackages directly, which the previous commit fixed,
and mutating a model loaded from datastore was a smell.
Even though the runtime blockers refuse to act on essentials, listing
them in the picker is misleading — a user who selects the launcher
expects it to be blocked, and silently dropping the choice violates
that expectation. Pull essentials from getEssentialPackages and add
them to ignoredApps, the existing exclusion set.

Apply the same filter to both code paths: the launcher-apps loader
(which already honored ignoredApps) and the APP_LIST shortcut + the
'add uninstalled apps from selectedAppList' fallback (which previously
ignored ignoredApps and would leak essentials back in if a group saved
under the old code still contained them).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant