Only migrate 2-button setting if set
- We have only shipped configurations with:
default=3 button + setting to opt in
default=2 button + no setting to opt out
So to prevent migrating in the case where a user has restored from
a device (1) to a device (2) where the setting may be false (but
previously showed 2 button nav), we only migrate the nav bar mode
to the 2 button overlay whenever the setting is set. This means
that the user will fallback to the device default nav bar mode
which corresponds to the previous default modes for each device.
- Also remove temporary nav bar mode migration for dogfood users
Bug: 128548249
Test: Migrate from P to Q with swipe up setting set to false
Change-Id: I7218eeb13fec50b2fe3e89f75ef0d2d4ab67aff1
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index cd97ce8..29cb6f3 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -20,12 +20,7 @@
import static android.os.Process.ROOT_UID;
import static android.os.Process.SHELL_UID;
import static android.os.Process.SYSTEM_UID;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
import android.Manifest;
import android.annotation.NonNull;
@@ -41,7 +36,6 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.om.IOverlayManager;
-import android.content.om.OverlayInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
@@ -4321,50 +4315,19 @@
if (currentVersion == 176) {
// Version 176: Migrate the existing swipe up setting into the resource overlay
- // for the navigation bar interaction mode.
+ // for the navigation bar interaction mode. We do so only if the
+ // setting is set.
- final IOverlayManager overlayManager = IOverlayManager.Stub.asInterface(
- ServiceManager.getService(Context.OVERLAY_SERVICE));
- int navBarMode = -1;
-
- // Migrate the swipe up setting only if it is set
final SettingsState secureSettings = getSecureSettingsLocked(userId);
final Setting swipeUpSetting = secureSettings.getSettingLocked(
"swipe_up_to_switch_apps_enabled");
- if (swipeUpSetting != null && !swipeUpSetting.isNull()) {
- navBarMode = swipeUpSetting.getValue().equals("1")
- ? NAV_BAR_MODE_2BUTTON
- : NAV_BAR_MODE_3BUTTON;
- }
-
- // Temporary: Only for migration for dogfooders, to be removed
- try {
- final OverlayInfo info = overlayManager.getOverlayInfo(
- "com.android.internal.experiment.navbar.type.inset",
- UserHandle.USER_CURRENT);
- if (info != null && info.isEnabled()) {
- navBarMode = NAV_BAR_MODE_GESTURAL;
- }
- } catch (RemoteException e) {
- // Ingore, fall through
- }
-
- if (navBarMode != -1) {
- String overlayPackage = "";
+ if (swipeUpSetting != null && !swipeUpSetting.isNull()
+ && swipeUpSetting.getValue().equals("1")) {
+ final IOverlayManager overlayManager = IOverlayManager.Stub.asInterface(
+ ServiceManager.getService(Context.OVERLAY_SERVICE));
try {
- switch (navBarMode) {
- case NAV_BAR_MODE_3BUTTON:
- overlayPackage = NAV_BAR_MODE_3BUTTON_OVERLAY;
- break;
- case NAV_BAR_MODE_2BUTTON:
- overlayPackage = NAV_BAR_MODE_2BUTTON_OVERLAY;
- break;
- case NAV_BAR_MODE_GESTURAL:
- overlayPackage = NAV_BAR_MODE_GESTURAL_OVERLAY;
- break;
- }
- overlayManager.setEnabledExclusiveInCategory(overlayPackage,
- UserHandle.USER_CURRENT);
+ overlayManager.setEnabledExclusiveInCategory(
+ NAV_BAR_MODE_2BUTTON_OVERLAY, UserHandle.USER_CURRENT);
} catch (RemoteException e) {
throw new IllegalStateException(
"Failed to set nav bar interaction mode overlay");