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

Commit 969d55e0 authored by Palash Ahuja's avatar Palash Ahuja
Browse files

BluetoothMetrics: Adding logging for NONE and BONDED in the java layer

Bug: 375437118
Test: m statsd_testdrive && statsd_testdrive -terse 916
Flag: EXEMPT, metrics logging
Change-Id: Idf9dba4d1b675cda8807413e6af99148b9fd71a1
parent 9f917bc9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -545,6 +545,7 @@ final class BondStateMachine extends StateMachine {
        if (oldState == newState) {
            return;
        }
        MetricsLogger.getInstance().logBondStateMachineEvent(device, newState);
        BluetoothStatsLog.write(
                BluetoothStatsLog.BLUETOOTH_BOND_STATE_CHANGED,
                mAdapterService.obfuscateAddress(device),
+25 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.bluetooth.btservice;

import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__BOND;
import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__PROFILE_CONNECTION;
import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__PROFILE_CONNECTION_A2DP;
import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__PROFILE_CONNECTION_A2DP_SINK;
@@ -31,6 +32,8 @@ import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVEN
import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__PROFILE_CONNECTION_PAN;
import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__PROFILE_CONNECTION_PBAP_CLIENT;
import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__PROFILE_CONNECTION_VOLUME_CONTROL;
import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__STATE_BONDED;
import static com.android.bluetooth.BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__STATE_NONE;
import static com.android.bluetooth.BtRestrictedStatsLog.RESTRICTED_BLUETOOTH_DEVICE_NAME_REPORTED;

import android.app.AlarmManager;
@@ -695,7 +698,7 @@ public class MetricsLogger {

    public void logBluetoothEvent(BluetoothDevice device, int eventType, int state, int uid) {

        if (mAdapterService.getMetricId(device) == 0 || !mInitialized) {
        if (!mInitialized || mAdapterService.getMetricId(device) == 0) {
            return;
        }

@@ -815,6 +818,27 @@ public class MetricsLogger {
                sessionStatus);
    }

    /** Logs Bond State Machine event */
    public void logBondStateMachineEvent(BluetoothDevice device, int bondState) {
        switch (bondState) {
            case BluetoothDevice.BOND_NONE:
                logBluetoothEvent(
                        device,
                        BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__BOND,
                        BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__STATE_NONE,
                        0);
                break;
            case BluetoothDevice.BOND_BONDED:
                logBluetoothEvent(
                        device,
                        BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__BOND,
                        BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__STATE_BONDED,
                        0);
                break;
            default:
        }
    }

    /** Logs LE Audio Broadcast audio sync. */
    public void logLeAudioBroadcastAudioSync(
            BluetoothDevice device,
+0 −11
Original line number Diff line number Diff line
@@ -564,18 +564,7 @@ static void bond_state_changed(bt_status_t status, const RawAddress& bd_addr,

  if (pairing_cb.bond_type == BOND_TYPE_TEMPORARY) {
    state = BT_BOND_STATE_NONE;
  } else {
    if (state == BT_BOND_STATE_NONE) {
      bluetooth::os::LogMetricBluetoothEvent(ToGdAddress(bd_addr),
                                             android::bluetooth::EventType::BOND,
                                             android::bluetooth::State::STATE_NONE);
    } else if (state == BT_BOND_STATE_BONDED) {
      bluetooth::os::LogMetricBluetoothEvent(ToGdAddress(bd_addr),
                                             android::bluetooth::EventType::BOND,
                                             android::bluetooth::State::STATE_BONDED);
  }
  }

  log::info(
          "Bond state changed to state={}[0:none, 1:bonding, "
          "2:bonded],prev_state={}, sdp_attempts={}",