PhoneWindowManager: honor disabled screen-on reclaim setting - #1336
Draft
CeRRiLLo89 wants to merge 5 commits into
Draft
PhoneWindowManager: honor disabled screen-on reclaim setting#1336CeRRiLLo89 wants to merge 5 commits into
CeRRiLLo89 wants to merge 5 commits into
Conversation
Screen-on reclaim is scheduled from a cached setting and executes after a 1250 ms delay. Re-read SCREEN_ON_MEMORY_RECLAIM before running the delayed reclaim so the disabled state is honored even if the cached value is stale or the setting changes after scheduling. Mark the cached flag volatile because it is updated by the settings observer and read from the power notifier path.
Remove whitespace from the blank line after mMemoryOpt.
Verify that the delayed screen-on reclaim callback rechecks the current SCREEN_ON_MEMORY_RECLAIM setting before releasing memory. Cover both the disabled and enabled paths while stubbing the ActivityManager call to avoid running a real reclaim during the test.
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.
Summary
Re-read
SCREEN_ON_MEMORY_RECLAIMimmediately before executing the delayedscreen-on memory reclaim.
Problem
PhoneWindowManagerschedulesmMemoryOptfrom the cachedmScreenOnReclaimvalue and executes the callback 1250 ms later.The callback previously called
releaseMemoryAtScreenOn()without checkingthe current setting again.
On raphael with crDroid Android 16, screen-on reclaim was reproduced while:
0;screen_on_memory_reclaimwas0;services.jarwas active.One controlled screen-on cycle produced the reclaim log 1251 ms after wake
and killed 25 cached processes, including the Android Auto car process.
The exact reason for the stale cached state has not been proven. It may involve
setting-observer timing or cross-thread visibility.
Change
execution contexts.
@VisibleForTesting.This does not modify:
Tests
Added unit coverage verifying that:
releaseMemory();The ActivityManager call is stubbed so the tests do not perform a real reclaim.
The tests have been added but have not been executed locally because a full
Android framework build environment is not currently available.
Expected test command:
atest WmTests:PhoneWindowManagerTestsDevice context
Device: Xiaomi Mi 9T Pro / Redmi K20 Pro (
raphael)Build: crDroid Android 16
v12.11-20260623The exact-build KernelSU mitigation remains enabled until a ROM build
containing this source change is available for controlled validation.
Validation status