Add the log for new supported accessibility button type 'Accessibility Floating Menu'
* Logs the atom AccessibilityShortcutReported in westworld Bug: 189860801 Test: make statsd_testdrive && statsd_testdrive 266 Change-Id: I4e5814cb6a1d877af540e278de5ffa398d6d0351
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.internal.accessibility.util;
|
||||
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU;
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL;
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN;
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW;
|
||||
@@ -28,6 +29,7 @@ import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT
|
||||
import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED__SERVICE_STATUS__UNKNOWN;
|
||||
import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_BUTTON;
|
||||
import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_BUTTON_LONG_PRESS;
|
||||
import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_FLOATING_MENU;
|
||||
import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__TRIPLE_TAP;
|
||||
import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__UNKNOWN_TYPE;
|
||||
import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__VOLUME_KEY;
|
||||
@@ -37,6 +39,8 @@ import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_RE
|
||||
import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_REPORTED__ACTIVATED_MODE__MAGNIFICATION_WINDOW;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.AccessibilityManager.ShortcutType;
|
||||
|
||||
@@ -50,50 +54,54 @@ public final class AccessibilityStatsLogUtils {
|
||||
private AccessibilityStatsLogUtils() {}
|
||||
|
||||
/**
|
||||
* Logs accessibility feature name that is assigned to the shortcut also its shortcut type.
|
||||
* Logs accessibility feature name that is assigned to the given {@code shortcutType}.
|
||||
* Calls this when clicking the shortcut {@link AccessibilityManager#ACCESSIBILITY_BUTTON} or
|
||||
* {@link AccessibilityManager#ACCESSIBILITY_SHORTCUT_KEY}
|
||||
* {@link AccessibilityManager#ACCESSIBILITY_SHORTCUT_KEY}.
|
||||
*
|
||||
* @param context context used to retrieve the {@link Settings} provider
|
||||
* @param componentName component name of the accessibility feature
|
||||
* @param shortcutType accessibility shortcut type {@link ShortcutType}
|
||||
* @param shortcutType accessibility shortcut type
|
||||
*/
|
||||
public static void logAccessibilityShortcutActivated(ComponentName componentName,
|
||||
@ShortcutType int shortcutType) {
|
||||
logAccessibilityShortcutActivated(componentName, shortcutType, UNKNOWN_STATUS);
|
||||
public static void logAccessibilityShortcutActivated(Context context,
|
||||
ComponentName componentName, @ShortcutType int shortcutType) {
|
||||
logAccessibilityShortcutActivatedInternal(componentName,
|
||||
convertToLoggingShortcutType(context, shortcutType), UNKNOWN_STATUS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs accessibility feature name that is assigned to the shortcut also its shortcut type and
|
||||
* enabled status. Calls this when clicking the shortcut
|
||||
* {@link AccessibilityManager#ACCESSIBILITY_BUTTON}
|
||||
* or {@link AccessibilityManager#ACCESSIBILITY_SHORTCUT_KEY}
|
||||
* Logs accessibility feature name that is assigned to the given {@code shortcutType} and the
|
||||
* {@code serviceEnabled} status.
|
||||
* Calls this when clicking the shortcut {@link AccessibilityManager#ACCESSIBILITY_BUTTON}
|
||||
* or {@link AccessibilityManager#ACCESSIBILITY_SHORTCUT_KEY}.
|
||||
*
|
||||
* @param context context used to retrieve the {@link Settings} provider
|
||||
* @param componentName component name of the accessibility feature
|
||||
* @param shortcutType accessibility shortcut type
|
||||
* @param serviceEnabled {@code true} if the service is enabled
|
||||
*/
|
||||
public static void logAccessibilityShortcutActivated(ComponentName componentName,
|
||||
@ShortcutType int shortcutType, boolean serviceEnabled) {
|
||||
logAccessibilityShortcutActivated(componentName, shortcutType,
|
||||
public static void logAccessibilityShortcutActivated(Context context,
|
||||
ComponentName componentName, @ShortcutType int shortcutType, boolean serviceEnabled) {
|
||||
logAccessibilityShortcutActivatedInternal(componentName,
|
||||
convertToLoggingShortcutType(context, shortcutType),
|
||||
convertToLoggingServiceStatus(serviceEnabled));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs accessibility feature name that is assigned to the shortcut also its shortcut type and
|
||||
* status code. Calls this when clicking the shortcut
|
||||
* {@link AccessibilityManager#ACCESSIBILITY_BUTTON}
|
||||
* or {@link AccessibilityManager#ACCESSIBILITY_SHORTCUT_KEY}
|
||||
* Logs accessibility feature name that is assigned to the given {@code loggingShortcutType} and
|
||||
* {@code loggingServiceStatus} code.
|
||||
*
|
||||
* @param componentName component name of the accessibility feature
|
||||
* @param shortcutType accessibility shortcut type {@link ShortcutType}
|
||||
* @param serviceStatus The service status code. 0 denotes unknown_status, 1 denotes enabled, 2
|
||||
* denotes disabled.
|
||||
* @param componentName component name of the accessibility feature
|
||||
* @param loggingShortcutType accessibility shortcut type for logging. 0 denotes
|
||||
* unknown_type, 1 denotes accessibility button, 2 denotes volume
|
||||
* key, 3 denotes triple tap on the screen, 4 denotes long press on
|
||||
* accessibility button, 5 denotes accessibility floating menu.
|
||||
* @param loggingServiceStatus The service status code for logging. 0 denotes unknown_status, 1
|
||||
* denotes enabled, 2 denotes disabled.
|
||||
*/
|
||||
private static void logAccessibilityShortcutActivated(ComponentName componentName,
|
||||
@ShortcutType int shortcutType, int serviceStatus) {
|
||||
private static void logAccessibilityShortcutActivatedInternal(ComponentName componentName,
|
||||
int loggingShortcutType, int loggingServiceStatus) {
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED,
|
||||
componentName.flattenToString(), convertToLoggingShortcutType(shortcutType),
|
||||
serviceStatus);
|
||||
componentName.flattenToString(), loggingShortcutType, loggingServiceStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,10 +152,19 @@ public final class AccessibilityStatsLogUtils {
|
||||
convertToLoggingMagnificationMode(mode));
|
||||
}
|
||||
|
||||
private static int convertToLoggingShortcutType(@ShortcutType int shortcutType) {
|
||||
private static boolean isFloatingMenuEnabled(Context context) {
|
||||
return Settings.Secure.getInt(context.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_BUTTON_MODE, /* def= */ -1)
|
||||
== ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU;
|
||||
}
|
||||
|
||||
private static int convertToLoggingShortcutType(Context context,
|
||||
@ShortcutType int shortcutType) {
|
||||
switch (shortcutType) {
|
||||
case ACCESSIBILITY_BUTTON:
|
||||
return ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_BUTTON;
|
||||
return isFloatingMenuEnabled(context)
|
||||
? ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_FLOATING_MENU
|
||||
: ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_BUTTON;
|
||||
case ACCESSIBILITY_SHORTCUT_KEY:
|
||||
return ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__VOLUME_KEY;
|
||||
}
|
||||
|
||||
@@ -2892,7 +2892,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
// In case user assigned magnification to the given shortcut.
|
||||
if (targetName.equals(MAGNIFICATION_CONTROLLER_NAME)) {
|
||||
final boolean enabled = !getFullScreenMagnificationController().isMagnifying(displayId);
|
||||
logAccessibilityShortcutActivated(MAGNIFICATION_COMPONENT_NAME, shortcutType, enabled);
|
||||
logAccessibilityShortcutActivated(mContext, MAGNIFICATION_COMPONENT_NAME, shortcutType,
|
||||
enabled);
|
||||
sendAccessibilityButtonToInputFilter(displayId);
|
||||
return;
|
||||
}
|
||||
@@ -2907,7 +2908,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
}
|
||||
// In case user assigned an accessibility shortcut target to the given shortcut.
|
||||
if (performAccessibilityShortcutTargetActivity(displayId, targetComponentName)) {
|
||||
logAccessibilityShortcutActivated(targetComponentName, shortcutType);
|
||||
logAccessibilityShortcutActivated(mContext, targetComponentName, shortcutType);
|
||||
return;
|
||||
}
|
||||
// in case user assigned an accessibility service to the given shortcut.
|
||||
@@ -2930,12 +2931,12 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
featureInfo.getSettingKey(), mCurrentUserId);
|
||||
// Assuming that the default state will be to have the feature off
|
||||
if (!TextUtils.equals(featureInfo.getSettingOnValue(), setting.read())) {
|
||||
logAccessibilityShortcutActivated(assignedTarget, shortcutType, /* serviceEnabled= */
|
||||
true);
|
||||
logAccessibilityShortcutActivated(mContext, assignedTarget, shortcutType,
|
||||
/* serviceEnabled= */ true);
|
||||
setting.write(featureInfo.getSettingOnValue());
|
||||
} else {
|
||||
logAccessibilityShortcutActivated(assignedTarget, shortcutType, /* serviceEnabled= */
|
||||
false);
|
||||
logAccessibilityShortcutActivated(mContext, assignedTarget, shortcutType,
|
||||
/* serviceEnabled= */ false);
|
||||
setting.write(featureInfo.getSettingOffValue());
|
||||
}
|
||||
return true;
|
||||
@@ -2997,13 +2998,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
if ((targetSdk <= Build.VERSION_CODES.Q && shortcutType == ACCESSIBILITY_SHORTCUT_KEY)
|
||||
|| (targetSdk > Build.VERSION_CODES.Q && !requestA11yButton)) {
|
||||
if (serviceConnection == null) {
|
||||
logAccessibilityShortcutActivated(assignedTarget,
|
||||
shortcutType, /* serviceEnabled= */ true);
|
||||
logAccessibilityShortcutActivated(mContext, assignedTarget, shortcutType,
|
||||
/* serviceEnabled= */ true);
|
||||
enableAccessibilityServiceLocked(assignedTarget, mCurrentUserId);
|
||||
|
||||
} else {
|
||||
logAccessibilityShortcutActivated(assignedTarget,
|
||||
shortcutType, /* serviceEnabled= */ false);
|
||||
logAccessibilityShortcutActivated(mContext, assignedTarget, shortcutType,
|
||||
/* serviceEnabled= */ false);
|
||||
disableAccessibilityServiceLocked(assignedTarget, mCurrentUserId);
|
||||
}
|
||||
return true;
|
||||
@@ -3024,8 +3025,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
return false;
|
||||
}
|
||||
// ServiceConnection means service enabled.
|
||||
logAccessibilityShortcutActivated(assignedTarget, shortcutType, /* serviceEnabled= */
|
||||
true);
|
||||
logAccessibilityShortcutActivated(mContext, assignedTarget, shortcutType,
|
||||
/* serviceEnabled= */ true);
|
||||
serviceConnection.notifyAccessibilityButtonClickedLocked(displayId);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user