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

Commit 1f9f5d53 authored by Michael Sun's avatar Michael Sun Committed by Automerger Merge Worker
Browse files

Merge changes Ic8fb3193,Ied7a7552 am: a45ed88d

parents b36331f7 a45ed88d
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -15,7 +15,10 @@
#

source_set("BluetoothMetricsSources_chromeos") {
  sources = [ "chromeos/metrics.cc" ]
  sources = [
    "chromeos/metrics.cc",
    "chromeos/metrics_event.cc",
  ]
  configs += [ "//bt/system/gd:gd_defaults" ]
}

@@ -25,7 +28,10 @@ source_set("BluetoothMetricsSources_linux") {
}

source_set("BluetoothMetricsSources") {
  sources = [ "counter_metrics.cc" ]
  sources = [
    "counter_metrics.cc",
    "utils.cc",
  ]

  configs += [ "//bt/system/gd:gd_defaults" ]
  deps = [ "//bt/system/gd:gd_default_deps" ]
+22 −1
Original line number Diff line number Diff line
@@ -17,10 +17,31 @@

#include "gd/metrics/metrics.h"

#include <metrics/structured_events.h>

#include "common/time_util.h"
#include "gd/metrics/chromeos/metrics_event.h"
#include "gd/metrics/utils.h"

namespace bluetooth {
namespace metrics {

void LogMetricsAdapterStateChanged(uint32_t state){};
void LogMetricsAdapterStateChanged(uint32_t state) {
  std::string boot_id;

  if (!GetBootId(&boot_id)) return;

  ::metrics::structured::events::bluetooth::BluetoothAdapterStateChanged()
      .SetBootId(boot_id)
      .SetSystemTime(bluetooth::common::time_get_os_boottime_us())
      .SetIsFloss(true)
      .SetAdapterState((int64_t)ToAdapterState(state))
      .Record();
}

void LogMetricsBondCreateAttempt(RawAddress* addr) {}

void LogMetricsBondStateChanged(
    RawAddress* addr, uint32_t device_type, uint32_t status, uint32_t bond_state, int32_t fail_reason) {}
}  // namespace metrics
}  // namespace bluetooth
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "gd/metrics/chromeos/metrics_event.h"

namespace bluetooth {
namespace metrics {

AdapterState ToAdapterState(uint32_t state) {
  return state == 1 ? AdapterState::ON : AdapterState::OFF;
}

}  // namespace metrics
}  // namespace bluetooth
 No newline at end of file
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once

#include <cstdint>

namespace bluetooth {
namespace metrics {

// ENUM definitaion for adapter state that in sync with ChromeOS strcutured metrics
// BluetoothAdapterStateChanged/AdapterState.
enum class AdapterState : int64_t { OFF = 0, ON = 1 };

// Convert topshim::btif::BtState to AdapterState.
AdapterState ToAdapterState(uint32_t state);

}  // namespace metrics
}  // namespace bluetooth
 No newline at end of file
+6 −1
Original line number Diff line number Diff line
@@ -20,7 +20,12 @@
namespace bluetooth {
namespace metrics {

void LogMetricsAdapterStateChanged(uint32_t state){};
void LogMetricsAdapterStateChanged(uint32_t state) {}

void LogMetricsBondCreateAttempt(RawAddress* addr, uint32_t device_type) {}

void LogMetricsBondStateChanged(
    RawAddress* addr, uint32_t device_type, uint32_t status, uint32_t bond_state, int32_t fail_reason) {}

}  // namespace metrics
}  // namespace bluetooth
Loading