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

Commit 755cb9d5 authored by Kevin Chyn's avatar Kevin Chyn Committed by Automerger Merge Worker
Browse files

Merge "Add check in #shouldReverseRotationDirectionAroundZAxis" into udc-dev am: 7b4ea8e2

parents 80479c65 7b4ea8e2
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -111,9 +111,13 @@ final class DeviceStateController {
    }
    }


    /**
    /**
     * @return true if the rotation direction on the Z axis should be reversed.
     * @return true if the rotation direction on the Z axis should be reversed for the default
     * display.
     */
     */
    boolean shouldReverseRotationDirectionAroundZAxis() {
    boolean shouldReverseRotationDirectionAroundZAxis(@NonNull DisplayContent displayContent) {
        if (!displayContent.isDefaultDisplay) {
            return false;
        }
        return ArrayUtils.contains(mReverseRotationAroundZAxisStates, mCurrentState);
        return ArrayUtils.contains(mReverseRotationAroundZAxisStates, mCurrentState);
    }
    }


+2 −2
Original line number Original line Diff line number Diff line
@@ -950,7 +950,7 @@ public class DisplayRotation {
    }
    }


    void freezeRotation(int rotation) {
    void freezeRotation(int rotation) {
        if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) {
        if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) {
            rotation = RotationUtils.reverseRotationDirectionAroundZAxis(rotation);
            rotation = RotationUtils.reverseRotationDirectionAroundZAxis(rotation);
        }
        }


@@ -1225,7 +1225,7 @@ public class DisplayRotation {
        if (mFoldController != null && mFoldController.shouldIgnoreSensorRotation()) {
        if (mFoldController != null && mFoldController.shouldIgnoreSensorRotation()) {
            sensorRotation = -1;
            sensorRotation = -1;
        }
        }
        if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) {
        if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) {
            sensorRotation = RotationUtils.reverseRotationDirectionAroundZAxis(sensorRotation);
            sensorRotation = RotationUtils.reverseRotationDirectionAroundZAxis(sensorRotation);
        }
        }
        mLastSensorRotation = sensorRotation;
        mLastSensorRotation = sensorRotation;
+7 −4
Original line number Original line Diff line number Diff line
@@ -59,10 +59,10 @@ import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.hardware.SensorManager;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.devicestate.DeviceStateManager;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
import android.os.PowerManagerInternal;
import android.os.PowerManagerInternal;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.Handler;
import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.Presubmit;
import android.provider.Settings;
import android.provider.Settings;
import android.view.DisplayAddress;
import android.view.DisplayAddress;
@@ -518,7 +518,8 @@ public class DisplayRotationTests {
        mBuilder.build();
        mBuilder.build();
        configureDisplayRotation(SCREEN_ORIENTATION_PORTRAIT, false, false);
        configureDisplayRotation(SCREEN_ORIENTATION_PORTRAIT, false, false);


        when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(true);
        when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent))
                .thenReturn(true);


        thawRotation();
        thawRotation();


@@ -544,7 +545,8 @@ public class DisplayRotationTests {
    @Test
    @Test
    public void testFreezeRotation_reverseRotationDirectionAroundZAxis_yes() throws Exception {
    public void testFreezeRotation_reverseRotationDirectionAroundZAxis_yes() throws Exception {
        mBuilder.build();
        mBuilder.build();
        when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(true);
        when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent))
                .thenReturn(true);


        freezeRotation(Surface.ROTATION_90);
        freezeRotation(Surface.ROTATION_90);
        assertEquals(Surface.ROTATION_270, mTarget.getUserRotation());
        assertEquals(Surface.ROTATION_270, mTarget.getUserRotation());
@@ -553,7 +555,8 @@ public class DisplayRotationTests {
    @Test
    @Test
    public void testFreezeRotation_reverseRotationDirectionAroundZAxis_no() throws Exception {
    public void testFreezeRotation_reverseRotationDirectionAroundZAxis_no() throws Exception {
        mBuilder.build();
        mBuilder.build();
        when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(false);
        when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent))
                .thenReturn(false);


        freezeRotation(Surface.ROTATION_90);
        freezeRotation(Surface.ROTATION_90);
        assertEquals(Surface.ROTATION_90, mTarget.getUserRotation());
        assertEquals(Surface.ROTATION_90, mTarget.getUserRotation());