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

Commit df4af1ac authored by Mingguang Xu's avatar Mingguang Xu Committed by Gerrit Code Review
Browse files

Merge "btaa: Add the method of onActivityLogsReady into btif interface"

parents d7adb076 bcd9f6af
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -25,12 +25,23 @@ namespace activity_attribution {

enum class Activity : uint8_t { UNKNOWN = 0, ADVERTISE, CONNECT, CONTROL, SCAN, HFP, VENDOR };

struct BtaaAggregationEntry {
  hci::Address address;
  Activity activity;
  uint16_t wakeup_count;
  uint32_t byte_count;
  uint32_t wakelock_duration;
};

class ActivityAttributionCallback {
 public:
  virtual ~ActivityAttributionCallback() = default;

  // Callback when Blutooth woke up the system
  // Callback when Bluetooth woke up the system
  virtual void OnWakeup(const Activity activity, const hci::Address& address) = 0;

  // Callback when Bluetooth activity logs are ready to be moved
  virtual void OnActivityLogsReady(const std::vector<BtaaAggregationEntry> logs) = 0;
};

class ActivityAttribution : public bluetooth::Module {
+13 −1
Original line number Diff line number Diff line
@@ -34,10 +34,22 @@ class ActivityAttributionCallbacks {
    VENDOR
  };

  struct BtaaAggregationEntry {
    RawAddress address;
    Activity activity;
    uint16_t wakeup_count;
    uint32_t byte_count;
    uint32_t wakelock_duration;
  };

  virtual ~ActivityAttributionCallbacks() = default;

  /** Callback when Blutooth woke up the system */
  /** Callback when Bluetooth woke up the system */
  virtual void OnWakeup(const Activity activity, const RawAddress& address) = 0;

  /** Callback when Bluetooth activity logs are ready to be moved */
  virtual void OnActivityLogsReady(
      const std::vector<BtaaAggregationEntry> logs) = 0;
};

class ActivityAttributionInterface {
+17 −0
Original line number Diff line number Diff line
@@ -54,6 +54,23 @@ class ActivityAttributionInterfaceImpl
                              bluetooth::ToRawAddress(address)));
  }

  void OnActivityLogsReady(
      const std::vector<BtaaAggregationEntry> logs) override {
    std::vector<ActivityAttributionCallbacks::BtaaAggregationEntry>
        callback_logs;
    for (auto& it : logs) {
      ActivityAttributionCallbacks::BtaaAggregationEntry entry{
          bluetooth::ToRawAddress(it.address),
          (ActivityAttributionCallbacks::Activity)it.activity, it.wakeup_count,
          it.byte_count, it.wakelock_duration};
      callback_logs.push_back(entry);
    }
    do_in_jni_thread(
        FROM_HERE,
        base::Bind(&ActivityAttributionCallbacks::OnActivityLogsReady,
                   base::Unretained(callbacks), callback_logs));
  }

 private:
  // Private constructor to prevent construction.
  ActivityAttributionInterfaceImpl() {}