PhoneWindowManager: honor disabled screen-on reclaim setting - #1336
PhoneWindowManager: honor disabled screen-on reclaim setting#1336CeRRiLLo89 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.
|
Validation update for the current pull request head: The controlled device reproduction was performed on a Xiaomi Mi 9T Pro / Reproduction conditions:
Observed result:
Source validation was completed using the real Executed tests: Result:
The tests use a mocked ActivityManager service, so they validate the The pull request was also integrated successfully into a complete The local ROM package passed compilation, packaging, VINTF and ZIP integrity Runtime validation with an official ROM build containing this change remains The exact-build mitigation module remains enabled on This pull request is ready for maintainer review. Runtime validation with an official crDroid build remains pending because the |
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