Loading services/foldables/devicestateprovider/src/com/android/server/policy/FoldableDeviceStateProvider.java +5 −2 Original line number Diff line number Diff line Loading @@ -367,8 +367,11 @@ public final class FoldableDeviceStateProvider implements DeviceStateProvider, // TODO(b/312397262): consider virtual displays cases synchronized (mLock) { if (mIsDualDisplayBlockingEnabled && !mExternalDisplaysConnected.get(displayId, false) && mDisplayManager.getDisplay(displayId).getType() == TYPE_EXTERNAL) { && !mExternalDisplaysConnected.get(displayId, false)) { var display = mDisplayManager.getDisplay(displayId); if (display == null || display.getType() != TYPE_EXTERNAL) { return; } mExternalDisplaysConnected.put(displayId, true); // Only update the supported state when going from 0 external display to 1 Loading services/foldables/devicestateprovider/tests/src/com/android/server/policy/FoldableDeviceStateProviderTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -590,6 +590,20 @@ public final class FoldableDeviceStateProviderTest { assertThat(mProvider.hasNoConnectedExternalDisplay()).isFalse(); } @Test public void testOnDisplayAddedWithNullDisplayDoesNotThrowNPE() { createProvider( createConfig( /* identifier= */ 1, /* name= */ "ONE", /* flags= */0, (c) -> true, FoldableDeviceStateProvider::hasNoConnectedExternalDisplay) ); when(mDisplayManager.getDisplay(1)).thenReturn(null); // This call should not throw NPE. mProvider.onDisplayAdded(1); } @Test public void hasNoConnectedDisplay_afterExternalDisplayAddedAndRemoved_returnsTrue() { createProvider( Loading Loading
services/foldables/devicestateprovider/src/com/android/server/policy/FoldableDeviceStateProvider.java +5 −2 Original line number Diff line number Diff line Loading @@ -367,8 +367,11 @@ public final class FoldableDeviceStateProvider implements DeviceStateProvider, // TODO(b/312397262): consider virtual displays cases synchronized (mLock) { if (mIsDualDisplayBlockingEnabled && !mExternalDisplaysConnected.get(displayId, false) && mDisplayManager.getDisplay(displayId).getType() == TYPE_EXTERNAL) { && !mExternalDisplaysConnected.get(displayId, false)) { var display = mDisplayManager.getDisplay(displayId); if (display == null || display.getType() != TYPE_EXTERNAL) { return; } mExternalDisplaysConnected.put(displayId, true); // Only update the supported state when going from 0 external display to 1 Loading
services/foldables/devicestateprovider/tests/src/com/android/server/policy/FoldableDeviceStateProviderTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -590,6 +590,20 @@ public final class FoldableDeviceStateProviderTest { assertThat(mProvider.hasNoConnectedExternalDisplay()).isFalse(); } @Test public void testOnDisplayAddedWithNullDisplayDoesNotThrowNPE() { createProvider( createConfig( /* identifier= */ 1, /* name= */ "ONE", /* flags= */0, (c) -> true, FoldableDeviceStateProvider::hasNoConnectedExternalDisplay) ); when(mDisplayManager.getDisplay(1)).thenReturn(null); // This call should not throw NPE. mProvider.onDisplayAdded(1); } @Test public void hasNoConnectedDisplay_afterExternalDisplayAddedAndRemoved_returnsTrue() { createProvider( Loading