PhoneWindowManager: honor disabled screen-on reclaim setting - #1336
Draft
CeRRiLLo89 wants to merge 6 commits into
Draft
PhoneWindowManager: honor disabled screen-on reclaim setting#1336CeRRiLLo89 wants to merge 6 commits into
CeRRiLLo89 wants to merge 6 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.PhoneWindowManagerinitialization, because the callback only requires the settings context and
the ActivityManager service.
This does not modify:
Tests
Added unit coverage verifying that:
releaseMemory()frombeing called;
call.
The tests initialize only the dependencies required by the delayed reclaim
callback instead of initializing the complete
PhoneWindowManagerpolicy.This avoids activating unrelated camera, role-management, device-key, and
Lineage settings subsystems during the unit test.
The ActivityManager call is mocked, so the tests do not perform a real process
reclaim.
Local validation was completed with the
lineage_raphaeluserdebug target anda physical Xiaomi Mi 9T Pro / Redmi K20 Pro (
raphael) running Android 16 /crDroid 12.11.
Executed tests:
Result:
The local crDroid WmTests baseline required two unrelated compatibility
adjustments in separate test files. Those adjustments were used only in the
local validation harness and are not included in this pull request.
Device context
Device: Xiaomi Mi 9T Pro / Redmi K20 Pro (
raphael)Build: crDroid Android 16
v12.11-20260623Validated pull request head:
60a3492aa2756fdad29b5a502b6cfa8acfff9d73The exact-build KernelSU mitigation remains enabled until a ROM build
containing this source change is available for controlled validation.
Validation status