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

Commit 0f17844e authored by Michael Sun's avatar Michael Sun
Browse files

btaa: introduce Bluetooth Activity Attribution skeleton

This change added skeleton implementation of Bluetooth Activity
Attribution (BTAA) into the Bluetooth stack.

Tag: #feature
Bug: 170315554
Test: verified locally BTAA module get initialized

Change-Id: Iab3b976370e4d1866e9a308d4e6f9a11cdff037c
parent 80dff5ce
Loading
Loading
Loading
Loading

btaa/Android.bp

0 → 100755
+16 −0
Original line number Diff line number Diff line
// libbtaa static library for target
// ========================================================
cc_library_static {
    name: "libbtaa",
    defaults: ["fluoride_defaults"],
    local_include_dirs: [
        "include",
    ],
    srcs: [
        "src/activity_attribution.cc",
    ],
    apex_available: [
        "//apex_available:platform",
        "com.android.bluetooth.updatable",
    ],
}
+34 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright 2020 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 <hardware/bt_activity_attribution.h>

namespace bluetooth {
namespace activity_attribution {
class ActivityAttribution {
 public:
  virtual ~ActivityAttribution() = default;

  static void CleanUp();
  static void Initialize(ActivityAttributionCallbacks* callbacks);
};

}  // namespace activity_attribution
}  // namespace bluetooth
+53 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright 2020 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 "activity_attribution.h"

#include <base/logging.h>

namespace bluetooth {
namespace activity_attribution {

class ActivityAttributionImpl;
static std::unique_ptr<ActivityAttributionImpl> instance;

class ActivityAttributionImpl : public ActivityAttribution {
 public:
  ~ActivityAttributionImpl() override = default;
  ActivityAttributionImpl(ActivityAttributionCallbacks* callbacks);

 private:
  [[maybe_unused]] ActivityAttributionCallbacks* mCallbacks;
};

ActivityAttributionImpl::ActivityAttributionImpl(
    ActivityAttributionCallbacks* callbacks)
    : mCallbacks(callbacks) {}

void ActivityAttribution::CleanUp() { instance.reset(); };

void ActivityAttribution::Initialize(ActivityAttributionCallbacks* callbacks) {
  if (instance) {
    LOG(ERROR) << __func__ << " Already initialized!";
    return;
  }
  instance.reset(new ActivityAttributionImpl(callbacks));
}

}  // namespace activity_attribution
}  // namespace bluetooth
+2 −1
Original line number Diff line number Diff line
@@ -109,9 +109,10 @@ cc_library_static {
    ],
    whole_static_libs: [
        "avrcp-target-service",
        "libaudio-a2dp-hw-utils",
        "lib-bt-packets",
        "libaudio-a2dp-hw-utils",
        "libbt-audio-hal-interface",
        "libbtaa",
    ],
    cflags: [
        "-DBUILDCFG",
+5 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include <hardware/bt_activity_attribution.h>

#include "btaa/include/activity_attribution.h"
#include "btif/include/btif_common.h"
#include "stack/include/btu.h"

@@ -37,6 +38,7 @@ class ActivityAttributionInterfaceImpl : public ActivityAttributionCallbacks,

  void Init(ActivityAttributionCallbacks* callbacks) override {
    this->callbacks = callbacks;
    ActivityAttribution::Initialize(this);
  }

  void OnWakeup(Activity activity, const RawAddress& address) override {
@@ -46,7 +48,9 @@ class ActivityAttributionInterfaceImpl : public ActivityAttributionCallbacks,
                                     Unretained(callbacks), activity, address));
  }

  void Cleanup(void) override {}
  void Cleanup(void) override {
    do_in_main_thread(FROM_HERE, Bind(&ActivityAttribution::CleanUp));
  }

 private:
  ActivityAttributionCallbacks* callbacks;