Loading packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java +20 −3 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.view.WindowManagerGlobal; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.statusbar.RegisterStatusBarResult; import com.android.settingslib.applications.InterestingConfigChanges; Loading Loading @@ -89,7 +90,16 @@ public class NavigationBarControllerImpl implements private final TaskbarDelegate mTaskbarDelegate; private final NavBarHelper mNavBarHelper; private int mNavMode; /** * Indicates whether the active display is a large screen, e.g. tablets, foldable devices in * the unfolded state. */ @VisibleForTesting boolean mIsLargeScreen; /** * Indicates whether the device is a phone, rather than everything else (e.g. foldables, * tablets) is considered not a handheld device. */ @VisibleForTesting boolean mIsPhone; /** A displayId - nav bar maps. */ @VisibleForTesting Loading Loading @@ -139,6 +149,8 @@ public class NavigationBarControllerImpl implements dumpManager, autoHideController, lightBarController, pipOptional, backAnimation.orElse(null), taskStackChangeListeners); mIsLargeScreen = isLargeScreen(mContext); mIsPhone = mContext.getResources().getIntArray(R.array.config_foldedDeviceStates).length == 0; dumpManager.registerDumpable(this); } Loading Loading @@ -253,9 +265,8 @@ public class NavigationBarControllerImpl implements /** @return {@code true} if taskbar is enabled, false otherwise */ private boolean initializeTaskbarIfNecessary() { // Enable for large screens or (phone AND flag is set); assuming phone = !mIsLargeScreen boolean taskbarEnabled = (mIsLargeScreen || enableTaskbarNavbarUnification()) && shouldCreateNavBarAndTaskBar(mContext.getDisplayId()); boolean taskbarEnabled = supportsTaskbar() && shouldCreateNavBarAndTaskBar( mContext.getDisplayId()); if (taskbarEnabled) { Trace.beginSection("NavigationBarController#initializeTaskbarIfNecessary"); Loading @@ -274,6 +285,12 @@ public class NavigationBarControllerImpl implements return taskbarEnabled; } @VisibleForTesting boolean supportsTaskbar() { // Enable for tablets, unfolded state on a foldable device or (non handheld AND flag is set) return mIsLargeScreen || (!mIsPhone && enableTaskbarNavbarUnification()); } private final CommandQueue.Callbacks mCommandQueueCallbacks = new CommandQueue.Callbacks() { @Override public void onDisplayRemoved(int displayId) { Loading packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerImplTest.java +23 −10 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static android.view.Display.INVALID_DISPLAY; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; import static com.android.wm.shell.Flags.enableTaskbarNavbarUnification; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; import static org.mockito.ArgumentMatchers.any; Loading Loading @@ -289,32 +291,43 @@ public class NavigationBarControllerImplTest extends SysuiTestCase { verify(mCommandQueue, never()).addCallback(any(TaskbarDelegate.class)); } @Test public void testConfigurationChange_taskbarNotInitialized() { Configuration configuration = mContext.getResources().getConfiguration(); when(Utilities.isLargeScreen(any())).thenReturn(true); mNavigationBarController.mIsLargeScreen = true; mNavigationBarController.onConfigChanged(configuration); verify(mTaskbarDelegate, never()).onConfigurationChanged(configuration); } @Test public void testConfigurationChangeUnfolding_taskbarInitialized() { public void testConfigurationChange_taskbarInitialized() { Configuration configuration = mContext.getResources().getConfiguration(); when(Utilities.isLargeScreen(any())).thenReturn(true); mNavigationBarController.mIsLargeScreen = true; when(mTaskbarDelegate.isInitialized()).thenReturn(true); mNavigationBarController.onConfigChanged(configuration); verify(mTaskbarDelegate, times(1)).onConfigurationChanged(configuration); } @Test public void testConfigurationChangeFolding_taskbarInitialized() { public void testShouldRenderTaskbar_taskbarNotRenderedOnPhone() { mNavigationBarController.mIsLargeScreen = false; mNavigationBarController.mIsPhone = true; assertFalse(mNavigationBarController.supportsTaskbar()); } @Test public void testShouldRenderTaskbar_taskbarRenderedOnTabletOrUnfolded() { mNavigationBarController.mIsLargeScreen = true; mNavigationBarController.mIsPhone = false; assertTrue(mNavigationBarController.supportsTaskbar()); } @Test public void testShouldRenderTaskbar_taskbarRenderedInFoldedState() { assumeTrue(enableTaskbarNavbarUnification()); Configuration configuration = mContext.getResources().getConfiguration(); when(Utilities.isLargeScreen(any())).thenReturn(false); when(mTaskbarDelegate.isInitialized()).thenReturn(true); mNavigationBarController.onConfigChanged(configuration); verify(mTaskbarDelegate, times(1)).onConfigurationChanged(configuration); mNavigationBarController.mIsLargeScreen = false; mNavigationBarController.mIsPhone = false; assertTrue(mNavigationBarController.supportsTaskbar()); } } Loading
packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarControllerImpl.java +20 −3 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.view.WindowManagerGlobal; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.statusbar.RegisterStatusBarResult; import com.android.settingslib.applications.InterestingConfigChanges; Loading Loading @@ -89,7 +90,16 @@ public class NavigationBarControllerImpl implements private final TaskbarDelegate mTaskbarDelegate; private final NavBarHelper mNavBarHelper; private int mNavMode; /** * Indicates whether the active display is a large screen, e.g. tablets, foldable devices in * the unfolded state. */ @VisibleForTesting boolean mIsLargeScreen; /** * Indicates whether the device is a phone, rather than everything else (e.g. foldables, * tablets) is considered not a handheld device. */ @VisibleForTesting boolean mIsPhone; /** A displayId - nav bar maps. */ @VisibleForTesting Loading Loading @@ -139,6 +149,8 @@ public class NavigationBarControllerImpl implements dumpManager, autoHideController, lightBarController, pipOptional, backAnimation.orElse(null), taskStackChangeListeners); mIsLargeScreen = isLargeScreen(mContext); mIsPhone = mContext.getResources().getIntArray(R.array.config_foldedDeviceStates).length == 0; dumpManager.registerDumpable(this); } Loading Loading @@ -253,9 +265,8 @@ public class NavigationBarControllerImpl implements /** @return {@code true} if taskbar is enabled, false otherwise */ private boolean initializeTaskbarIfNecessary() { // Enable for large screens or (phone AND flag is set); assuming phone = !mIsLargeScreen boolean taskbarEnabled = (mIsLargeScreen || enableTaskbarNavbarUnification()) && shouldCreateNavBarAndTaskBar(mContext.getDisplayId()); boolean taskbarEnabled = supportsTaskbar() && shouldCreateNavBarAndTaskBar( mContext.getDisplayId()); if (taskbarEnabled) { Trace.beginSection("NavigationBarController#initializeTaskbarIfNecessary"); Loading @@ -274,6 +285,12 @@ public class NavigationBarControllerImpl implements return taskbarEnabled; } @VisibleForTesting boolean supportsTaskbar() { // Enable for tablets, unfolded state on a foldable device or (non handheld AND flag is set) return mIsLargeScreen || (!mIsPhone && enableTaskbarNavbarUnification()); } private final CommandQueue.Callbacks mCommandQueueCallbacks = new CommandQueue.Callbacks() { @Override public void onDisplayRemoved(int displayId) { Loading
packages/SystemUI/tests/src/com/android/systemui/navigationbar/NavigationBarControllerImplTest.java +23 −10 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static android.view.Display.INVALID_DISPLAY; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; import static com.android.wm.shell.Flags.enableTaskbarNavbarUnification; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; import static org.mockito.ArgumentMatchers.any; Loading Loading @@ -289,32 +291,43 @@ public class NavigationBarControllerImplTest extends SysuiTestCase { verify(mCommandQueue, never()).addCallback(any(TaskbarDelegate.class)); } @Test public void testConfigurationChange_taskbarNotInitialized() { Configuration configuration = mContext.getResources().getConfiguration(); when(Utilities.isLargeScreen(any())).thenReturn(true); mNavigationBarController.mIsLargeScreen = true; mNavigationBarController.onConfigChanged(configuration); verify(mTaskbarDelegate, never()).onConfigurationChanged(configuration); } @Test public void testConfigurationChangeUnfolding_taskbarInitialized() { public void testConfigurationChange_taskbarInitialized() { Configuration configuration = mContext.getResources().getConfiguration(); when(Utilities.isLargeScreen(any())).thenReturn(true); mNavigationBarController.mIsLargeScreen = true; when(mTaskbarDelegate.isInitialized()).thenReturn(true); mNavigationBarController.onConfigChanged(configuration); verify(mTaskbarDelegate, times(1)).onConfigurationChanged(configuration); } @Test public void testConfigurationChangeFolding_taskbarInitialized() { public void testShouldRenderTaskbar_taskbarNotRenderedOnPhone() { mNavigationBarController.mIsLargeScreen = false; mNavigationBarController.mIsPhone = true; assertFalse(mNavigationBarController.supportsTaskbar()); } @Test public void testShouldRenderTaskbar_taskbarRenderedOnTabletOrUnfolded() { mNavigationBarController.mIsLargeScreen = true; mNavigationBarController.mIsPhone = false; assertTrue(mNavigationBarController.supportsTaskbar()); } @Test public void testShouldRenderTaskbar_taskbarRenderedInFoldedState() { assumeTrue(enableTaskbarNavbarUnification()); Configuration configuration = mContext.getResources().getConfiguration(); when(Utilities.isLargeScreen(any())).thenReturn(false); when(mTaskbarDelegate.isInitialized()).thenReturn(true); mNavigationBarController.onConfigChanged(configuration); verify(mTaskbarDelegate, times(1)).onConfigurationChanged(configuration); mNavigationBarController.mIsLargeScreen = false; mNavigationBarController.mIsPhone = false; assertTrue(mNavigationBarController.supportsTaskbar()); } }