Loading packages/SystemUI/src/com/android/systemui/Dependency.java +3 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import com.android.systemui.statusbar.notification.stack.AmbientState; import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager; import com.android.systemui.statusbar.phone.LightBarController; import com.android.systemui.statusbar.phone.ScreenOffAnimationController; import com.android.systemui.statusbar.phone.StatusBarContentInsetsProvider; import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; Loading Loading @@ -139,6 +140,7 @@ public class Dependency { @Inject Lazy<SysUiState> mSysUiStateFlagsContainer; @Inject Lazy<CommandQueue> mCommandQueue; @Inject Lazy<UiEventLogger> mUiEventLogger; @Inject Lazy<StatusBarContentInsetsProvider> mContentInsetsProviderLazy; @Inject Lazy<FeatureFlags> mFeatureFlagsLazy; @Inject Lazy<NotificationSectionsManager> mNotificationSectionsManagerLazy; @Inject Lazy<ScreenOffAnimationController> mScreenOffAnimationController; Loading Loading @@ -184,6 +186,7 @@ public class Dependency { mProviders.put(CommandQueue.class, mCommandQueue::get); mProviders.put(UiEventLogger.class, mUiEventLogger::get); mProviders.put(FeatureFlags.class, mFeatureFlagsLazy::get); mProviders.put(StatusBarContentInsetsProvider.class, mContentInsetsProviderLazy::get); mProviders.put(NotificationSectionsManager.class, mNotificationSectionsManagerLazy::get); mProviders.put(ScreenOffAnimationController.class, mScreenOffAnimationController::get); mProviders.put(AmbientState.class, mAmbientStateLazy::get); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +5 −36 Original line number Diff line number Diff line Loading @@ -32,8 +32,6 @@ import android.view.accessibility.AccessibilityEvent; import android.widget.FrameLayout; import android.widget.LinearLayout; import androidx.annotation.NonNull; import com.android.internal.policy.SystemBarUtils; import com.android.systemui.Dependency; import com.android.systemui.Flags; Loading @@ -49,6 +47,7 @@ import java.util.Objects; public class PhoneStatusBarView extends FrameLayout { private static final String TAG = "PhoneStatusBarView"; private final StatusBarContentInsetsProvider mContentInsetsProvider; private final StatusBarWindowController mStatusBarWindowController; private int mRotationOrientation = -1; Loading @@ -61,10 +60,6 @@ public class PhoneStatusBarView extends FrameLayout { private int mStatusBarHeight; @Nullable private Gefingerpoken mTouchEventHandler; @Nullable private HasCornerCutoutFetcher mHasCornerCutoutFetcher; @Nullable private InsetsFetcher mInsetsFetcher; private int mDensity; private float mFontScale; Loading @@ -75,6 +70,7 @@ public class PhoneStatusBarView extends FrameLayout { public PhoneStatusBarView(Context context, AttributeSet attrs) { super(context, attrs); mContentInsetsProvider = Dependency.get(StatusBarContentInsetsProvider.class); mStatusBarWindowController = Dependency.get(StatusBarWindowController.class); } Loading @@ -82,14 +78,6 @@ public class PhoneStatusBarView extends FrameLayout { mTouchEventHandler = handler; } void setHasCornerCutoutFetcher(@NonNull HasCornerCutoutFetcher cornerCutoutFetcher) { mHasCornerCutoutFetcher = cornerCutoutFetcher; } void setInsetsFetcher(@NonNull InsetsFetcher insetsFetcher) { mInsetsFetcher = insetsFetcher; } void init(StatusBarUserChipViewModel viewModel) { StatusBarUserSwitcherContainer container = findViewById(R.id.user_switcher_container); StatusBarUserChipViewBinder.bind(container, viewModel); Loading Loading @@ -282,14 +270,7 @@ public class PhoneStatusBarView extends FrameLayout { return; } boolean hasCornerCutout; if (mHasCornerCutoutFetcher != null) { hasCornerCutout = mHasCornerCutoutFetcher.fetchHasCornerCutout(); } else { Log.e(TAG, "mHasCornerCutoutFetcher unexpectedly null"); hasCornerCutout = true; } boolean hasCornerCutout = mContentInsetsProvider.currentRotationHasCornerCutout(); if (mDisplayCutout == null || mDisplayCutout.isEmpty() || hasCornerCutout) { mCutoutSpace.setVisibility(View.GONE); return; Loading @@ -307,12 +288,8 @@ public class PhoneStatusBarView extends FrameLayout { } private void updateSafeInsets() { if (mInsetsFetcher == null) { Log.e(TAG, "mInsetsFetcher unexpectedly null"); return; } Insets insets = mInsetsFetcher.fetchInsets(); Insets insets = mContentInsetsProvider .getStatusBarContentInsetsForCurrentRotation(); setPadding( insets.left, insets.top, Loading @@ -326,12 +303,4 @@ public class PhoneStatusBarView extends FrameLayout { } mStatusBarWindowController.refreshStatusBarHeight(); } interface HasCornerCutoutFetcher { boolean fetchHasCornerCutout(); } interface InsetsFetcher { Insets fetchInsets(); } } packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt +0 −10 Original line number Diff line number Diff line Loading @@ -73,7 +73,6 @@ private constructor( private val configurationController: ConfigurationController, private val statusOverlayHoverListenerFactory: StatusOverlayHoverListenerFactory, private val darkIconDispatcher: DarkIconDispatcher, private val statusBarContentInsetsProvider: StatusBarContentInsetsProvider, ) : ViewController<PhoneStatusBarView>(view) { private lateinit var battery: BatteryMeterView Loading Loading @@ -156,14 +155,7 @@ private constructor( } init { // These should likely be done in `onInit`, not `init`. mView.setTouchEventHandler(PhoneStatusBarViewTouchHandler()) mView.setHasCornerCutoutFetcher { statusBarContentInsetsProvider.currentRotationHasCornerCutout() } mView.setInsetsFetcher { statusBarContentInsetsProvider.getStatusBarContentInsetsForCurrentRotation() } mView.init(userChipViewModel) } Loading Loading @@ -318,7 +310,6 @@ private constructor( private val configurationController: ConfigurationController, private val statusOverlayHoverListenerFactory: StatusOverlayHoverListenerFactory, private val darkIconDispatcher: DarkIconDispatcher, private val statusBarContentInsetsProvider: StatusBarContentInsetsProvider, ) { fun create(view: PhoneStatusBarView): PhoneStatusBarViewController { val statusBarMoveFromCenterAnimationController = Loading @@ -344,7 +335,6 @@ private constructor( configurationController, statusOverlayHoverListenerFactory, darkIconDispatcher, statusBarContentInsetsProvider, ) } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewControllerTest.kt +0 −1 Original line number Diff line number Diff line Loading @@ -391,7 +391,6 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { configurationController, mStatusOverlayHoverListenerFactory, fakeDarkIconDispatcher, mock(StatusBarContentInsetsProvider::class.java), ) .create(view) .also { it.init() } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt +26 −40 Original line number Diff line number Diff line Loading @@ -56,14 +56,21 @@ class PhoneStatusBarViewTest : SysuiTestCase() { private val systemIconsContainer: View get() = view.requireViewById(R.id.system_icons) private val contentInsetsProvider = mock<StatusBarContentInsetsProvider>() private val windowController = mock<StatusBarWindowController>() @Before fun setUp() { mDependency.injectTestDependency( StatusBarContentInsetsProvider::class.java, contentInsetsProvider ) mDependency.injectTestDependency(StatusBarWindowController::class.java, windowController) context.ensureTestableResources() view = spy(createStatusBarView()) whenever(view.rootWindowInsets).thenReturn(emptyWindowInsets()) whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(Insets.NONE) } @Test Loading Loading @@ -234,7 +241,8 @@ class PhoneStatusBarViewTest : SysuiTestCase() { @Test fun onAttachedToWindow_updatesLeftTopRightPaddingsBasedOnInsets() { val insets = Insets.of(/* left= */ 10, /* top= */ 20, /* right= */ 30, /* bottom= */ 40) view.setInsetsFetcher { insets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(insets) view.onAttachedToWindow() Loading @@ -244,24 +252,11 @@ class PhoneStatusBarViewTest : SysuiTestCase() { assertThat(view.paddingBottom).isEqualTo(0) } @Test fun onAttachedToWindow_noInsetsFetcher_noCrash() { // Don't call `PhoneStatusBarView.setInsetsFetcher` // WHEN the view is attached view.onAttachedToWindow() // THEN there's no crash, and the padding stays as it was assertThat(view.paddingLeft).isEqualTo(0) assertThat(view.paddingTop).isEqualTo(0) assertThat(view.paddingRight).isEqualTo(0) assertThat(view.paddingBottom).isEqualTo(0) } @Test fun onConfigurationChanged_updatesLeftTopRightPaddingsBasedOnInsets() { val insets = Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10) view.setInsetsFetcher { insets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(insets) view.onConfigurationChanged(Configuration()) Loading @@ -271,32 +266,18 @@ class PhoneStatusBarViewTest : SysuiTestCase() { assertThat(view.paddingBottom).isEqualTo(0) } @Test fun onConfigurationChanged_noInsetsFetcher_noCrash() { // Don't call `PhoneStatusBarView.setInsetsFetcher` // WHEN the view is attached view.onConfigurationChanged(Configuration()) // THEN there's no crash, and the padding stays as it was assertThat(view.paddingLeft).isEqualTo(0) assertThat(view.paddingTop).isEqualTo(0) assertThat(view.paddingRight).isEqualTo(0) assertThat(view.paddingBottom).isEqualTo(0) } @Test fun onConfigurationChanged_noRelevantChange_doesNotUpdateInsets() { val previousInsets = Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10) view.setInsetsFetcher { previousInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(previousInsets) context.orCreateTestableResources.overrideConfiguration(Configuration()) view.onAttachedToWindow() val newInsets = Insets.NONE view.setInsetsFetcher { newInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(newInsets) view.onConfigurationChanged(Configuration()) assertThat(view.paddingLeft).isEqualTo(previousInsets.left) Loading @@ -309,14 +290,16 @@ class PhoneStatusBarViewTest : SysuiTestCase() { fun onConfigurationChanged_densityChanged_updatesInsets() { val previousInsets = Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10) view.setInsetsFetcher { previousInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(previousInsets) val configuration = Configuration() configuration.densityDpi = 123 context.orCreateTestableResources.overrideConfiguration(configuration) view.onAttachedToWindow() val newInsets = Insets.NONE view.setInsetsFetcher { newInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(newInsets) configuration.densityDpi = 456 view.onConfigurationChanged(configuration) Loading @@ -330,14 +313,16 @@ class PhoneStatusBarViewTest : SysuiTestCase() { fun onConfigurationChanged_fontScaleChanged_updatesInsets() { val previousInsets = Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10) view.setInsetsFetcher { previousInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(previousInsets) val configuration = Configuration() configuration.fontScale = 1f context.orCreateTestableResources.overrideConfiguration(configuration) view.onAttachedToWindow() val newInsets = Insets.NONE view.setInsetsFetcher { newInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(newInsets) configuration.fontScale = 2f view.onConfigurationChanged(configuration) Loading @@ -363,7 +348,8 @@ class PhoneStatusBarViewTest : SysuiTestCase() { @Test fun onApplyWindowInsets_updatesLeftTopRightPaddingsBasedOnInsets() { val insets = Insets.of(/* left= */ 90, /* top= */ 10, /* right= */ 45, /* bottom= */ 50) view.setInsetsFetcher { insets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(insets) view.onApplyWindowInsets(WindowInsets(Rect())) Loading Loading @@ -404,7 +390,7 @@ class PhoneStatusBarViewTest : SysuiTestCase() { /* typeVisibilityMap = */ booleanArrayOf(), /* isRound = */ false, /* forceConsumingTypes = */ 0, /* forceConsumingOpaqueCaptionBar = */ false, /* forceConsumingCaptionBar = */ false, /* suppressScrimTypes = */ 0, /* displayCutout = */ DisplayCutout.NO_CUTOUT, /* roundedCorners = */ RoundedCorners.NO_ROUNDED_CORNERS, Loading Loading
packages/SystemUI/src/com/android/systemui/Dependency.java +3 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import com.android.systemui.statusbar.notification.stack.AmbientState; import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager; import com.android.systemui.statusbar.phone.LightBarController; import com.android.systemui.statusbar.phone.ScreenOffAnimationController; import com.android.systemui.statusbar.phone.StatusBarContentInsetsProvider; import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; Loading Loading @@ -139,6 +140,7 @@ public class Dependency { @Inject Lazy<SysUiState> mSysUiStateFlagsContainer; @Inject Lazy<CommandQueue> mCommandQueue; @Inject Lazy<UiEventLogger> mUiEventLogger; @Inject Lazy<StatusBarContentInsetsProvider> mContentInsetsProviderLazy; @Inject Lazy<FeatureFlags> mFeatureFlagsLazy; @Inject Lazy<NotificationSectionsManager> mNotificationSectionsManagerLazy; @Inject Lazy<ScreenOffAnimationController> mScreenOffAnimationController; Loading Loading @@ -184,6 +186,7 @@ public class Dependency { mProviders.put(CommandQueue.class, mCommandQueue::get); mProviders.put(UiEventLogger.class, mUiEventLogger::get); mProviders.put(FeatureFlags.class, mFeatureFlagsLazy::get); mProviders.put(StatusBarContentInsetsProvider.class, mContentInsetsProviderLazy::get); mProviders.put(NotificationSectionsManager.class, mNotificationSectionsManagerLazy::get); mProviders.put(ScreenOffAnimationController.class, mScreenOffAnimationController::get); mProviders.put(AmbientState.class, mAmbientStateLazy::get); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +5 −36 Original line number Diff line number Diff line Loading @@ -32,8 +32,6 @@ import android.view.accessibility.AccessibilityEvent; import android.widget.FrameLayout; import android.widget.LinearLayout; import androidx.annotation.NonNull; import com.android.internal.policy.SystemBarUtils; import com.android.systemui.Dependency; import com.android.systemui.Flags; Loading @@ -49,6 +47,7 @@ import java.util.Objects; public class PhoneStatusBarView extends FrameLayout { private static final String TAG = "PhoneStatusBarView"; private final StatusBarContentInsetsProvider mContentInsetsProvider; private final StatusBarWindowController mStatusBarWindowController; private int mRotationOrientation = -1; Loading @@ -61,10 +60,6 @@ public class PhoneStatusBarView extends FrameLayout { private int mStatusBarHeight; @Nullable private Gefingerpoken mTouchEventHandler; @Nullable private HasCornerCutoutFetcher mHasCornerCutoutFetcher; @Nullable private InsetsFetcher mInsetsFetcher; private int mDensity; private float mFontScale; Loading @@ -75,6 +70,7 @@ public class PhoneStatusBarView extends FrameLayout { public PhoneStatusBarView(Context context, AttributeSet attrs) { super(context, attrs); mContentInsetsProvider = Dependency.get(StatusBarContentInsetsProvider.class); mStatusBarWindowController = Dependency.get(StatusBarWindowController.class); } Loading @@ -82,14 +78,6 @@ public class PhoneStatusBarView extends FrameLayout { mTouchEventHandler = handler; } void setHasCornerCutoutFetcher(@NonNull HasCornerCutoutFetcher cornerCutoutFetcher) { mHasCornerCutoutFetcher = cornerCutoutFetcher; } void setInsetsFetcher(@NonNull InsetsFetcher insetsFetcher) { mInsetsFetcher = insetsFetcher; } void init(StatusBarUserChipViewModel viewModel) { StatusBarUserSwitcherContainer container = findViewById(R.id.user_switcher_container); StatusBarUserChipViewBinder.bind(container, viewModel); Loading Loading @@ -282,14 +270,7 @@ public class PhoneStatusBarView extends FrameLayout { return; } boolean hasCornerCutout; if (mHasCornerCutoutFetcher != null) { hasCornerCutout = mHasCornerCutoutFetcher.fetchHasCornerCutout(); } else { Log.e(TAG, "mHasCornerCutoutFetcher unexpectedly null"); hasCornerCutout = true; } boolean hasCornerCutout = mContentInsetsProvider.currentRotationHasCornerCutout(); if (mDisplayCutout == null || mDisplayCutout.isEmpty() || hasCornerCutout) { mCutoutSpace.setVisibility(View.GONE); return; Loading @@ -307,12 +288,8 @@ public class PhoneStatusBarView extends FrameLayout { } private void updateSafeInsets() { if (mInsetsFetcher == null) { Log.e(TAG, "mInsetsFetcher unexpectedly null"); return; } Insets insets = mInsetsFetcher.fetchInsets(); Insets insets = mContentInsetsProvider .getStatusBarContentInsetsForCurrentRotation(); setPadding( insets.left, insets.top, Loading @@ -326,12 +303,4 @@ public class PhoneStatusBarView extends FrameLayout { } mStatusBarWindowController.refreshStatusBarHeight(); } interface HasCornerCutoutFetcher { boolean fetchHasCornerCutout(); } interface InsetsFetcher { Insets fetchInsets(); } }
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt +0 −10 Original line number Diff line number Diff line Loading @@ -73,7 +73,6 @@ private constructor( private val configurationController: ConfigurationController, private val statusOverlayHoverListenerFactory: StatusOverlayHoverListenerFactory, private val darkIconDispatcher: DarkIconDispatcher, private val statusBarContentInsetsProvider: StatusBarContentInsetsProvider, ) : ViewController<PhoneStatusBarView>(view) { private lateinit var battery: BatteryMeterView Loading Loading @@ -156,14 +155,7 @@ private constructor( } init { // These should likely be done in `onInit`, not `init`. mView.setTouchEventHandler(PhoneStatusBarViewTouchHandler()) mView.setHasCornerCutoutFetcher { statusBarContentInsetsProvider.currentRotationHasCornerCutout() } mView.setInsetsFetcher { statusBarContentInsetsProvider.getStatusBarContentInsetsForCurrentRotation() } mView.init(userChipViewModel) } Loading Loading @@ -318,7 +310,6 @@ private constructor( private val configurationController: ConfigurationController, private val statusOverlayHoverListenerFactory: StatusOverlayHoverListenerFactory, private val darkIconDispatcher: DarkIconDispatcher, private val statusBarContentInsetsProvider: StatusBarContentInsetsProvider, ) { fun create(view: PhoneStatusBarView): PhoneStatusBarViewController { val statusBarMoveFromCenterAnimationController = Loading @@ -344,7 +335,6 @@ private constructor( configurationController, statusOverlayHoverListenerFactory, darkIconDispatcher, statusBarContentInsetsProvider, ) } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewControllerTest.kt +0 −1 Original line number Diff line number Diff line Loading @@ -391,7 +391,6 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { configurationController, mStatusOverlayHoverListenerFactory, fakeDarkIconDispatcher, mock(StatusBarContentInsetsProvider::class.java), ) .create(view) .also { it.init() } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt +26 −40 Original line number Diff line number Diff line Loading @@ -56,14 +56,21 @@ class PhoneStatusBarViewTest : SysuiTestCase() { private val systemIconsContainer: View get() = view.requireViewById(R.id.system_icons) private val contentInsetsProvider = mock<StatusBarContentInsetsProvider>() private val windowController = mock<StatusBarWindowController>() @Before fun setUp() { mDependency.injectTestDependency( StatusBarContentInsetsProvider::class.java, contentInsetsProvider ) mDependency.injectTestDependency(StatusBarWindowController::class.java, windowController) context.ensureTestableResources() view = spy(createStatusBarView()) whenever(view.rootWindowInsets).thenReturn(emptyWindowInsets()) whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(Insets.NONE) } @Test Loading Loading @@ -234,7 +241,8 @@ class PhoneStatusBarViewTest : SysuiTestCase() { @Test fun onAttachedToWindow_updatesLeftTopRightPaddingsBasedOnInsets() { val insets = Insets.of(/* left= */ 10, /* top= */ 20, /* right= */ 30, /* bottom= */ 40) view.setInsetsFetcher { insets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(insets) view.onAttachedToWindow() Loading @@ -244,24 +252,11 @@ class PhoneStatusBarViewTest : SysuiTestCase() { assertThat(view.paddingBottom).isEqualTo(0) } @Test fun onAttachedToWindow_noInsetsFetcher_noCrash() { // Don't call `PhoneStatusBarView.setInsetsFetcher` // WHEN the view is attached view.onAttachedToWindow() // THEN there's no crash, and the padding stays as it was assertThat(view.paddingLeft).isEqualTo(0) assertThat(view.paddingTop).isEqualTo(0) assertThat(view.paddingRight).isEqualTo(0) assertThat(view.paddingBottom).isEqualTo(0) } @Test fun onConfigurationChanged_updatesLeftTopRightPaddingsBasedOnInsets() { val insets = Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10) view.setInsetsFetcher { insets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(insets) view.onConfigurationChanged(Configuration()) Loading @@ -271,32 +266,18 @@ class PhoneStatusBarViewTest : SysuiTestCase() { assertThat(view.paddingBottom).isEqualTo(0) } @Test fun onConfigurationChanged_noInsetsFetcher_noCrash() { // Don't call `PhoneStatusBarView.setInsetsFetcher` // WHEN the view is attached view.onConfigurationChanged(Configuration()) // THEN there's no crash, and the padding stays as it was assertThat(view.paddingLeft).isEqualTo(0) assertThat(view.paddingTop).isEqualTo(0) assertThat(view.paddingRight).isEqualTo(0) assertThat(view.paddingBottom).isEqualTo(0) } @Test fun onConfigurationChanged_noRelevantChange_doesNotUpdateInsets() { val previousInsets = Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10) view.setInsetsFetcher { previousInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(previousInsets) context.orCreateTestableResources.overrideConfiguration(Configuration()) view.onAttachedToWindow() val newInsets = Insets.NONE view.setInsetsFetcher { newInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(newInsets) view.onConfigurationChanged(Configuration()) assertThat(view.paddingLeft).isEqualTo(previousInsets.left) Loading @@ -309,14 +290,16 @@ class PhoneStatusBarViewTest : SysuiTestCase() { fun onConfigurationChanged_densityChanged_updatesInsets() { val previousInsets = Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10) view.setInsetsFetcher { previousInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(previousInsets) val configuration = Configuration() configuration.densityDpi = 123 context.orCreateTestableResources.overrideConfiguration(configuration) view.onAttachedToWindow() val newInsets = Insets.NONE view.setInsetsFetcher { newInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(newInsets) configuration.densityDpi = 456 view.onConfigurationChanged(configuration) Loading @@ -330,14 +313,16 @@ class PhoneStatusBarViewTest : SysuiTestCase() { fun onConfigurationChanged_fontScaleChanged_updatesInsets() { val previousInsets = Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10) view.setInsetsFetcher { previousInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(previousInsets) val configuration = Configuration() configuration.fontScale = 1f context.orCreateTestableResources.overrideConfiguration(configuration) view.onAttachedToWindow() val newInsets = Insets.NONE view.setInsetsFetcher { newInsets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(newInsets) configuration.fontScale = 2f view.onConfigurationChanged(configuration) Loading @@ -363,7 +348,8 @@ class PhoneStatusBarViewTest : SysuiTestCase() { @Test fun onApplyWindowInsets_updatesLeftTopRightPaddingsBasedOnInsets() { val insets = Insets.of(/* left= */ 90, /* top= */ 10, /* right= */ 45, /* bottom= */ 50) view.setInsetsFetcher { insets } whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) .thenReturn(insets) view.onApplyWindowInsets(WindowInsets(Rect())) Loading Loading @@ -404,7 +390,7 @@ class PhoneStatusBarViewTest : SysuiTestCase() { /* typeVisibilityMap = */ booleanArrayOf(), /* isRound = */ false, /* forceConsumingTypes = */ 0, /* forceConsumingOpaqueCaptionBar = */ false, /* forceConsumingCaptionBar = */ false, /* suppressScrimTypes = */ 0, /* displayCutout = */ DisplayCutout.NO_CUTOUT, /* roundedCorners = */ RoundedCorners.NO_ROUNDED_CORNERS, Loading