AodPolicy: Fix service leak
Fixes an issue where the AlwaysOnDisplayPolicy leaked a service
context, and with it the entirety of DozeMachine, preventing
wakelocks from being GCed and preventing them from being
fallback-released.
Bug: 78402666
Test: Toggle screen on and off a few times, verify that DozeService is not being leaked.
Change-Id: Ie3ad67c2d0c83760f4d04a53394fab4a3a35d6bc
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
index 07b79a2..d2d9c4c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
@@ -59,9 +59,9 @@
@VisibleForTesting
protected DozeParameters(Context context) {
- mContext = context;
+ mContext = context.getApplicationContext();
mAmbientDisplayConfiguration = new AmbientDisplayConfiguration(mContext);
- mAlwaysOnPolicy = new AlwaysOnDisplayPolicy(context);
+ mAlwaysOnPolicy = new AlwaysOnDisplayPolicy(mContext);
mControlScreenOffAnimation = !getDisplayNeedsBlanking();
mPowerManager = mContext.getSystemService(PowerManager.class);
@@ -243,6 +243,10 @@
mDozeAlwaysOn = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);
}
+ public AlwaysOnDisplayPolicy getPolicy() {
+ return mAlwaysOnPolicy;
+ }
+
/**
* Parses a spec of the form `1,2,3,!5,*`. The resulting object will match numbers that are
* listed, will not match numbers that are listed with a ! prefix, and will match / not match