Apps: Restrict battery filter to whitelisted apps#360
Merged
Conversation
The 'Battery unrestricted apps' Overview category and the apps-list battery filter both used the predicate batteryOptimization != MANAGED_BY_SYSTEM, which matches IGNORED *and* OPTIMIZED. After a user changed an app's battery setting from Unrestricted to Optimized, a fresh scan correctly updated the enum from IGNORED to OPTIMIZED, but the filter still matched and the app stayed in the list — which the reporter saw as the data being stuck even after manual refresh and app restart. Flip the predicate to == IGNORED in both AppsFilterOptions.BATTERY_OPTIMIZATION and OverviewViewModel#SummaryCategory.BATTERY_OPT so it actually means 'whitelisted from doze'. Adds a unit test covering all four enum values.
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.
What changed
The "Battery unrestricted apps" category on the Overview screen, and the matching battery filter on the Apps list, now only show apps that are actually whitelisted from battery optimization (i.e. set to Unrestricted in Android's per-app battery settings). Apps in the default Optimized state (or Restricted, on devices that expose it) no longer appear there.
Closes #359.
Technical Context
batteryOptimization != BatteryOptimization.MANAGED_BY_SYSTEM, which matches bothIGNORED(whitelisted) andOPTIMIZED(declares the perm but is not whitelisted). The label said "unrestricted" but the predicate said "any app that can request whitelisting".AppsFilterOptions.BATTERY_OPTIMIZATIONandOverviewViewModel#SummaryCategory.BATTERY_OPT. Both flipped to== BatteryOptimization.IGNORED.IGNOREDtoOPTIMIZED, but the filter still matched. No One UI / Samsung quirk involved.BATTERY_OPTIMIZATION.matches. Behavioural change is intentional — anyone who relied on the chip surfacing all apps that declare the permission has lost that view; the chip now matches the Overview label semantics.