Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30486e7a authored by Chris Göllner's avatar Chris Göllner
Browse files

Fix status bar window height not being updated on certain rotations

This was causing status bar icons being truncated.

Certain rotation events don't trigger an application wide configuration
change event. An example is when going from portrait to upside down, or
when going from landscape to seascape.
It triggers a configuration change on the PhoneStatusBarView though.

The status bar window height was being updated on application level
configuration changes. For that reason it was not being updated always.

The fix is to update the height based on configuration change events
from the PhoneStatusBarView instead of the application.

Test: PhoneStatusBarViewTest.kt
Test: CentralSurfacesImplTest.java
Test: Manually
Fixes: 323299264
Flag: ACONFIG com.android.systemui.truncated_status_bar_icons_fix DISABLED

Change-Id: I37dd1b6b446b6975a8aa6ba8d597cd95a990f74c
parent ca4a84d4
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -226,6 +226,17 @@ flag {
   bug: "308676488"
}

flag {
    name: "truncated_status_bar_icons_fix"
    namespace: "systemui"
    description: "Fixes the status bar icons being trunacted due to the status bar window height "
        "not being updated after certain rotations"
    bug: "323299264"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "compose_bouncer"
    namespace: "systemui"
+3 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import com.android.systemui.statusbar.phone.SystemUIDialogManager;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.FlashlightController;
import com.android.systemui.statusbar.window.StatusBarWindowController;
import com.android.systemui.tuner.TunablePadding.TunablePaddingService;
import com.android.systemui.tuner.TunerService;

@@ -172,6 +173,7 @@ public class Dependency {
    @Inject Lazy<SystemUIDialogManager> mSystemUIDialogManagerLazy;
    @Inject Lazy<DialogLaunchAnimator> mDialogLaunchAnimatorLazy;
    @Inject Lazy<UserTracker> mUserTrackerLazy;
    @Inject Lazy<StatusBarWindowController> mStatusBarWindowControllerLazy;

    @Inject
    public Dependency() {
@@ -226,6 +228,7 @@ public class Dependency {
        mProviders.put(SystemUIDialogManager.class, mSystemUIDialogManagerLazy::get);
        mProviders.put(DialogLaunchAnimator.class, mDialogLaunchAnimatorLazy::get);
        mProviders.put(UserTracker.class, mUserTrackerLazy::get);
        mProviders.put(StatusBarWindowController.class, mStatusBarWindowControllerLazy::get);

        Dependency.setInstance(this);
    }
+5 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static androidx.lifecycle.Lifecycle.State.RESUMED;
import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;
import static com.android.systemui.Flags.lightRevealMigration;
import static com.android.systemui.Flags.predictiveBackSysui;
import static com.android.systemui.Flags.truncatedStatusBarIconsFix;
import static com.android.systemui.charging.WirelessChargingAnimation.UNKNOWN_BATTERY_LEVEL;
import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF;
import static com.android.systemui.statusbar.StatusBarState.SHADE;
@@ -1905,10 +1906,11 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
            mQSPanelController.updateResources();
        }

        if (!truncatedStatusBarIconsFix()) {
            if (mStatusBarWindowController != null) {
                mStatusBarWindowController.refreshStatusBarHeight();
            }

        }
        if (mShadeSurface != null) {
            mShadeSurface.updateResources();
        }
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.systemui.statusbar.phone;


import static com.android.systemui.Flags.truncatedStatusBarIconsFix;

import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Configuration;
@@ -41,6 +43,7 @@ import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.statusbar.phone.userswitcher.StatusBarUserSwitcherContainer;
import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.statusbar.window.StatusBarWindowController;
import com.android.systemui.user.ui.binder.StatusBarUserChipViewBinder;
import com.android.systemui.user.ui.viewmodel.StatusBarUserChipViewModel;
import com.android.systemui.util.leak.RotationUtils;
@@ -50,6 +53,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 DarkReceiver mBattery;
    private Clock mClock;
@@ -72,6 +76,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);
    }

    void setTouchEventHandler(Gefingerpoken handler) {
@@ -101,6 +106,9 @@ public class PhoneStatusBarView extends FrameLayout {
        Dependency.get(DarkIconDispatcher.class).addDarkReceiver(mClock);
        if (updateDisplayParameters()) {
            updateLayoutForCutout();
            if (truncatedStatusBarIconsFix()) {
                updateWindowHeight();
            }
        }
    }

@@ -124,6 +132,9 @@ public class PhoneStatusBarView extends FrameLayout {
        if (updateDisplayParameters()) {
            updateLayoutForCutout();
            requestLayout();
            if (truncatedStatusBarIconsFix()) {
                updateWindowHeight();
            }
        }
    }

@@ -279,4 +290,8 @@ public class PhoneStatusBarView extends FrameLayout {
                insets.right,
                getPaddingBottom());
    }

    private void updateWindowHeight() {
        mStatusBarWindowController.refreshStatusBarHeight();
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -1053,6 +1053,24 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
        verify(mBubbles).onStatusBarVisibilityChanged(true);
    }

    @Test
    public void updateResources_flagEnabled_doesNotUpdateStatusBarWindowHeight() {
        mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX);

        mCentralSurfaces.updateResources();

        verify(mStatusBarWindowController, never()).refreshStatusBarHeight();
    }

    @Test
    public void updateResources_flagDisabled_updatesStatusBarWindowHeight() {
        mSetFlagsRule.disableFlags(com.android.systemui.Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX);

        mCentralSurfaces.updateResources();

        verify(mStatusBarWindowController).refreshStatusBarHeight();
    }

    /**
     * Configures the appropriate mocks and then calls {@link CentralSurfacesImpl#updateIsKeyguard}
     * to reconfigure the keyguard to reflect the requested showing/occluded states.
Loading