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

Commit ee4c9b7d authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Named wake lock reasons

Fixes: 121039718
Test: atest ScrimControllerTest
Test: atest KeepAwakeAnimationListenerTest
Test: atest SettableWakeLockTest
Test: atest WakeLockTest
Test: adb shell dumpsys activity service com.android.systemui
Change-Id: I612874da597fba6974edd1f702932ee1a5629fc7
parent 9a8bcf5f
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ public class DozeMachine {

    static final String TAG = "DozeMachine";
    static final boolean DEBUG = DozeService.DEBUG;
    private static final String REASON_CHANGE_STATE = "DozeMachine#requestState";
    private static final String REASON_HELD_FOR_STATE = "DozeMachine#heldForState";

    public enum State {
        /** Default state. Transition to INITIALIZED to get Doze going. */
@@ -167,14 +169,14 @@ public class DozeMachine {
        boolean runNow = !isExecutingTransition();
        mQueuedRequests.add(requestedState);
        if (runNow) {
            mWakeLock.acquire();
            mWakeLock.acquire(REASON_CHANGE_STATE);
            for (int i = 0; i < mQueuedRequests.size(); i++) {
                // Transitions in Parts can call back into requestState, which will
                // cause mQueuedRequests to grow.
                transitionTo(mQueuedRequests.get(i), pulseReason);
            }
            mQueuedRequests.clear();
            mWakeLock.release();
            mWakeLock.release(REASON_CHANGE_STATE);
        }
    }

@@ -311,10 +313,10 @@ public class DozeMachine {
    private void updateWakeLockState(State newState) {
        boolean staysAwake = newState.staysAwake();
        if (mWakeLockHeldForCurrentState && !staysAwake) {
            mWakeLock.release();
            mWakeLock.release(REASON_HELD_FOR_STATE);
            mWakeLockHeldForCurrentState = false;
        } else if (!mWakeLockHeldForCurrentState && staysAwake) {
            mWakeLock.acquire();
            mWakeLock.acquire(REASON_HELD_FOR_STATE);
            mWakeLockHeldForCurrentState = true;
        }
    }
@@ -336,6 +338,7 @@ public class DozeMachine {
    public void dump(PrintWriter pw) {
        pw.print(" state="); pw.println(mState);
        pw.print(" wakeLockHeldForCurrentState="); pw.println(mWakeLockHeldForCurrentState);
        pw.print(" wakeLock="); pw.println(mWakeLock);
        pw.println("Parts:");
        for (Part p : mParts) {
            p.dump(pw);
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public class DozeScreenState implements DozeMachine.Part {
        mDozeService = service;
        mHandler = handler;
        mParameters = parameters;
        mWakeLock = new SettableWakeLock(wakeLock);
        mWakeLock = new SettableWakeLock(wakeLock, TAG);
    }

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -348,7 +348,7 @@ public class DozeTriggers implements DozeMachine.Part {
            mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL, 0,
                    mHandler);
            mHandler.postDelayed(this, TIMEOUT_DELAY_MS);
            mWakeLock.acquire();
            mWakeLock.acquire(TAG);
            mRegistered = true;
        }

@@ -383,7 +383,7 @@ public class DozeTriggers implements DozeMachine.Part {
            }
            onProximityResult(result);
            if (wasRegistered) {
                mWakeLock.release();
                mWakeLock.release(TAG);
            }
            mFinished = true;
        }
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ public class KeyguardIndicationController implements StateListener {
                mTextView.getTextColors() : ColorStateList.valueOf(Color.WHITE);
        mDisclosure = indicationArea.findViewById(R.id.keyguard_indication_enterprise_disclosure);
        mLockIcon = lockIcon;
        mWakeLock = new SettableWakeLock(wakeLock);
        mWakeLock = new SettableWakeLock(wakeLock, TAG);

        Resources res = context.getResources();
        mSlowThreshold = res.getInteger(R.integer.config_chargingSlowlyThreshold);
+2 −2
Original line number Diff line number Diff line
@@ -340,7 +340,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        if (!mWakeLockHeld) {
            if (mWakeLock != null) {
                mWakeLockHeld = true;
                mWakeLock.acquire();
                mWakeLock.acquire(TAG);
            } else {
                Log.w(TAG, "Cannot hold wake lock, it has not been set yet");
            }
@@ -654,7 +654,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo

    private void onFinished(Callback callback) {
        if (mWakeLockHeld) {
            mWakeLock.release();
            mWakeLock.release(TAG);
            mWakeLockHeld = false;
        }

Loading