From f44beff4591d648d0b13e27cc0e9309156b456a9 Mon Sep 17 00:00:00 2001 From: jasonwshsu Date: Sat, 4 Dec 2021 00:58:18 +0800 Subject: [PATCH] Fix the incorrect result of AccessibilityShortcutStats Root Cause: ACCESSIBILITY_BUTTON_MODE has different format than logging's accessibility shortcut_type. Solution: mapping the result before logging the atom. Bug: 209009696 Test: m statsd_testdrive && statsd_testdrive 10127 Change-Id: I518d3ccd080f3650c07a0147ed468c87a4dcd285 --- .../stats/pull/StatsPullAtomService.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java index 2be29d4a5ab41..dfff76d3a044f 100644 --- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java @@ -50,6 +50,10 @@ import static android.telephony.TelephonyManager.UNKNOWN_CARRIER_ID; import static android.util.MathUtils.constrain; import static com.android.internal.util.ConcurrentUtils.DIRECT_EXECUTOR; +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_FLOATING_MENU; +import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_GESTURE; +import static com.android.internal.util.FrameworkStatsLog.ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__UNKNOWN_TYPE; import static com.android.internal.util.FrameworkStatsLog.DATA_USAGE_BYTES_TRANSFER__OPPORTUNISTIC_DATA_SUB__NOT_OPPORTUNISTIC; import static com.android.internal.util.FrameworkStatsLog.DATA_USAGE_BYTES_TRANSFER__OPPORTUNISTIC_DATA_SUB__OPPORTUNISTIC; import static com.android.internal.util.FrameworkStatsLog.TIME_ZONE_DETECTOR_STATE__DETECTION_MODE__GEO; @@ -4387,8 +4391,9 @@ public class StatsPullAtomService extends SystemService { final int userId = userInfo.getUserHandle().getIdentifier(); if (isAccessibilityShortcutUser(mContext, userId)) { - final int software_shortcut_type = Settings.Secure.getIntForUser(resolver, - Settings.Secure.ACCESSIBILITY_BUTTON_MODE, 0, userId); + final int software_shortcut_type = convertToAccessibilityShortcutType( + Settings.Secure.getIntForUser(resolver, + Settings.Secure.ACCESSIBILITY_BUTTON_MODE, 0, userId)); final String software_shortcut_list = Settings.Secure.getStringForUser(resolver, Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, userId); final int software_shortcut_service_num = countAccessibilityServices( @@ -4509,6 +4514,19 @@ public class StatsPullAtomService extends SystemService { && !TextUtils.isEmpty(software_string); } + private int convertToAccessibilityShortcutType(int shortcutType) { + switch (shortcutType) { + case Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR: + return ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_BUTTON; + case Settings.Secure.ACCESSIBILITY_BUTTON_MODE_FLOATING_MENU: + return ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_FLOATING_MENU; + case Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE: + return ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__A11Y_GESTURE; + default: + return ACCESSIBILITY_SHORTCUT_REPORTED__SHORTCUT_TYPE__UNKNOWN_TYPE; + } + } + // Thermal event received from vendor thermal management subsystem private static final class ThermalEventListener extends IThermalEventListener.Stub { @Override