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

Commit d34b4e8d authored by Winson Chung's avatar Winson Chung
Browse files

Fix inconsistency in nav mode changes



- Don't rely on the broadcast for determining overlay changes, the actual
  changes are propagated via asset path changes to the configuration
  only after which the correct resources can be read
- Remove unnecessary reloading of nav bar when changing modes, basically
  in the rare cases that the configuration change comes before the
  receiver what happens is that NavBarFragment is reloaded (because
  FragmentHostManager detects an interesting config change), but the
  NavigationModeController has the old value (because it hasn't received
  the broadcast), then when it receives the broadcast, it has to
  reinflate with the new mode.  Now that NavModeController is based on
  config changes (and FragmentService always posts config change updates)
  the NavModeController mode will always be updated before the fragment
  is reloaded (and NavBarInflaterView doesn't need to update on mode change
  at all)
- Remove some dead code

Bug: 156631944
Test: Change nav modes a bunch of times

Change-Id: I14ba57acab3683fcd187d0d4adcf87dc7e352b1d
Signed-off-by: default avatarWinson Chung <winsonc@google.com>
parent 125bdd8c
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -93,7 +93,6 @@ public class NavigationBarInflaterView extends FrameLayout

    private boolean mIsVertical;
    private boolean mAlternativeOrder;
    private boolean mUsingCustomLayout;

    private OverviewProxyService mOverviewProxyService;
    private int mNavBarMode = NAV_BAR_MODE_3BUTTON;
@@ -145,7 +144,6 @@ public class NavigationBarInflaterView extends FrameLayout
    @Override
    public void onNavigationModeChanged(int mode) {
        mNavBarMode = mode;
        onLikelyDefaultLayoutChange();
    }

    @Override
@@ -154,17 +152,7 @@ public class NavigationBarInflaterView extends FrameLayout
        super.onDetachedFromWindow();
    }

    public void setNavigationBarLayout(String layoutValue) {
        if (!Objects.equals(mCurrentLayout, layoutValue)) {
            mUsingCustomLayout = layoutValue != null;
            clearViews();
            inflateLayout(layoutValue);
        }
    }

    public void onLikelyDefaultLayoutChange() {
        // Don't override custom layouts
        if (mUsingCustomLayout) return;

        // Reevaluate new layout
        final String newValue = getDefaultLayout();
+11 −19
Original line number Diff line number Diff line
@@ -16,19 +16,14 @@

package com.android.systemui.statusbar.phone;

import static android.content.Intent.ACTION_OVERLAY_CHANGED;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.om.IOverlayManager;
import android.content.om.OverlayInfo;
import android.content.pm.PackageManager;
import android.content.res.ApkAssets;
import android.os.PatternMatcher;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -39,6 +34,7 @@ import android.util.Log;
import com.android.systemui.Dumpable;
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;

import java.io.FileDescriptor;
@@ -69,16 +65,6 @@ public class NavigationModeController implements Dumpable {

    private ArrayList<ModeChangedListener> mListeners = new ArrayList<>();

    private BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (DEBUG) {
                Log.d(TAG, "ACTION_OVERLAY_CHANGED");
            }
            updateCurrentInteractionMode(true /* notify */);
        }
    };

    private final DeviceProvisionedController.DeviceProvisionedListener mDeviceProvisionedCallback =
            new DeviceProvisionedController.DeviceProvisionedListener() {
                @Override
@@ -97,6 +83,7 @@ public class NavigationModeController implements Dumpable {
    @Inject
    public NavigationModeController(Context context,
            DeviceProvisionedController deviceProvisionedController,
            ConfigurationController configurationController,
            @UiBackground Executor uiBgExecutor) {
        mContext = context;
        mCurrentUserContext = context;
@@ -105,10 +92,15 @@ public class NavigationModeController implements Dumpable {
        mUiBgExecutor = uiBgExecutor;
        deviceProvisionedController.addCallback(mDeviceProvisionedCallback);

        IntentFilter overlayFilter = new IntentFilter(ACTION_OVERLAY_CHANGED);
        overlayFilter.addDataScheme("package");
        overlayFilter.addDataSchemeSpecificPart("android", PatternMatcher.PATTERN_LITERAL);
        mContext.registerReceiverAsUser(mReceiver, UserHandle.ALL, overlayFilter, null, null);
        configurationController.addCallback(new ConfigurationController.ConfigurationListener() {
            @Override
            public void onOverlayChanged() {
                if (DEBUG) {
                    Log.d(TAG, "onOverlayChanged");
                }
                updateCurrentInteractionMode(true /* notify */);
            }
        });

        updateCurrentInteractionMode(false /* notify */);
    }