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

Commit 45125a5d authored by Palash Ahuja's avatar Palash Ahuja Committed by Gerrit Code Review
Browse files

Merge "BluetoothMetrics: Function for bluetooth event logging" into main

parents f13fbb70 e67854ca
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ struct formatter<android::bluetooth::DeviceInfoSrcEnum>
template <>
struct formatter<android::bluetooth::AddressTypeEnum>
    : enum_formatter<android::bluetooth::AddressTypeEnum> {};
template <>
struct formatter<android::bluetooth::EventType> : enum_formatter<android::bluetooth::EventType> {};
template <>
struct formatter<android::bluetooth::State> : enum_formatter<android::bluetooth::State> {};
}  // namespace fmt

namespace bluetooth {
@@ -447,5 +451,19 @@ void LogMetricBluetoothLEConnection(os::LEConnectionSessionOptions session_optio
  }
}

void LogMetricBluetoothEvent(const Address& address, android::bluetooth::EventType event_type,
                             android::bluetooth::State state) {
  if (address.IsEmpty()) {
    log::warn("Failed BluetoothEvent Upload - Address is Empty");
    return;
  }
  int metric_id = MetricIdManager::GetInstance().AllocateId(address);
  int ret = stats_write(BLUETOOTH_CROSS_LAYER_EVENT_REPORTED, event_type, state, 0, metric_id, 0);
  if (ret < 0) {
    log::warn("Failed BluetoothEvent Upload - Address {}, Event_type {}, State {}", address,
              event_type, state);
  }
}

}  // namespace os
}  // namespace bluetooth
+3 −0
Original line number Diff line number Diff line
@@ -209,5 +209,8 @@ void LogMetricBluetoothLEConnectionMetricEvent(
        std::vector<std::pair<os::ArgumentType, int>>& argument_list) {}

void LogMetricBluetoothLEConnection(os::LEConnectionSessionOptions /* session_options */) {}

void LogMetricBluetoothEvent(const Address& address, android::bluetooth::EventType event_type,
                             android::bluetooth::State state) {}
}  // namespace os
}  // namespace bluetooth
+3 −0
Original line number Diff line number Diff line
@@ -130,5 +130,8 @@ void LogMetricBluetoothLEConnectionMetricEvent(

void LogMetricBluetoothLEConnection(os::LEConnectionSessionOptions /* session_options */) {}

void LogMetricBluetoothEvent(const Address& /* address */,
                             android::bluetooth::EventType /* event type */,
                             android::bluetooth::State /* state */) {}
}  // namespace os
}  // namespace bluetooth
+3 −0
Original line number Diff line number Diff line
@@ -115,5 +115,8 @@ void LogMetricBluetoothLEConnectionMetricEvent(
        std::vector<std::pair<os::ArgumentType, int>>& argument_list) {}

void LogMetricBluetoothLEConnection(os::LEConnectionSessionOptions /* session_options */) {}

void LogMetricBluetoothEvent(const Address& address, android::bluetooth::EventType event_type,
                             android::bluetooth::State state) {}
}  // namespace os
}  // namespace bluetooth
+9 −0
Original line number Diff line number Diff line
@@ -344,6 +344,15 @@ void LogMetricBluetoothLEConnectionMetricEvent(
// Upload LE Session
void LogMetricBluetoothLEConnection(os::LEConnectionSessionOptions session_options);

/**
 * Logs a Bluetooth Event
 *
 * @param address address of associated device
 * @param event_type type of event where this is getting logged from
 * @param state state associated with the event
 */
void LogMetricBluetoothEvent(const hci::Address& address, android::bluetooth::EventType event_type,
                             android::bluetooth::State state);
}  // namespace os
   //
}  // namespace bluetooth