summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2020-05-26 21:16:48 -0700
committer Winson Chung <winsonc@google.com> 2020-05-26 21:28:32 -0700
commitd34b4e8d278386b85a00018c502bd21d00f8813b (patch)
tree890e1c252d715c58674bb854ce6e3a47230b8de3
parent125bdd8ca1653ab9eb44e845629a5fdade3bcb56 (diff)
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: Winson Chung <winsonc@google.com>
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationModeController.java30
2 files changed, 11 insertions, 31 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
index 662c744f8c95..46c873db8a08 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
@@ -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();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationModeController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationModeController.java
index 06b7d1a34b5a..daefef5e826d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationModeController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationModeController.java
@@ -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 */);
}