Merge "Fix Magnification Settings didn't restore via D2D transfer" into rvc-dev
This commit is contained in:
@@ -80,6 +80,7 @@ public class SettingsHelper {
|
|||||||
sBroadcastOnRestore.add(Settings.Secure.UI_NIGHT_MODE);
|
sBroadcastOnRestore.add(Settings.Secure.UI_NIGHT_MODE);
|
||||||
sBroadcastOnRestore.add(Settings.Secure.DARK_THEME_CUSTOM_START_TIME);
|
sBroadcastOnRestore.add(Settings.Secure.DARK_THEME_CUSTOM_START_TIME);
|
||||||
sBroadcastOnRestore.add(Settings.Secure.DARK_THEME_CUSTOM_END_TIME);
|
sBroadcastOnRestore.add(Settings.Secure.DARK_THEME_CUSTOM_END_TIME);
|
||||||
|
sBroadcastOnRestore.add(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface SettingsLookup {
|
private interface SettingsLookup {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import androidx.test.runner.AndroidJUnit4;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link SettingsHelper#restoreValue(Context, ContentResolver, ContentValues, Uri,
|
* Tests for {@link SettingsHelper#restoreValue(Context, ContentResolver, ContentValues, Uri,
|
||||||
@@ -89,7 +90,7 @@ public class SettingsHelperRestoreTest {
|
|||||||
float restoreSettingValue = defaultSettingValue + 0.5f;
|
float restoreSettingValue = defaultSettingValue + 0.5f;
|
||||||
|
|
||||||
mSettingsHelper.restoreValue(
|
mSettingsHelper.restoreValue(
|
||||||
mContext,
|
Mockito.mock(Context.class),
|
||||||
mContentResolver,
|
mContentResolver,
|
||||||
new ContentValues(2),
|
new ContentValues(2),
|
||||||
Settings.Secure.getUriFor(settingName),
|
Settings.Secure.getUriFor(settingName),
|
||||||
@@ -132,7 +133,7 @@ public class SettingsHelperRestoreTest {
|
|||||||
Settings.Secure.putInt(mContentResolver, settingName, configuredSettingValue);
|
Settings.Secure.putInt(mContentResolver, settingName, configuredSettingValue);
|
||||||
|
|
||||||
mSettingsHelper.restoreValue(
|
mSettingsHelper.restoreValue(
|
||||||
mContext,
|
Mockito.mock(Context.class),
|
||||||
mContentResolver,
|
mContentResolver,
|
||||||
new ContentValues(2),
|
new ContentValues(2),
|
||||||
Settings.Secure.getUriFor(settingName),
|
Settings.Secure.getUriFor(settingName),
|
||||||
@@ -154,7 +155,7 @@ public class SettingsHelperRestoreTest {
|
|||||||
|
|
||||||
int restoreSettingValue = 1;
|
int restoreSettingValue = 1;
|
||||||
mSettingsHelper.restoreValue(
|
mSettingsHelper.restoreValue(
|
||||||
mContext,
|
Mockito.mock(Context.class),
|
||||||
mContentResolver,
|
mContentResolver,
|
||||||
new ContentValues(2),
|
new ContentValues(2),
|
||||||
Settings.Secure.getUriFor(settingName),
|
Settings.Secure.getUriFor(settingName),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.server.accessibility;
|
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_BUTTON;
|
||||||
import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_SHORTCUT_KEY;
|
import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_SHORTCUT_KEY;
|
||||||
import static android.view.accessibility.AccessibilityManager.ShortcutType;
|
import static android.view.accessibility.AccessibilityManager.ShortcutType;
|
||||||
@@ -542,12 +543,56 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE),
|
intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE),
|
||||||
intent.getStringExtra(Intent.EXTRA_SETTING_NEW_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);
|
}, 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
|
@Override
|
||||||
public long addClient(IAccessibilityManagerClient callback, int userId) {
|
public long addClient(IAccessibilityManagerClient callback, int userId) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
|||||||
Reference in New Issue
Block a user