--- /dev/null
+// 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",
+ ],
+}
--- /dev/null
+/******************************************************************************
+ *
+ * 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
--- /dev/null
+/******************************************************************************
+ *
+ * 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
],
whole_static_libs: [
"avrcp-target-service",
- "libaudio-a2dp-hw-utils",
"lib-bt-packets",
+ "libaudio-a2dp-hw-utils",
"libbt-audio-hal-interface",
+ "libbtaa",
],
cflags: [
"-DBUILDCFG",
#include <hardware/bt_activity_attribution.h>
+#include "btaa/include/activity_attribution.h"
#include "btif/include/btif_common.h"
#include "stack/include/btu.h"
void Init(ActivityAttributionCallbacks* callbacks) override {
this->callbacks = callbacks;
+ ActivityAttribution::Initialize(this);
}
void OnWakeup(Activity activity, const RawAddress& address) override {
Unretained(callbacks), activity, address));
}
- void Cleanup(void) override {}
+ void Cleanup(void) override {
+ do_in_main_thread(FROM_HERE, Bind(&ActivityAttribution::CleanUp));
+ }
private:
ActivityAttributionCallbacks* callbacks;