Loading core/res/res/values/config.xml +2 −3 Original line number Diff line number Diff line Loading @@ -3267,13 +3267,12 @@ <!-- Array of values used in Gesture Navigation settings page to reduce/increase the back gesture's inset size. These values will be multiplied into the default width, read from the gesture navigation overlay package, in order to create 4 different sizes which are selectable gesture navigation overlay package, in order to create 3 different sizes which are selectable via a slider component. --> <array name="config_backGestureInsetScales"> <item>0.75</item> <item>0.60</item> <item>1.00</item> <item>1.33</item> <item>1.66</item> </array> <!-- Controls whether the navbar needs a scrim with Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +95 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static android.os.Process.SHELL_UID; import static android.os.Process.SYSTEM_UID; import static android.provider.Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY; import static com.android.providers.settings.SettingsState.FALLBACK_FILE_SUFFIX; Loading @@ -41,6 +43,7 @@ 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.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageInfo; Loading Loading @@ -3414,7 +3417,7 @@ public class SettingsProvider extends ContentProvider { } private final class UpgradeController { private static final int SETTINGS_VERSION = 191; private static final int SETTINGS_VERSION = 192; private final int mUserId; Loading Loading @@ -4783,6 +4786,20 @@ public class SettingsProvider extends ContentProvider { currentVersion = 191; } if (currentVersion == 191) { final SettingsState secureSettings = getSecureSettingsLocked(userId); int mode = getContext().getResources().getInteger( com.android.internal.R.integer.config_navBarInteractionMode); if (mode == NAV_BAR_MODE_GESTURAL) { switchToDefaultGestureNavBackInset(userId, secureSettings); } migrateBackGestureSensitivity(Secure.BACK_GESTURE_INSET_SCALE_LEFT, userId, secureSettings); migrateBackGestureSensitivity(Secure.BACK_GESTURE_INSET_SCALE_RIGHT, userId, secureSettings); currentVersion = 192; } // vXXX: Add new settings above this point. if (currentVersion != newVersion) { Loading @@ -4801,6 +4818,83 @@ public class SettingsProvider extends ContentProvider { } } /** * Previously, We were using separate overlay packages for different back inset sizes. Now, * we have a single overlay package for gesture navigation mode, and set the inset size via * a secure.settings field. * * If a non-default overlay package is enabled, then enable the default overlay exclusively, * and set the calculated inset size difference as a scale value in secure.settings. */ private void switchToDefaultGestureNavBackInset(int userId, SettingsState secureSettings) { try { final IOverlayManager om = IOverlayManager.Stub.asInterface( ServiceManager.getService(Context.OVERLAY_SERVICE)); final OverlayInfo info = om.getOverlayInfo(NAV_BAR_MODE_GESTURAL_OVERLAY, userId); if (info != null && !info.isEnabled()) { final int curInset = getContext().getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_backGestureInset); om.setEnabledExclusiveInCategory(NAV_BAR_MODE_GESTURAL_OVERLAY, userId); final int defInset = getContext().getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_backGestureInset); final float scale = defInset == 0 ? 1.0f : ((float) curInset) / defInset; if (scale != 1.0f) { secureSettings.insertSettingLocked( Secure.BACK_GESTURE_INSET_SCALE_LEFT, Float.toString(scale), null /* tag */, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); secureSettings.insertSettingLocked( Secure.BACK_GESTURE_INSET_SCALE_RIGHT, Float.toString(scale), null /* tag */, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); if (DEBUG) { Slog.v(LOG_TAG, "Moved back sensitivity for user " + userId + " to scale " + scale); } } } } catch (SecurityException | IllegalStateException | RemoteException e) { Slog.e(LOG_TAG, "Failed to switch to default gesture nav overlay for user " + userId); } } private void migrateBackGestureSensitivity(String side, int userId, SettingsState secureSettings) { final Setting currentScale = secureSettings.getSettingLocked(side); if (currentScale.isNull()) { return; } float current = 1.0f; try { current = Float.parseFloat(currentScale.getValue()); } catch (NumberFormatException e) { // Do nothing. Overwrite with default value. } // Inset scale migration across all devices // Old(24dp): 0.66 0.75 0.83 1.00 1.08 1.33 1.66 // New(30dp): 0.60 0.60 1.00 1.00 1.00 1.00 1.33 final float low = 0.76f; // Values smaller than this will map to 0.6 final float high = 1.65f; // Values larger than this will map to 1.33 float newScale; if (current < low) { newScale = 0.6f; } else if (current < high) { newScale = 1.0f; } else { newScale = 1.33f; } secureSettings.insertSettingLocked(side, Float.toString(newScale), null /* tag */, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); if (DEBUG) { Slog.v(LOG_TAG, "Changed back sensitivity from " + current + " to " + newScale + " for user " + userId + " on " + side); } } private void ensureLegacyDefaultValueAndSystemSetUpdatedLocked(SettingsState settings, int userId) { List<String> names = settings.getSettingNamesLocked(); Loading packages/SystemUI/src/com/android/systemui/navigationbar/NavigationModeController.java +0 −35 Original line number Diff line number Diff line Loading @@ -17,15 +17,12 @@ package com.android.systemui.navigationbar; 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; Loading Loading @@ -131,9 +128,6 @@ public class NavigationModeController implements Dumpable { public void updateCurrentInteractionMode(boolean notify) { mCurrentUserContext = getCurrentUserContext(); int mode = getCurrentInteractionMode(mCurrentUserContext); if (mode == NAV_BAR_MODE_GESTURAL) { switchToDefaultGestureNavOverlayIfNecessary(); } mUiBgExecutor.execute(() -> Settings.Secure.putString(mCurrentUserContext.getContentResolver(), Secure.NAVIGATION_MODE, String.valueOf(mode))); Loading Loading @@ -187,35 +181,6 @@ public class NavigationModeController implements Dumpable { } } private void switchToDefaultGestureNavOverlayIfNecessary() { final int userId = mCurrentUserContext.getUserId(); try { final IOverlayManager om = IOverlayManager.Stub.asInterface( ServiceManager.getService(Context.OVERLAY_SERVICE)); final OverlayInfo info = om.getOverlayInfo(NAV_BAR_MODE_GESTURAL_OVERLAY, userId); if (info != null && !info.isEnabled()) { // Enable the default gesture nav overlay, and move the back gesture inset scale to // Settings.Secure for left and right sensitivity. final int curInset = mCurrentUserContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_backGestureInset); om.setEnabledExclusiveInCategory(NAV_BAR_MODE_GESTURAL_OVERLAY, userId); final int defInset = mCurrentUserContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_backGestureInset); final float scale = defInset == 0 ? 1.0f : ((float) curInset) / defInset; Settings.Secure.putFloat(mCurrentUserContext.getContentResolver(), Secure.BACK_GESTURE_INSET_SCALE_LEFT, scale); Settings.Secure.putFloat(mCurrentUserContext.getContentResolver(), Secure.BACK_GESTURE_INSET_SCALE_RIGHT, scale); if (DEBUG) { Log.v(TAG, "Moved back sensitivity for user " + userId + " to scale " + scale); } } } catch (SecurityException | IllegalStateException | RemoteException e) { Log.e(TAG, "Failed to switch to default gesture nav overlay for user " + userId); } } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("NavigationModeController:"); Loading packages/overlays/NavigationBarModeGesturalOverlay/res/values/config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ <bool name="config_navBarTapThrough">true</bool> <!-- Controls the size of the back gesture inset. --> <dimen name="config_backGestureInset">24dp</dimen> <dimen name="config_backGestureInset">30dp</dimen> <!-- Controls whether the navbar needs a scrim with {@link Window#setEnsuringNavigationBarContrastWhenTransparent}. --> Loading Loading
core/res/res/values/config.xml +2 −3 Original line number Diff line number Diff line Loading @@ -3267,13 +3267,12 @@ <!-- Array of values used in Gesture Navigation settings page to reduce/increase the back gesture's inset size. These values will be multiplied into the default width, read from the gesture navigation overlay package, in order to create 4 different sizes which are selectable gesture navigation overlay package, in order to create 3 different sizes which are selectable via a slider component. --> <array name="config_backGestureInsetScales"> <item>0.75</item> <item>0.60</item> <item>1.00</item> <item>1.33</item> <item>1.66</item> </array> <!-- Controls whether the navbar needs a scrim with Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +95 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static android.os.Process.SHELL_UID; import static android.os.Process.SYSTEM_UID; import static android.provider.Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY; import static com.android.providers.settings.SettingsState.FALLBACK_FILE_SUFFIX; Loading @@ -41,6 +43,7 @@ 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.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageInfo; Loading Loading @@ -3414,7 +3417,7 @@ public class SettingsProvider extends ContentProvider { } private final class UpgradeController { private static final int SETTINGS_VERSION = 191; private static final int SETTINGS_VERSION = 192; private final int mUserId; Loading Loading @@ -4783,6 +4786,20 @@ public class SettingsProvider extends ContentProvider { currentVersion = 191; } if (currentVersion == 191) { final SettingsState secureSettings = getSecureSettingsLocked(userId); int mode = getContext().getResources().getInteger( com.android.internal.R.integer.config_navBarInteractionMode); if (mode == NAV_BAR_MODE_GESTURAL) { switchToDefaultGestureNavBackInset(userId, secureSettings); } migrateBackGestureSensitivity(Secure.BACK_GESTURE_INSET_SCALE_LEFT, userId, secureSettings); migrateBackGestureSensitivity(Secure.BACK_GESTURE_INSET_SCALE_RIGHT, userId, secureSettings); currentVersion = 192; } // vXXX: Add new settings above this point. if (currentVersion != newVersion) { Loading @@ -4801,6 +4818,83 @@ public class SettingsProvider extends ContentProvider { } } /** * Previously, We were using separate overlay packages for different back inset sizes. Now, * we have a single overlay package for gesture navigation mode, and set the inset size via * a secure.settings field. * * If a non-default overlay package is enabled, then enable the default overlay exclusively, * and set the calculated inset size difference as a scale value in secure.settings. */ private void switchToDefaultGestureNavBackInset(int userId, SettingsState secureSettings) { try { final IOverlayManager om = IOverlayManager.Stub.asInterface( ServiceManager.getService(Context.OVERLAY_SERVICE)); final OverlayInfo info = om.getOverlayInfo(NAV_BAR_MODE_GESTURAL_OVERLAY, userId); if (info != null && !info.isEnabled()) { final int curInset = getContext().getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_backGestureInset); om.setEnabledExclusiveInCategory(NAV_BAR_MODE_GESTURAL_OVERLAY, userId); final int defInset = getContext().getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_backGestureInset); final float scale = defInset == 0 ? 1.0f : ((float) curInset) / defInset; if (scale != 1.0f) { secureSettings.insertSettingLocked( Secure.BACK_GESTURE_INSET_SCALE_LEFT, Float.toString(scale), null /* tag */, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); secureSettings.insertSettingLocked( Secure.BACK_GESTURE_INSET_SCALE_RIGHT, Float.toString(scale), null /* tag */, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); if (DEBUG) { Slog.v(LOG_TAG, "Moved back sensitivity for user " + userId + " to scale " + scale); } } } } catch (SecurityException | IllegalStateException | RemoteException e) { Slog.e(LOG_TAG, "Failed to switch to default gesture nav overlay for user " + userId); } } private void migrateBackGestureSensitivity(String side, int userId, SettingsState secureSettings) { final Setting currentScale = secureSettings.getSettingLocked(side); if (currentScale.isNull()) { return; } float current = 1.0f; try { current = Float.parseFloat(currentScale.getValue()); } catch (NumberFormatException e) { // Do nothing. Overwrite with default value. } // Inset scale migration across all devices // Old(24dp): 0.66 0.75 0.83 1.00 1.08 1.33 1.66 // New(30dp): 0.60 0.60 1.00 1.00 1.00 1.00 1.33 final float low = 0.76f; // Values smaller than this will map to 0.6 final float high = 1.65f; // Values larger than this will map to 1.33 float newScale; if (current < low) { newScale = 0.6f; } else if (current < high) { newScale = 1.0f; } else { newScale = 1.33f; } secureSettings.insertSettingLocked(side, Float.toString(newScale), null /* tag */, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); if (DEBUG) { Slog.v(LOG_TAG, "Changed back sensitivity from " + current + " to " + newScale + " for user " + userId + " on " + side); } } private void ensureLegacyDefaultValueAndSystemSetUpdatedLocked(SettingsState settings, int userId) { List<String> names = settings.getSettingNamesLocked(); Loading
packages/SystemUI/src/com/android/systemui/navigationbar/NavigationModeController.java +0 −35 Original line number Diff line number Diff line Loading @@ -17,15 +17,12 @@ package com.android.systemui.navigationbar; 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; Loading Loading @@ -131,9 +128,6 @@ public class NavigationModeController implements Dumpable { public void updateCurrentInteractionMode(boolean notify) { mCurrentUserContext = getCurrentUserContext(); int mode = getCurrentInteractionMode(mCurrentUserContext); if (mode == NAV_BAR_MODE_GESTURAL) { switchToDefaultGestureNavOverlayIfNecessary(); } mUiBgExecutor.execute(() -> Settings.Secure.putString(mCurrentUserContext.getContentResolver(), Secure.NAVIGATION_MODE, String.valueOf(mode))); Loading Loading @@ -187,35 +181,6 @@ public class NavigationModeController implements Dumpable { } } private void switchToDefaultGestureNavOverlayIfNecessary() { final int userId = mCurrentUserContext.getUserId(); try { final IOverlayManager om = IOverlayManager.Stub.asInterface( ServiceManager.getService(Context.OVERLAY_SERVICE)); final OverlayInfo info = om.getOverlayInfo(NAV_BAR_MODE_GESTURAL_OVERLAY, userId); if (info != null && !info.isEnabled()) { // Enable the default gesture nav overlay, and move the back gesture inset scale to // Settings.Secure for left and right sensitivity. final int curInset = mCurrentUserContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_backGestureInset); om.setEnabledExclusiveInCategory(NAV_BAR_MODE_GESTURAL_OVERLAY, userId); final int defInset = mCurrentUserContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_backGestureInset); final float scale = defInset == 0 ? 1.0f : ((float) curInset) / defInset; Settings.Secure.putFloat(mCurrentUserContext.getContentResolver(), Secure.BACK_GESTURE_INSET_SCALE_LEFT, scale); Settings.Secure.putFloat(mCurrentUserContext.getContentResolver(), Secure.BACK_GESTURE_INSET_SCALE_RIGHT, scale); if (DEBUG) { Log.v(TAG, "Moved back sensitivity for user " + userId + " to scale " + scale); } } } catch (SecurityException | IllegalStateException | RemoteException e) { Log.e(TAG, "Failed to switch to default gesture nav overlay for user " + userId); } } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("NavigationModeController:"); Loading
packages/overlays/NavigationBarModeGesturalOverlay/res/values/config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ <bool name="config_navBarTapThrough">true</bool> <!-- Controls the size of the back gesture inset. --> <dimen name="config_backGestureInset">24dp</dimen> <dimen name="config_backGestureInset">30dp</dimen> <!-- Controls whether the navbar needs a scrim with {@link Window#setEnsuringNavigationBarContrastWhenTransparent}. --> Loading