Merge "AodPolicy: Fix service leak" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4f4882f2ce
@@ -116,6 +116,7 @@ public class AlwaysOnDisplayPolicy {
|
|||||||
private SettingsObserver mSettingsObserver;
|
private SettingsObserver mSettingsObserver;
|
||||||
|
|
||||||
public AlwaysOnDisplayPolicy(Context context) {
|
public AlwaysOnDisplayPolicy(Context context) {
|
||||||
|
context = context.getApplicationContext();
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mParser = new KeyValueListParser(',');
|
mParser = new KeyValueListParser(',');
|
||||||
mSettingsObserver = new SettingsObserver(context.getMainThreadHandler());
|
mSettingsObserver = new SettingsObserver(context.getMainThreadHandler());
|
||||||
|
|||||||
@@ -61,13 +61,14 @@ public class DozeFactory {
|
|||||||
|
|
||||||
DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock);
|
DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock);
|
||||||
machine.setParts(new DozeMachine.Part[]{
|
machine.setParts(new DozeMachine.Part[]{
|
||||||
new DozePauser(handler, machine, alarmManager, new AlwaysOnDisplayPolicy(context)),
|
new DozePauser(handler, machine, alarmManager, params.getPolicy()),
|
||||||
new DozeFalsingManagerAdapter(FalsingManager.getInstance(context)),
|
new DozeFalsingManagerAdapter(FalsingManager.getInstance(context)),
|
||||||
createDozeTriggers(context, sensorManager, host, alarmManager, config, params,
|
createDozeTriggers(context, sensorManager, host, alarmManager, config, params,
|
||||||
handler, wakeLock, machine),
|
handler, wakeLock, machine),
|
||||||
createDozeUi(context, host, wakeLock, machine, handler, alarmManager, params),
|
createDozeUi(context, host, wakeLock, machine, handler, alarmManager, params),
|
||||||
new DozeScreenState(wrappedService, handler, params, wakeLock),
|
new DozeScreenState(wrappedService, handler, params, wakeLock),
|
||||||
createDozeScreenBrightness(context, wrappedService, sensorManager, host, handler),
|
createDozeScreenBrightness(context, wrappedService, sensorManager, host, params,
|
||||||
|
handler),
|
||||||
new DozeWallpaperState(context, params)
|
new DozeWallpaperState(context, params)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -76,11 +77,11 @@ public class DozeFactory {
|
|||||||
|
|
||||||
private DozeMachine.Part createDozeScreenBrightness(Context context,
|
private DozeMachine.Part createDozeScreenBrightness(Context context,
|
||||||
DozeMachine.Service service, SensorManager sensorManager, DozeHost host,
|
DozeMachine.Service service, SensorManager sensorManager, DozeHost host,
|
||||||
Handler handler) {
|
DozeParameters params, Handler handler) {
|
||||||
Sensor sensor = DozeSensors.findSensorWithType(sensorManager,
|
Sensor sensor = DozeSensors.findSensorWithType(sensorManager,
|
||||||
context.getString(R.string.doze_brightness_sensor_type));
|
context.getString(R.string.doze_brightness_sensor_type));
|
||||||
return new DozeScreenBrightness(context, service, sensorManager, sensor, host, handler,
|
return new DozeScreenBrightness(context, service, sensorManager, sensor, host, handler,
|
||||||
new AlwaysOnDisplayPolicy(context));
|
params.getPolicy());
|
||||||
}
|
}
|
||||||
|
|
||||||
private DozeTriggers createDozeTriggers(Context context, SensorManager sensorManager,
|
private DozeTriggers createDozeTriggers(Context context, SensorManager sensorManager,
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class DozeService extends DreamService
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Dependency.get(PluginManager.class).removePluginListener(this);
|
Dependency.get(PluginManager.class).removePluginListener(this);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
mDozeMachine = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
mAllowPulseTriggers = allowPulseTriggers;
|
mAllowPulseTriggers = allowPulseTriggers;
|
||||||
mDozeSensors = new DozeSensors(context, alarmManager, mSensorManager, dozeParameters,
|
mDozeSensors = new DozeSensors(context, alarmManager, mSensorManager, dozeParameters,
|
||||||
config, wakeLock, this::onSensor, this::onProximityFar,
|
config, wakeLock, this::onSensor, this::onProximityFar,
|
||||||
new AlwaysOnDisplayPolicy(context));
|
dozeParameters.getPolicy());
|
||||||
mUiModeManager = mContext.getSystemService(UiModeManager.class);
|
mUiModeManager = mContext.getSystemService(UiModeManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,9 +59,9 @@ public class DozeParameters implements TunerService.Tunable {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected DozeParameters(Context context) {
|
protected DozeParameters(Context context) {
|
||||||
mContext = context;
|
mContext = context.getApplicationContext();
|
||||||
mAmbientDisplayConfiguration = new AmbientDisplayConfiguration(mContext);
|
mAmbientDisplayConfiguration = new AmbientDisplayConfiguration(mContext);
|
||||||
mAlwaysOnPolicy = new AlwaysOnDisplayPolicy(context);
|
mAlwaysOnPolicy = new AlwaysOnDisplayPolicy(mContext);
|
||||||
|
|
||||||
mControlScreenOffAnimation = !getDisplayNeedsBlanking();
|
mControlScreenOffAnimation = !getDisplayNeedsBlanking();
|
||||||
mPowerManager = mContext.getSystemService(PowerManager.class);
|
mPowerManager = mContext.getSystemService(PowerManager.class);
|
||||||
@@ -243,6 +243,10 @@ public class DozeParameters implements TunerService.Tunable {
|
|||||||
mDozeAlwaysOn = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);
|
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
|
* 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
|
* listed, will not match numbers that are listed with a ! prefix, and will match / not match
|
||||||
|
|||||||
Reference in New Issue
Block a user