Merge "Adjusts the default magnification settings for config_magnification_area" into sc-dev

This commit is contained in:
Minche Li
2021-02-19 05:17:45 +00:00
committed by Android (Google) Code Review
2 changed files with 22 additions and 6 deletions

View File

@@ -4780,17 +4780,23 @@ public class SettingsProvider extends ContentProvider {
} }
if (currentVersion == 192) { if (currentVersion == 192) {
// Version 192: set the default value for magnification capabilities. If // Version 192: set the default value for magnification capabilities.
// magnification is enabled by the user, set it to full-screen, and set a value // If the device supports magnification area and magnification is enabled
// to show a prompt when using the magnification first time after upgrading. // by the user, set it to full-screen, and set a value to show a prompt
// when using the magnification first time after upgrading.
final SettingsState secureSettings = getSecureSettingsLocked(userId); final SettingsState secureSettings = getSecureSettingsLocked(userId);
final Setting magnificationCapabilities = secureSettings.getSettingLocked( final Setting magnificationCapabilities = secureSettings.getSettingLocked(
Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY); Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY);
final boolean supportMagnificationArea = getContext().getResources().getBoolean(
com.android.internal.R.bool.config_magnification_area);
final int capability = supportMagnificationArea
? R.integer.def_accessibility_magnification_capabilities
: Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN;
final String supportShowPrompt = supportMagnificationArea ? "1" : "0";
if (magnificationCapabilities.isNull()) { if (magnificationCapabilities.isNull()) {
secureSettings.insertSettingLocked( secureSettings.insertSettingLocked(
Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY, Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY,
String.valueOf(getContext().getResources().getInteger( String.valueOf(getContext().getResources().getInteger(capability)),
R.integer.def_accessibility_magnification_capabilities)),
null, true, SettingsState.SYSTEM_PACKAGE_NAME); null, true, SettingsState.SYSTEM_PACKAGE_NAME);
if (isMagnificationSettingsOn(secureSettings)) { if (isMagnificationSettingsOn(secureSettings)) {
@@ -4800,7 +4806,8 @@ public class SettingsProvider extends ContentProvider {
null, false /* makeDefault */, null, false /* makeDefault */,
SettingsState.SYSTEM_PACKAGE_NAME); SettingsState.SYSTEM_PACKAGE_NAME);
secureSettings.insertSettingLocked( secureSettings.insertSettingLocked(
Secure.ACCESSIBILITY_SHOW_WINDOW_MAGNIFICATION_PROMPT, "1", Secure.ACCESSIBILITY_SHOW_WINDOW_MAGNIFICATION_PROMPT,
supportShowPrompt,
null, false /* makeDefault */, null, false /* makeDefault */,
SettingsState.SYSTEM_PACKAGE_NAME); SettingsState.SYSTEM_PACKAGE_NAME);
} }

View File

@@ -118,6 +118,9 @@ class AccessibilityUserState {
private int mNonInteractiveUiTimeout = 0; private int mNonInteractiveUiTimeout = 0;
private int mInteractiveUiTimeout = 0; private int mInteractiveUiTimeout = 0;
private int mLastSentClientState = -1; private int mLastSentClientState = -1;
/** {@code true} if the device config supports magnification area. */
private final boolean mSupportMagnificationArea;
// The magnification mode of default display. // The magnification mode of default display.
private int mMagnificationMode = ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN; private int mMagnificationMode = ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN;
// The magnification capabilities used to know magnification mode could be switched. // The magnification capabilities used to know magnification mode could be switched.
@@ -138,6 +141,10 @@ class AccessibilityUserState {
private int mSoftKeyboardShowMode = SHOW_MODE_AUTO; private int mSoftKeyboardShowMode = SHOW_MODE_AUTO;
boolean isValidMagnificationModeLocked() { boolean isValidMagnificationModeLocked() {
if (!mSupportMagnificationArea
&& mMagnificationMode == Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW) {
return false;
}
return (mMagnificationCapabilities & mMagnificationMode) != 0; return (mMagnificationCapabilities & mMagnificationMode) != 0;
} }
@@ -156,6 +163,8 @@ class AccessibilityUserState {
R.color.accessibility_focus_highlight_color); R.color.accessibility_focus_highlight_color);
mFocusStrokeWidth = mFocusStrokeWidthDefaultValue; mFocusStrokeWidth = mFocusStrokeWidthDefaultValue;
mFocusColor = mFocusColorDefaultValue; mFocusColor = mFocusColorDefaultValue;
mSupportMagnificationArea = mContext.getResources().getBoolean(
R.bool.config_magnification_area);
} }
boolean isHandlingAccessibilityEventsLocked() { boolean isHandlingAccessibilityEventsLocked() {