Merge "Accessibility Service & Shortcut Redesign - Remove “volume key shortcut” setting (5/n)" into rvc-dev am: fea8d184c2 am: 5664cb5315 am: 21f36c7bfb
Change-Id: I6420243922e46e18fee7ea9214b107f37a9c2054
This commit is contained in:
@@ -6560,13 +6560,6 @@ public final class Settings {
|
||||
*/
|
||||
public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
|
||||
|
||||
/**
|
||||
* Setting specifying if the accessibility shortcut is enabled.
|
||||
* @hide
|
||||
*/
|
||||
public static final String ACCESSIBILITY_SHORTCUT_ENABLED =
|
||||
"accessibility_shortcut_enabled";
|
||||
|
||||
/**
|
||||
* Setting specifying if the accessibility shortcut is enabled.
|
||||
* @hide
|
||||
|
||||
@@ -143,9 +143,6 @@ public class AccessibilityShortcutController {
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE),
|
||||
false, co, UserHandle.USER_ALL);
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED),
|
||||
false, co, UserHandle.USER_ALL);
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN),
|
||||
false, co, UserHandle.USER_ALL);
|
||||
@@ -174,8 +171,6 @@ public class AccessibilityShortcutController {
|
||||
public void onSettingsChanged() {
|
||||
final boolean hasShortcutTarget = hasShortcutTarget();
|
||||
final ContentResolver cr = mContext.getContentResolver();
|
||||
final boolean enabled = Settings.Secure.getIntForUser(
|
||||
cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 1, mUserId) == 1;
|
||||
// Enable the shortcut from the lockscreen by default if the dialog has been shown
|
||||
final int dialogAlreadyShown = Settings.Secure.getIntForUser(
|
||||
cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, DialogStaus.NOT_SHOWN,
|
||||
@@ -183,7 +178,7 @@ public class AccessibilityShortcutController {
|
||||
mEnabledOnLockScreen = Settings.Secure.getIntForUser(
|
||||
cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
|
||||
dialogAlreadyShown, mUserId) == 1;
|
||||
mIsShortcutEnabled = enabled && hasShortcutTarget;
|
||||
mIsShortcutEnabled = hasShortcutTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.internal.accessibility;
|
||||
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN;
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED;
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN;
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE;
|
||||
import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_SHORTCUT_KEY;
|
||||
@@ -102,10 +101,8 @@ public class AccessibilityShortcutControllerTest {
|
||||
private static final long[] VIBRATOR_PATTERN_LONG = {VIBRATOR_PATTERN_1, VIBRATOR_PATTERN_2};
|
||||
|
||||
// Convenience values for enabling/disabling to make code more readable
|
||||
private static final int DISABLED = 0;
|
||||
private static final int ENABLED_EXCEPT_LOCK_SCREEN = 1;
|
||||
private static final int ENABLED_INCLUDING_LOCK_SCREEN = 2;
|
||||
private static final int DISABLED_BUT_LOCK_SCREEN_ON = 3;
|
||||
|
||||
private @Mock Context mContext;
|
||||
private @Mock FrameworkObjectProvider mFrameworkObjectProvider;
|
||||
@@ -224,14 +221,6 @@ public class AccessibilityShortcutControllerTest {
|
||||
assertTrue(getController().isAccessibilityShortcutAvailable(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortcutAvailable_disabledWithValidServiceWhenCreated_shouldReturnFalse()
|
||||
throws Exception {
|
||||
configureValidShortcutService();
|
||||
configureShortcutEnabled(DISABLED_BUT_LOCK_SCREEN_ON);
|
||||
assertFalse(getController().isAccessibilityShortcutAvailable(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortcutAvailable_onLockScreenButDisabledThere_shouldReturnFalse()
|
||||
throws Exception {
|
||||
@@ -284,21 +273,9 @@ public class AccessibilityShortcutControllerTest {
|
||||
assertTrue(accessibilityShortcutController.isAccessibilityShortcutAvailable(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortcutAvailable_whenShortcutBecomesDisabled_shouldReturnFalse()
|
||||
throws Exception {
|
||||
configureShortcutEnabled(ENABLED_EXCEPT_LOCK_SCREEN);
|
||||
configureValidShortcutService();
|
||||
AccessibilityShortcutController accessibilityShortcutController = getController();
|
||||
configureShortcutEnabled(DISABLED);
|
||||
accessibilityShortcutController.onSettingsChanged();
|
||||
assertFalse(accessibilityShortcutController.isAccessibilityShortcutAvailable(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortcutAvailable_whenShortcutBecomesEnabled_shouldReturnTrue()
|
||||
throws Exception {
|
||||
configureShortcutEnabled(DISABLED);
|
||||
configureValidShortcutService();
|
||||
AccessibilityShortcutController accessibilityShortcutController = getController();
|
||||
configureShortcutEnabled(ENABLED_EXCEPT_LOCK_SCREEN);
|
||||
@@ -594,31 +571,19 @@ public class AccessibilityShortcutControllerTest {
|
||||
}
|
||||
|
||||
private void configureShortcutEnabled(int enabledValue) {
|
||||
final boolean enabled;
|
||||
final boolean lockscreen;
|
||||
|
||||
switch (enabledValue) {
|
||||
case DISABLED:
|
||||
enabled = false;
|
||||
lockscreen = false;
|
||||
break;
|
||||
case DISABLED_BUT_LOCK_SCREEN_ON:
|
||||
enabled = false;
|
||||
lockscreen = true;
|
||||
break;
|
||||
case ENABLED_INCLUDING_LOCK_SCREEN:
|
||||
enabled = true;
|
||||
lockscreen = true;
|
||||
break;
|
||||
case ENABLED_EXCEPT_LOCK_SCREEN:
|
||||
enabled = true;
|
||||
lockscreen = false;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
Settings.Secure.putInt(mContentResolver, ACCESSIBILITY_SHORTCUT_ENABLED, enabled ? 1 : 0);
|
||||
Settings.Secure.putInt(
|
||||
mContentResolver, ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, lockscreen ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -189,19 +189,6 @@ public class AccessibilityUtils {
|
||||
return context.getString(R.string.config_defaultAccessibilityService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the accessibility shortcut is enabled for a user
|
||||
*
|
||||
* @param context A valid context
|
||||
* @param userId The user of interest
|
||||
* @return {@code true} if the shortcut is enabled for the user. {@code false} otherwise.
|
||||
* Note that the shortcut may be enabled, but no action associated with it.
|
||||
*/
|
||||
public static boolean isShortcutEnabled(Context context, int userId) {
|
||||
return Settings.Secure.getIntForUser(context.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 1, userId) == 1;
|
||||
}
|
||||
|
||||
private static Set<ComponentName> getInstalledServices(Context context) {
|
||||
final Set<ComponentName> installedServices = new HashSet<>();
|
||||
installedServices.clear();
|
||||
|
||||
@@ -48,7 +48,6 @@ public class SecureSettings {
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
|
||||
Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN,
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED,
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
|
||||
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET,
|
||||
|
||||
@@ -25,10 +25,10 @@ import static android.provider.settings.validators.SettingsValidators.COMMA_SEPA
|
||||
import static android.provider.settings.validators.SettingsValidators.COMPONENT_NAME_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.JSON_OBJECT_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.LOCALE_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.NONE_NEGATIVE_LONG_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.NON_NEGATIVE_INTEGER_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.NULLABLE_COMPONENT_NAME_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.PACKAGE_NAME_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.NONE_NEGATIVE_LONG_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.TILE_LIST_VALIDATOR;
|
||||
import static android.provider.settings.validators.SettingsValidators.TTS_LIST_VALIDATOR;
|
||||
|
||||
@@ -82,7 +82,6 @@ public class SecureSettingsValidators {
|
||||
Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
|
||||
ACCESSIBILITY_SHORTCUT_TARGET_LIST_VALIDATOR);
|
||||
VALIDATORS.put(Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Secure.ACCESSIBILITY_SHORTCUT_ENABLED, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, BOOLEAN_VALIDATOR);
|
||||
VALIDATORS.put(
|
||||
|
||||
@@ -1780,9 +1780,6 @@ class SettingsProtoDumpUtil {
|
||||
dumpSetting(s, p,
|
||||
Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON,
|
||||
SecureSettingsProto.Accessibility.LARGE_POINTER_ICON);
|
||||
dumpSetting(s, p,
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED,
|
||||
SecureSettingsProto.Accessibility.SHORTCUT_ENABLED);
|
||||
dumpSetting(s, p,
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
|
||||
SecureSettingsProto.Accessibility.SHORTCUT_ON_LOCK_SCREEN);
|
||||
|
||||
@@ -3436,7 +3436,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private final class UpgradeController {
|
||||
private static final int SETTINGS_VERSION = 188;
|
||||
private static final int SETTINGS_VERSION = 189;
|
||||
|
||||
private final int mUserId;
|
||||
|
||||
@@ -4759,6 +4759,23 @@ public class SettingsProvider extends ContentProvider {
|
||||
currentVersion = 188;
|
||||
}
|
||||
|
||||
if (currentVersion == 188) {
|
||||
// Deprecate ACCESSIBILITY_SHORTCUT_ENABLED, and migrate it
|
||||
// to ACCESSIBILITY_SHORTCUT_TARGET_SERVICE.
|
||||
final SettingsState secureSettings = getSecureSettingsLocked(userId);
|
||||
final Setting shortcutEnabled = secureSettings.getSettingLocked(
|
||||
"accessibility_shortcut_enabled");
|
||||
if ("0".equals(shortcutEnabled.getValue())) {
|
||||
// Clear shortcut key targets list setting.
|
||||
secureSettings.insertSettingLocked(
|
||||
Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
|
||||
"", null /* tag */, false /* makeDefault */,
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
}
|
||||
secureSettings.deleteSettingLocked("accessibility_shortcut_enabled");
|
||||
currentVersion = 189;
|
||||
}
|
||||
|
||||
// vXXX: Add new settings above this point.
|
||||
|
||||
if (currentVersion != newVersion) {
|
||||
|
||||
@@ -2001,17 +2001,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
|
||||
userState.mUserId, currentTargets, str -> str);
|
||||
scheduleNotifyClientsOfServicesStateChangeLocked(userState);
|
||||
|
||||
// Disable accessibility shortcut key if there's no shortcut installed.
|
||||
if (currentTargets.isEmpty()) {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 0, userState.mUserId);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canRequestAndRequestsTouchExplorationLocked(
|
||||
|
||||
Reference in New Issue
Block a user