Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ public class SettingsHelper { sBroadcastOnRestore.add(Settings.Secure.UI_NIGHT_MODE); sBroadcastOnRestore.add(Settings.Secure.DARK_THEME_CUSTOM_START_TIME); sBroadcastOnRestore.add(Settings.Secure.DARK_THEME_CUSTOM_END_TIME); sBroadcastOnRestore.add(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED); } private interface SettingsLookup { Loading packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperRestoreTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; /** * Tests for {@link SettingsHelper#restoreValue(Context, ContentResolver, ContentValues, Uri, Loading Loading @@ -89,7 +90,7 @@ public class SettingsHelperRestoreTest { float restoreSettingValue = defaultSettingValue + 0.5f; mSettingsHelper.restoreValue( mContext, Mockito.mock(Context.class), mContentResolver, new ContentValues(2), Settings.Secure.getUriFor(settingName), Loading Loading @@ -132,7 +133,7 @@ public class SettingsHelperRestoreTest { Settings.Secure.putInt(mContentResolver, settingName, configuredSettingValue); mSettingsHelper.restoreValue( mContext, Mockito.mock(Context.class), mContentResolver, new ContentValues(2), Settings.Secure.getUriFor(settingName), Loading @@ -154,7 +155,7 @@ public class SettingsHelperRestoreTest { int restoreSettingValue = 1; mSettingsHelper.restoreValue( mContext, Mockito.mock(Context.class), mContentResolver, new ContentValues(2), Settings.Secure.getUriFor(settingName), Loading services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +45 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.accessibility; import static android.provider.Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED; import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_BUTTON; import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_SHORTCUT_KEY; import static android.view.accessibility.AccessibilityManager.ShortcutType; Loading Loading @@ -542,12 +543,56 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE), intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)); } } else if (ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(which)) { synchronized (mLock) { restoreLegacyDisplayMagnificationNavBarIfNeededLocked( intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE), intent.getIntExtra(Intent.EXTRA_SETTING_RESTORED_FROM_SDK_INT, 0)); } } } } }, UserHandle.ALL, intentFilter, null, null); } // Called only during settings restore; currently supports only the owner user // TODO: b/22388012 private void restoreLegacyDisplayMagnificationNavBarIfNeededLocked(String newSetting, int restoreFromSdkInt) { if (restoreFromSdkInt >= Build.VERSION_CODES.R) { return; } boolean displayMagnificationNavBarEnabled; try { displayMagnificationNavBarEnabled = Integer.parseInt(newSetting) == 1; } catch (NumberFormatException e) { Slog.w(LOG_TAG, "number format is incorrect" + e); return; } final AccessibilityUserState userState = getUserStateLocked(UserHandle.USER_SYSTEM); final Set<String> targetsFromSetting = new ArraySet<>(); readColonDelimitedSettingToSet(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, userState.mUserId, targetsFromSetting, str -> str); final boolean targetsContainMagnification = targetsFromSetting.contains( MAGNIFICATION_CONTROLLER_NAME); if (targetsContainMagnification == displayMagnificationNavBarEnabled) { return; } if (displayMagnificationNavBarEnabled) { targetsFromSetting.add(MAGNIFICATION_CONTROLLER_NAME); } else { targetsFromSetting.remove(MAGNIFICATION_CONTROLLER_NAME); } persistColonDelimitedSetToSettingLocked(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, userState.mUserId, targetsFromSetting, str -> str); readAccessibilityButtonTargetsLocked(userState); onUserStateChangedLocked(userState); } @Override public long addClient(IAccessibilityManagerClient callback, int userId) { synchronized (mLock) { Loading Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ public class SettingsHelper { sBroadcastOnRestore.add(Settings.Secure.UI_NIGHT_MODE); sBroadcastOnRestore.add(Settings.Secure.DARK_THEME_CUSTOM_START_TIME); sBroadcastOnRestore.add(Settings.Secure.DARK_THEME_CUSTOM_END_TIME); sBroadcastOnRestore.add(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED); } private interface SettingsLookup { Loading
packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperRestoreTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; /** * Tests for {@link SettingsHelper#restoreValue(Context, ContentResolver, ContentValues, Uri, Loading Loading @@ -89,7 +90,7 @@ public class SettingsHelperRestoreTest { float restoreSettingValue = defaultSettingValue + 0.5f; mSettingsHelper.restoreValue( mContext, Mockito.mock(Context.class), mContentResolver, new ContentValues(2), Settings.Secure.getUriFor(settingName), Loading Loading @@ -132,7 +133,7 @@ public class SettingsHelperRestoreTest { Settings.Secure.putInt(mContentResolver, settingName, configuredSettingValue); mSettingsHelper.restoreValue( mContext, Mockito.mock(Context.class), mContentResolver, new ContentValues(2), Settings.Secure.getUriFor(settingName), Loading @@ -154,7 +155,7 @@ public class SettingsHelperRestoreTest { int restoreSettingValue = 1; mSettingsHelper.restoreValue( mContext, Mockito.mock(Context.class), mContentResolver, new ContentValues(2), Settings.Secure.getUriFor(settingName), Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +45 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.accessibility; import static android.provider.Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED; import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_BUTTON; import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_SHORTCUT_KEY; import static android.view.accessibility.AccessibilityManager.ShortcutType; Loading Loading @@ -542,12 +543,56 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE), intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)); } } else if (ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(which)) { synchronized (mLock) { restoreLegacyDisplayMagnificationNavBarIfNeededLocked( intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE), intent.getIntExtra(Intent.EXTRA_SETTING_RESTORED_FROM_SDK_INT, 0)); } } } } }, UserHandle.ALL, intentFilter, null, null); } // Called only during settings restore; currently supports only the owner user // TODO: b/22388012 private void restoreLegacyDisplayMagnificationNavBarIfNeededLocked(String newSetting, int restoreFromSdkInt) { if (restoreFromSdkInt >= Build.VERSION_CODES.R) { return; } boolean displayMagnificationNavBarEnabled; try { displayMagnificationNavBarEnabled = Integer.parseInt(newSetting) == 1; } catch (NumberFormatException e) { Slog.w(LOG_TAG, "number format is incorrect" + e); return; } final AccessibilityUserState userState = getUserStateLocked(UserHandle.USER_SYSTEM); final Set<String> targetsFromSetting = new ArraySet<>(); readColonDelimitedSettingToSet(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, userState.mUserId, targetsFromSetting, str -> str); final boolean targetsContainMagnification = targetsFromSetting.contains( MAGNIFICATION_CONTROLLER_NAME); if (targetsContainMagnification == displayMagnificationNavBarEnabled) { return; } if (displayMagnificationNavBarEnabled) { targetsFromSetting.add(MAGNIFICATION_CONTROLLER_NAME); } else { targetsFromSetting.remove(MAGNIFICATION_CONTROLLER_NAME); } persistColonDelimitedSetToSettingLocked(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, userState.mUserId, targetsFromSetting, str -> str); readAccessibilityButtonTargetsLocked(userState); onUserStateChangedLocked(userState); } @Override public long addClient(IAccessibilityManagerClient callback, int userId) { synchronized (mLock) { Loading