Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f4882f2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "AodPolicy: Fix service leak" into pi-dev

parents 54e0be0d 2f5a385d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ public class AlwaysOnDisplayPolicy {
    private SettingsObserver mSettingsObserver;

    public AlwaysOnDisplayPolicy(Context context) {
        context = context.getApplicationContext();
        mContext = context;
        mParser = new KeyValueListParser(',');
        mSettingsObserver = new SettingsObserver(context.getMainThreadHandler());
+5 −4
Original line number Diff line number Diff line
@@ -61,13 +61,14 @@ public class DozeFactory {

        DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock);
        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)),
                createDozeTriggers(context, sensorManager, host, alarmManager, config, params,
                        handler, wakeLock, machine),
                createDozeUi(context, host, wakeLock, machine, handler, alarmManager, params),
                new DozeScreenState(wrappedService, handler, params, wakeLock),
                createDozeScreenBrightness(context, wrappedService, sensorManager, host, handler),
                createDozeScreenBrightness(context, wrappedService, sensorManager, host, params,
                        handler),
                new DozeWallpaperState(context, params)
        });

@@ -76,11 +77,11 @@ public class DozeFactory {

    private DozeMachine.Part createDozeScreenBrightness(Context context,
            DozeMachine.Service service, SensorManager sensorManager, DozeHost host,
            Handler handler) {
            DozeParameters params, Handler handler) {
        Sensor sensor = DozeSensors.findSensorWithType(sensorManager,
                context.getString(R.string.doze_brightness_sensor_type));
        return new DozeScreenBrightness(context, service, sensorManager, sensor, host, handler,
                new AlwaysOnDisplayPolicy(context));
                params.getPolicy());
    }

    private DozeTriggers createDozeTriggers(Context context, SensorManager sensorManager,
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ public class DozeService extends DreamService
    public void onDestroy() {
        Dependency.get(PluginManager.class).removePluginListener(this);
        super.onDestroy();
        mDozeMachine = null;
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public class DozeTriggers implements DozeMachine.Part {
        mAllowPulseTriggers = allowPulseTriggers;
        mDozeSensors = new DozeSensors(context, alarmManager, mSensorManager, dozeParameters,
                config, wakeLock, this::onSensor, this::onProximityFar,
                new AlwaysOnDisplayPolicy(context));
                dozeParameters.getPolicy());
        mUiModeManager = mContext.getSystemService(UiModeManager.class);
    }

+6 −2
Original line number Diff line number Diff line
@@ -59,9 +59,9 @@ public class DozeParameters implements TunerService.Tunable {

    @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 @@ public class DozeParameters implements TunerService.Tunable {
        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