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

Commit 43ed9717 authored by Eric Shih's avatar Eric Shih
Browse files

Adding Power Telemetry data into Dumpsys

Collect below Bluetooth activities data.
1. ACL and SCO link details
2. Connected L2cap, Rfcomm channel details
3. BR/EDR scan & inquiry details
4. ACL Tx/Rx packets details for fixed duration
5. L2cap & Rfcomm Tx/Rx details for fixed duration
6. Sniff activity details for each ACL handle

Change naming to Google C++ Style
Fix Native Crash issue
Writing data to log instead of file

Change-Id: I2354a6d20656fdb619cdf7951b053c5a3325116c
Bug: 237393639
Bug: 294794871
Test: atest net_test_osi
parent 159f23fe
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@
#include "osi/include/allocator.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/stack_power_telemetry.h"
#include "osi/include/wakelock.h"
#include "profile_log_levels.h"
#include "stack/btm/btm_sco_hfp_hal.h"
@@ -813,6 +814,7 @@ static void dump(int fd, const char** arguments) {
  DumpsysHid(fd);
  DumpsysBtaDm(fd);
  bluetooth::shim::Dump(fd, arguments);
  power_telemetry::GetInstance().Dumpsys(fd);
}

static void dumpMetrics(std::string* output) {
+2 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/properties.h"
#include "osi/include/stack_power_telemetry.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_sec.h"
#include "stack/include/bt_octets.h"
@@ -2494,6 +2495,7 @@ void btif_dm_start_discovery(void) {
  btif_dm_inquiry_in_progress = false;
  /* find nearby devices */
  BTA_DmSearch(btif_dm_search_devices_evt);
  power_telemetry::GetInstance().LogScanStarted();
}

/*******************************************************************************
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ cc_library_static {
        "src/socket.cc",
        "src/socket_utils/socket_local_client.cc",
        "src/socket_utils/socket_local_server.cc",
        "src/stack_power_telemetry.cc",
        "src/thread.cc",
        "src/thread_scheduler.cc",
        "src/wakelock.cc",
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ static_library("osi") {
    # dependencies are abstracted.
    "src/socket_utils/socket_local_client.cc",
    "src/socket_utils/socket_local_server.cc",
    "src/stack_power_telemetry.cc",
    "src/thread.cc",
    "src/wakelock.cc",

+73 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 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 <base/logging.h>

#include <cstdint>
#include <memory>

#include "types/raw_address.h"

namespace power_telemetry {

struct PowerTelemetryImpl;

class PowerTelemetry {
 public:
  PowerTelemetry();

  void RecordLogDataContainer();
  void LogScanStarted();

  void LogHciCmdDetail();
  void LogHciEvtDetail();

  void LogLinkDetails(uint16_t handle, const RawAddress& bdaddr,
                      bool isConnected, bool is_acl_link);
  void LogRxAclPktData(uint16_t len);
  void LogTxAclPktData(uint16_t len);

  void LogChannelConnected(uint16_t psm, int32_t src_id, int32_t dst_id,
                           const RawAddress& bd_addr);
  void LogChannelDisconnected(uint16_t psm, int32_t src_id, int32_t dst_id,
                              const RawAddress& bd_addr);
  void LogRxBytes(uint16_t psm, int32_t src_id, int32_t dst_id,
                  const RawAddress& bd_addr, int32_t num_bytes);
  void LogTxBytes(uint16_t psm, int32_t src_id, int32_t dst_id,
                  const RawAddress& bd_addr, int32_t num_bytes);

  void LogSniffStarted(uint16_t handle, const RawAddress& bdaddr);
  void LogSniffStopped(uint16_t handle, const RawAddress& bdaddr);
  void LogAclTxPowerLevel(uint16_t handle, uint8_t txPower);
  void LogInqScanStarted();
  void LogInqScanStopped();
  void LogBleAdvStarted();
  void LogBleAdvStopped();

  void LogTxPower(void* res);
  void LogTrafficData();

  void Dumpsys(int32_t fd);

 protected:
  std::unique_ptr<PowerTelemetryImpl> pimpl_;
};

PowerTelemetry& GetInstance();

}  // namespace power_telemetry
Loading