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

Commit b9ba96fa authored by Michael Sun's avatar Michael Sun Committed by Gerrit Code Review
Browse files

Merge changes from topics "btaa-jni-1", "btaa-jni-2"

* changes:
  btaa: introduce btif interface for btaa
  btaa: new include files in bt stack for BTAA interface
parents 865f9def 80dff5ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ cc_library_static {
        "src/btif_a2dp_control.cc",
        "src/btif_a2dp_sink.cc",
        "src/btif_a2dp_source.cc",
        "src/btif_activity_attribution.cc",
        "src/btif_av.cc",
        "src/btif_avrcp_audio_track.cc",
        "src/btif_ble_advertiser.cc",
+25 −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 <hardware/bt_activity_attribution.h>

namespace bluetooth {
namespace activity_attribution {

ActivityAttributionInterface* getActivityAttributionInterface();

}  // namespace activity_attribution
}  // namespace bluetooth
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
#include "bta/include/bta_hf_client_api.h"
#include "btif/avrcp/avrcp_service.h"
#include "btif_a2dp.h"
#include "btif_activity_attribution.h"
#include "btif_api.h"
#include "btif_av.h"
#include "btif_bqr.h"
@@ -430,6 +431,11 @@ static const void* get_profile_interface(const char* profile_id) {

  if (is_profile(profile_id, BT_KEYSTORE_ID))
    return bluetooth::bluetooth_keystore::getBluetoothKeystoreInterface();

  if (is_profile(profile_id, BT_ACTIVITY_ATTRIBUTION_ID)) {
    return bluetooth::activity_attribution::getActivityAttributionInterface();
  }

  return NULL;
}

+63 −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.
 *
 ******************************************************************************/

/* Activity Attribution Interface */

#include <hardware/bt_activity_attribution.h>

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

using base::Bind;
using base::Unretained;

namespace bluetooth {
namespace activity_attribution {

std::unique_ptr<ActivityAttributionInterface> activityAttributionInstance;

class ActivityAttributionInterfaceImpl : public ActivityAttributionCallbacks,
                                         public ActivityAttributionInterface {
  ~ActivityAttributionInterfaceImpl() override = default;

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

  void OnWakeup(Activity activity, const RawAddress& address) override {
    VLOG(2) << __func__ << " activity: " << (int)activity
            << " address: " << address;
    do_in_jni_thread(FROM_HERE, Bind(&ActivityAttributionCallbacks::OnWakeup,
                                     Unretained(callbacks), activity, address));
  }

  void Cleanup(void) override {}

 private:
  ActivityAttributionCallbacks* callbacks;
};

ActivityAttributionInterface* getActivityAttributionInterface() {
  if (!activityAttributionInstance)
    activityAttributionInstance.reset(new ActivityAttributionInterfaceImpl());

  return activityAttributionInstance.get();
}

}  // namespace activity_attribution
}  // namespace bluetooth
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
#define BT_PROFILE_HEARING_AID_ID "hearing_aid"
#define BT_KEYSTORE_ID "bluetooth_keystore"
#define BT_ACTIVITY_ATTRIBUTION_ID "activity_attribution"

/** Bluetooth Device Name */
typedef struct { uint8_t name[249]; } __attribute__((packed)) bt_bdname_t;
Loading