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

Commit 3d74e1f2 authored by Michael Wright's avatar Michael Wright Committed by Android Git Automerger
Browse files

am 09952195: Merge "Update rotation without holding the WOL lock." into mnc-dr-dev

* commit '09952195':
  Update rotation without holding the WOL lock.
parents 5bc2a2c0 09952195
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -217,6 +217,8 @@ public abstract class WindowOrientationListener {
     * It is called each time the orientation determination transitions from being
     * uncertain to being certain again, even if it is the same orientation as before.
     *
     * This should only be called on the Handler thread.
     *
     * @param rotation The new orientation of the device, one of the Surface.ROTATION_* constants.
     * @see android.view.Surface
     */
@@ -995,9 +997,13 @@ public abstract class WindowOrientationListener {

        @Override
        public void onSensorChanged(SensorEvent event) {
            int newRotation;
            synchronized (mLock) {
                mDesiredRotation = (int) event.values[0];
                evaluateRotationChangeLocked();
                newRotation = evaluateRotationChangeLocked();
            }
            if (newRotation >=0) {
                onProposedRotationChanged(newRotation);
            }
        }

@@ -1023,18 +1029,19 @@ public abstract class WindowOrientationListener {
            unscheduleRotationEvaluationLocked();
        }

        public void evaluateRotationChangeLocked() {
        public int evaluateRotationChangeLocked() {
            unscheduleRotationEvaluationLocked();
            if (mDesiredRotation == mProposedRotation) {
                return;
                return -1;
            }
            final long now = SystemClock.elapsedRealtimeNanos();
            if (isDesiredRotationAcceptableLocked(now)) {
                mProposedRotation = mDesiredRotation;
                onProposedRotationChanged(mProposedRotation);
                return mProposedRotation;
            } else {
                scheduleRotationEvaluationIfNecessaryLocked(now);
            }
            return -1;
        }

        private boolean isDesiredRotationAcceptableLocked(long now) {
@@ -1090,9 +1097,13 @@ public abstract class WindowOrientationListener {
        private Runnable mRotationEvaluator = new Runnable() {
            @Override
            public void run() {
                int newRotation;
                synchronized (mLock) {
                    mRotationEvaluationScheduled = false;
                    evaluateRotationChangeLocked();
                    newRotation = evaluateRotationChangeLocked();
                }
                if (newRotation >= 0) {
                    onProposedRotationChanged(newRotation);
                }
            }
        };