Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83a1af22 authored by Angela Wang's avatar Angela Wang
Browse files

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
parent 5370d36b
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -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;
        }
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -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();