Merge "WindowOrientationListener: Check if proposed rotation is in range"

This commit is contained in:
Treehugger Robot
2019-09-13 18:57:50 +00:00
committed by Gerrit Code Review

View File

@@ -1047,8 +1047,14 @@ public abstract class WindowOrientationListener {
@Override @Override
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
int newRotation; int newRotation;
int reportedRotation = (int) event.values[0];
if (reportedRotation < 0 || reportedRotation > 3) {
return;
}
synchronized (mLock) { synchronized (mLock) {
mDesiredRotation = (int) event.values[0]; mDesiredRotation = reportedRotation;
newRotation = evaluateRotationChangeLocked(); newRotation = evaluateRotationChangeLocked();
} }
if (newRotation >=0) { if (newRotation >=0) {