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

Commit f95e183a authored by LuK1337's avatar LuK1337 Committed by Luca Stefani
Browse files

SystemUI: Fix FORCE_SHOW_NAVBAR handling on user switch

* This addresses the issue where navbar gets destroyed
  after user switch on devices where navigation bar
  should be always visible.
* https://gitlab.com/LineageOS/issues/android/issues/307

Change-Id: If5d350ab4393826039f9c9e598735163fc1d4509
parent 09b74fe1
Loading
Loading
Loading
Loading
+25 −9
Original line number Diff line number Diff line
@@ -677,6 +677,7 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl

    private NavigationBarFragment mNavigationBar;
    private View mNavigationBarView;
    private boolean mNeedsNavigationBar;
    protected ActivityLaunchAnimator mActivityLaunchAnimator;
    private HeadsUpAppearanceController mHeadsUpAppearanceController;
    private boolean mVibrateOnOpening;
@@ -733,6 +734,16 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl
        mVibratorHelper = Dependency.get(VibratorHelper.class);
        mScrimSrcModeEnabled = res.getBoolean(R.bool.config_status_bar_scrim_behind_use_src);
        mClearAllEnabled = res.getBoolean(R.bool.config_enableNotificationsClearAll);
        mNeedsNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);

        // Allow a system property to override this. Used by the emulator.
        // See also hasNavigationBar().
        String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
        if ("1".equals(navBarOverride)) {
            mNeedsNavigationBar = false;
        } else if ("0".equals(navBarOverride)) {
            mNeedsNavigationBar = true;
        }

        DateTimeView.setReceiverHandler(Dependency.get(Dependency.TIME_TICK_HANDLER));
        putComponent(StatusBar.class, this);
@@ -5909,17 +5920,22 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl
        } else if (LOCKSCREEN_MEDIA_METADATA.equals(key)) {
            mShowMediaMetadata = newValue == null || Integer.parseInt(newValue) != 0;
        } else if (mWindowManagerService != null && FORCE_SHOW_NAVBAR.equals(key)) {
            boolean forcedVisibility = newValue != null && Integer.parseInt(newValue) == 1;
            boolean forcedVisibility = mNeedsNavigationBar ||
                    (newValue != null && Integer.parseInt(newValue) == 1);

            if (forcedVisibility && mNavigationBarView == null) {
            if (forcedVisibility) {
                if (mNavigationBarView == null) {
                    createNavigationBar();
            } else if (mNavigationBarView != null) {
                }
            } else {
                if (mNavigationBarView != null) {
                    FragmentHostManager fm = FragmentHostManager.get(mNavigationBarView);
                    mWindowManager.removeViewImmediate(mNavigationBarView);
                    mNavigationBarView = null;
                    fm.getFragmentManager().beginTransaction().remove(mNavigationBar).commit();
                    mNavigationBar = null;
                }
            }
        } else if (BERRY_GLOBAL_STYLE.equals(key)) {
            updateTheme();
        }