Support accessibility shortcut secondary action (8/n)

Integrate with the multiple shortcut selections and change the behavior as below:
- Get the shortcut type from system provider or shared_prefs if this is first time to use.
- Update the shared_prefs for what user seen.

Bug: 142530063
Bug: 142531156
Test: make RunSettingsRoboTests2
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityUtilTest
Change-Id: I58aeb960e2c4aa0bc2432be34c1372c0de89117a
This commit is contained in:
menghanli
2020-01-15 10:41:51 +08:00
parent 5f4fadb949
commit 5d0f336fec
6 changed files with 181 additions and 83 deletions

View File

@@ -304,6 +304,26 @@ final class AccessibilityUtil {
return false;
}
/**
* Gets the corresponding user shortcut type of a given accessibility service.
*
* @param context The current context.
* @param componentName The component name that need to be checked existed in Settings.
* @return The user shortcut type if component name existed in {@code UserShortcutType} string
* Settings.
*/
static int getUserShortcutTypesFromSettings(Context context,
@NonNull ComponentName componentName) {
int shortcutTypes = UserShortcutType.DEFAULT;
if (hasValuesInSettings(context, UserShortcutType.SOFTWARE, componentName)) {
shortcutTypes |= UserShortcutType.SOFTWARE;
}
if (hasValuesInSettings(context, UserShortcutType.HARDWARE, componentName)) {
shortcutTypes |= UserShortcutType.HARDWARE;
}
return shortcutTypes;
}
/**
* Converts {@link UserShortcutType} to key in Settings.
*