fix: never block the device's default launcher#238
Open
Raian256 wants to merge 3 commits into
Open
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.