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

Commit ad6aee64 authored by Yi Jiang's avatar Yi Jiang Committed by Automerger Merge Worker
Browse files

Merge "Fixes NPE from resolveRotation()" into tm-dev am: 5551c13e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16984944

Change-Id: I41125b429d8d7505f0222b3a44d0c40ae02fb321
parents 61e6d6e2 5551c13e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1167,6 +1167,10 @@ public abstract class WindowOrientationListener {
                if (mRotationResolverService == null) {
                    mRotationResolverService = LocalServices.getService(
                            RotationResolverInternal.class);
                    if (mRotationResolverService == null) {
                        finalizeRotation(reportedRotation);
                        return;
                    }
                }

                String packageName = null;
+10 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ public class WindowOrientationListenerTest {
    }

    @Test
    public void testSensorChanged_normalCase2() {
    public void testOnSensorChanged_normalCase2() {
        mWindowOrientationListener.mOrientationJudge.onSensorChanged(mFakeSensorEvent);

        mFakeRotationResolverInternal.callbackWithFailureResult(
@@ -123,6 +123,15 @@ public class WindowOrientationListenerTest {
        assertThat(mFinalizedRotation).isEqualTo(DEFAULT_SENSOR_ROTATION);
    }

    @Test
    public void testOnSensorChanged_rotationResolverServiceIsNull_useSensorResult() {
        mWindowOrientationListener.mRotationResolverService = null;

        mWindowOrientationListener.mOrientationJudge.onSensorChanged(mFakeSensorEvent);

        assertThat(mFinalizedRotation).isEqualTo(DEFAULT_SENSOR_ROTATION);
    }

    static final class TestableRotationResolver extends RotationResolverInternal {
        @Surface.Rotation
        RotationResolverCallbackInternal mCallback;