Merge "Fixes NPE from resolveRotation()" into tm-dev
This commit is contained in:
@@ -1167,6 +1167,10 @@ public abstract class WindowOrientationListener {
|
|||||||
if (mRotationResolverService == null) {
|
if (mRotationResolverService == null) {
|
||||||
mRotationResolverService = LocalServices.getService(
|
mRotationResolverService = LocalServices.getService(
|
||||||
RotationResolverInternal.class);
|
RotationResolverInternal.class);
|
||||||
|
if (mRotationResolverService == null) {
|
||||||
|
finalizeRotation(reportedRotation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String packageName = null;
|
String packageName = null;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class WindowOrientationListenerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSensorChanged_normalCase2() {
|
public void testOnSensorChanged_normalCase2() {
|
||||||
mWindowOrientationListener.mOrientationJudge.onSensorChanged(mFakeSensorEvent);
|
mWindowOrientationListener.mOrientationJudge.onSensorChanged(mFakeSensorEvent);
|
||||||
|
|
||||||
mFakeRotationResolverInternal.callbackWithFailureResult(
|
mFakeRotationResolverInternal.callbackWithFailureResult(
|
||||||
@@ -123,6 +123,15 @@ public class WindowOrientationListenerTest {
|
|||||||
assertThat(mFinalizedRotation).isEqualTo(DEFAULT_SENSOR_ROTATION);
|
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 {
|
static final class TestableRotationResolver extends RotationResolverInternal {
|
||||||
@Surface.Rotation
|
@Surface.Rotation
|
||||||
RotationResolverCallbackInternal mCallback;
|
RotationResolverCallbackInternal mCallback;
|
||||||
|
|||||||
Reference in New Issue
Block a user