Add check in #shouldReverseRotationDirectionAroundZAxis
... to return false for non-default displays. The property that it uses (config_deviceStatesToReverseDefaultDisplayRotationAroundZAxis) indicates that it should only apply to default displays. Fixes: 281939489 Test: Steps in b/281939489#comment#11 Test: atest DisplayRotationTests Test: Rear display mode rotation with and without rotation lock Change-Id: I0d9d606b22c8cc5f2710b782faad2b44343d6462
This commit is contained in:
@@ -122,9 +122,13 @@ final class DeviceStateController implements DeviceStateManager.DeviceStateCallb
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
@@ -950,7 +950,7 @@ public class DisplayRotation {
|
||||
}
|
||||
|
||||
void freezeRotation(int rotation) {
|
||||
if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) {
|
||||
if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) {
|
||||
rotation = RotationUtils.reverseRotationDirectionAroundZAxis(rotation);
|
||||
}
|
||||
|
||||
@@ -1225,7 +1225,7 @@ public class DisplayRotation {
|
||||
if (mFoldController != null && mFoldController.shouldIgnoreSensorRotation()) {
|
||||
sensorRotation = -1;
|
||||
}
|
||||
if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()) {
|
||||
if (mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mDisplayContent)) {
|
||||
sensorRotation = RotationUtils.reverseRotationDirectionAroundZAxis(sensorRotation);
|
||||
}
|
||||
mLastSensorRotation = sensorRotation;
|
||||
|
||||
@@ -59,10 +59,10 @@ import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.devicestate.DeviceStateManager;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManagerInternal;
|
||||
import android.os.SystemClock;
|
||||
import android.os.Handler;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.provider.Settings;
|
||||
import android.view.DisplayAddress;
|
||||
@@ -518,7 +518,8 @@ public class DisplayRotationTests {
|
||||
mBuilder.build();
|
||||
configureDisplayRotation(SCREEN_ORIENTATION_PORTRAIT, false, false);
|
||||
|
||||
when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(true);
|
||||
when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent))
|
||||
.thenReturn(true);
|
||||
|
||||
thawRotation();
|
||||
|
||||
@@ -544,7 +545,8 @@ public class DisplayRotationTests {
|
||||
@Test
|
||||
public void testFreezeRotation_reverseRotationDirectionAroundZAxis_yes() throws Exception {
|
||||
mBuilder.build();
|
||||
when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(true);
|
||||
when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent))
|
||||
.thenReturn(true);
|
||||
|
||||
freezeRotation(Surface.ROTATION_90);
|
||||
assertEquals(Surface.ROTATION_270, mTarget.getUserRotation());
|
||||
@@ -553,7 +555,8 @@ public class DisplayRotationTests {
|
||||
@Test
|
||||
public void testFreezeRotation_reverseRotationDirectionAroundZAxis_no() throws Exception {
|
||||
mBuilder.build();
|
||||
when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis()).thenReturn(false);
|
||||
when(mDeviceStateController.shouldReverseRotationDirectionAroundZAxis(mMockDisplayContent))
|
||||
.thenReturn(false);
|
||||
|
||||
freezeRotation(Surface.ROTATION_90);
|
||||
assertEquals(Surface.ROTATION_90, mTarget.getUserRotation());
|
||||
|
||||
Reference in New Issue
Block a user