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

Commit 38220e2e authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "btaa: add btaa shim implementation"

parents 8f977f25 7cfa9fcc
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,9 @@ class ActivityAttributionInterface {
 public:
 public:
  virtual ~ActivityAttributionInterface() = default;
  virtual ~ActivityAttributionInterface() = default;


  /** Init the interface. */
  virtual void Init(void) = 0;

  /** Register JNI callbacks with the interface. */
  /** Register JNI callbacks with the interface. */
  virtual void RegisterCallbacks(ActivityAttributionCallbacks* callbacks) = 0;
  virtual void RegisterCallbacks(ActivityAttributionCallbacks* callbacks) = 0;


+1 −0
Original line number Original line Diff line number Diff line
@@ -13,6 +13,7 @@ filegroup {
        "acl.cc",
        "acl.cc",
        "acl_api.cc",
        "acl_api.cc",
        "acl_legacy_interface.cc",
        "acl_legacy_interface.cc",
        "activity_attribution.cc",
        "btm.cc",
        "btm.cc",
        "btm_api.cc",
        "btm_api.cc",
        "config.cc",
        "config.cc",
+67 −0
Original line number Original line 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.
 */

#define LOG_TAG "bt_shim_activity_attribution"
#include "activity_attribution.h"

#include "btif_common.h"
#include "gd/btaa/activity_attribution.h"
#include "helpers.h"
#include "main/shim/entry.h"

class ActivityAttributionInterfaceImpl
    : public ActivityAttributionInterface,
      public bluetooth::activity_attribution::ActivityAttributionCallback {
 public:
  ~ActivityAttributionInterfaceImpl() override = default;

  static ActivityAttributionInterfaceImpl* GetInstance() {
    static ActivityAttributionInterfaceImpl* instance =
        new ActivityAttributionInterfaceImpl();
    return instance;
  }

  void Init() override {
    bluetooth::shim::GetActivityAttribution()
        ->RegisterActivityAttributionCallback(this);
  }

  void RegisterCallbacks(ActivityAttributionCallbacks* callbacks) override {
    this->callbacks = callbacks;
  }

  void Cleanup(void) override{};

  void OnWakeup(const Activity activity,
                const bluetooth::hci::Address& address) override {
    do_in_jni_thread(
        FROM_HERE, base::Bind(&ActivityAttributionCallbacks::OnWakeup,
                              base::Unretained(callbacks),
                              (ActivityAttributionCallbacks::Activity)activity,
                              bluetooth::ToRawAddress(address)));
  }

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

  ActivityAttributionCallbacks* callbacks;
};

ActivityAttributionInterface*
bluetooth::shim::get_activity_attribution_instance() {
  return ActivityAttributionInterfaceImpl::GetInstance();
}
+32 −0
Original line number Original line 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.
 */

/**
 * Gd shim layer to activity attribution
 */
#pragma once

#include "include/hardware/bt_activity_attribution.h"

using namespace bluetooth::activity_attribution;

namespace bluetooth {
namespace shim {

ActivityAttributionInterface* get_activity_attribution_instance();

}  // namespace shim
}  // namespace bluetooth
+4 −0
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@
#include "gd/storage/storage_module.h"
#include "gd/storage/storage_module.h"


#include "main/shim/acl_legacy_interface.h"
#include "main/shim/acl_legacy_interface.h"
#include "main/shim/activity_attribution.h"
#include "main/shim/hci_layer.h"
#include "main/shim/hci_layer.h"
#include "main/shim/helpers.h"
#include "main/shim/helpers.h"
#include "main/shim/l2c_api.h"
#include "main/shim/l2c_api.h"
@@ -162,6 +163,9 @@ void Stack::StartEverything() {
      !common::init_flags::gd_core_is_enabled()) {
      !common::init_flags::gd_core_is_enabled()) {
    L2CA_UseLegacySecurityModule();
    L2CA_UseLegacySecurityModule();
  }
  }
  if (common::init_flags::btaa_hci_is_enabled()) {
    bluetooth::shim::get_activity_attribution_instance()->Init();
  }
}
}


void Stack::Start(ModuleList* modules) {
void Stack::Start(ModuleList* modules) {