From 83a1af221a88e4a060b9e18fb854e0739873696e Mon Sep 17 00:00:00 2001 From: Angela Wang Date: Mon, 4 Jul 2022 08:37:19 +0000 Subject: [PATCH] Logs hearing aid information when a hearing aid is bonded The information including device mode, device side, and entry page id where the binding process starts. Set the mapped bond entry from BluetoothPairingDetail into the cached bluetooth device and log it later when the device mode and device side is received after the hearing aid bluetooth profile is connected. Bug: 237344016 Test: m statsd_testdrive & statsd_testdrive 513 Change-Id: Ie0432f7da4f29e89e47d0ad3d72a04a9f5ea83ae Merged-In: Ie0432f7da4f29e89e47d0ad3d72a04a9f5ea83ae --- .../AccessibilityStatsLogUtils.java | 23 +++++++++++++++++++ .../bluetooth/BluetoothPairingDetail.java | 10 ++++++++ 2 files changed, 33 insertions(+) diff --git a/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java b/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java index d8a887d510e..e78982a94d9 100644 --- a/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java +++ b/src/com/android/settings/accessibility/AccessibilityStatsLogUtils.java @@ -28,6 +28,7 @@ import static com.android.settings.accessibility.TextReadingPreferenceFragment.R import android.content.ComponentName; +import com.android.internal.util.FrameworkStatsLog; import com.android.settings.core.instrumentation.SettingsStatsLog; /** Methods for logging accessibility states. */ @@ -112,4 +113,26 @@ public final class AccessibilityStatsLogUtils { return SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED__ENTRY_POINT__TEXT_READING_UNKNOWN_ENTRY; } } + + /** + * Converts the entering page id where the hearing aid binding process starts for logging. + * + * @param pageId the entry page id where the hearing aid binding process starts + * @return the int value for logging mapped from some page ids defined in + * {@link SettingsStatsLog} + */ + public static int convertToHearingAidInfoBondEntry(int pageId) { + switch (pageId) { + case SettingsStatsLog.SETTINGS_UICHANGED__PAGE_ID__SETTINGS_CONNECTED_DEVICE_CATEGORY: + return FrameworkStatsLog.HEARING_AID_INFO_REPORTED__BOND_ENTRY__CONNECTED_DEVICES; + case SettingsStatsLog.SETTINGS_UICHANGED__PAGE_ID__DIALOG_ACCESSIBILITY_HEARINGAID: + return FrameworkStatsLog.HEARING_AID_INFO_REPORTED__BOND_ENTRY__ACCESSIBILITY_HEARING_AIDS; + case SettingsStatsLog.SETTINGS_UICHANGED__PAGE_ID__DIALOG_ACCESSIBILITY_HEARING_AID_PAIR_ANOTHER: + return FrameworkStatsLog.HEARING_AID_INFO_REPORTED__BOND_ENTRY__ACCESSIBILITY_HEARING_AID_PAIR_ANOTHER; + case SettingsStatsLog.SETTINGS_UICHANGED__PAGE_ID__BLUETOOTH_FRAGMENT: + return FrameworkStatsLog.HEARING_AID_INFO_REPORTED__BOND_ENTRY__BLUETOOTH; + default: + return FrameworkStatsLog.HEARING_AID_INFO_REPORTED__BOND_ENTRY__PAGE_UNKNOWN; + } + } } diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java index 2e0e9b5c2ff..9a92783e18a 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java @@ -29,8 +29,11 @@ import android.widget.Toast; import androidx.annotation.VisibleForTesting; import com.android.settings.R; +import com.android.settings.accessibility.AccessibilityStatsLogUtils; +import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.bluetooth.BluetoothDeviceFilter; import com.android.settingslib.bluetooth.CachedBluetoothDevice; +import com.android.settingslib.bluetooth.HearingAidStatsLogUtils; import com.android.settingslib.search.Indexable; import com.android.settingslib.widget.FooterPreference; @@ -179,6 +182,13 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme // If one device is connected(bonded), then close this fragment. finish(); return; + } else if (bondState == BluetoothDevice.BOND_BONDING) { + // Set the bond entry where binding process starts for logging hearing aid device info + final int pageId = FeatureFactory.getFactory( + getContext()).getMetricsFeatureProvider().getAttribution(getActivity()); + final int bondEntry = AccessibilityStatsLogUtils.convertToHearingAidInfoBondEntry( + pageId); + HearingAidStatsLogUtils.setBondEntryForDevice(bondEntry, cachedDevice); } if (mSelectedDevice != null && cachedDevice != null) { BluetoothDevice device = cachedDevice.getDevice();