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

Commit 57e44769 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge changes I48e0b7bf,I660b8e77,Id5580b27 into main

* changes:
  Flagging: wrap injected flag usage
  Flagging: Wrap static flag usage
  Flagging: use ifndef TARGET_FLOSS
parents 64f81b74 235eb326
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ java_aconfig_library {
cc_aconfig_library {
    name: "bluetooth_flags_c_lib",
    aconfig_declarations: "bluetooth_aconfig_flags",
    export_include_dirs: ["exported_include"],
    host_supported: true,
    visibility: [
        "//packages/modules/Bluetooth/system:__subpackages__",
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 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

#ifndef TARGET_FLOSS

#include <com_android_bluetooth_flags.h>

#define IS_FLAG_ENABLED(flag_name) com::android::bluetooth::flags::flag_name()
#define IS_FLAG_ENABLED_P(provider, flag_name) provider.flag_name()

#else

// FLOSS does not yet support android aconfig flags
#define IS_FLAG_ENABLED(flag_name) false
#define IS_FLAG_ENABLED_P(provider, flag_name) false

namespace com::android::bluetooth::flags {
struct flag_provider_interface {};
}  // namespace com::android::bluetooth::flags

#endif
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ if (defined(use.android) && use.android) {
config("target_defaults") {
  include_dirs = [
    "//bt/system",
    "//bt/flags/exported_include",
    "//bt/system/linux_include",
    "//bt/system/types",
    "//bt/system/include",
+5 −12
Original line number Diff line number Diff line
@@ -15,11 +15,9 @@
 * limitations under the License.
 */

#include <android_bluetooth_flags.h>
#include <base/functional/bind.h>
#include <base/strings/string_number_conversions.h>
#ifdef __ANDROID__
#include <com_android_bluetooth_flags.h>
#endif
#include <lc3.h>

#include <deque>
@@ -166,11 +164,9 @@ std::ostream& operator<<(std::ostream& os, const AudioState& audio_state) {
namespace {
void le_audio_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC* p_data);

#ifdef __ANDROID__
static void le_audio_health_status_callback(const RawAddress& addr,
                                            int group_id,
                                            LeAudioHealthBasedAction action);
#endif

class LeAudioClientImpl;
LeAudioClientImpl* instance;
@@ -254,14 +250,12 @@ class LeAudioClientImpl : public LeAudioClient {
      reconnection_mode_ = BTM_BLE_BKG_CONNECT_ALLOW_LIST;
    }

#ifdef __ANDROID__
    if (com::android::bluetooth::flags::leaudio_enable_health_based_actions()) {
    if (IS_FLAG_ENABLED(leaudio_enable_health_based_actions)) {
      LOG_INFO("Loading health status module");
      leAudioHealthStatus_ = LeAudioHealthStatus::Get();
      leAudioHealthStatus_->RegisterCallback(
          base::BindRepeating(le_audio_health_status_callback));
    }
#endif

    BTA_GATTC_AppRegister(
        le_audio_gattc_callback,
@@ -5481,14 +5475,13 @@ class LeAudioClientImpl : public LeAudioClient {
  }
};

#ifdef __ANDROID__
void le_audio_health_status_callback(const RawAddress& addr, int group_id,
static void le_audio_health_status_callback(const RawAddress& addr,
                                            int group_id,
                                            LeAudioHealthBasedAction action) {
  if (instance) {
    instance->LeAudioHealthSendRecommendation(addr, group_id, action);
  }
}
#endif

/* This is a generic callback method for gatt client which handles every client
 * application events.
+2 −7
Original line number Diff line number Diff line
@@ -17,12 +17,10 @@

#include "state_machine.h"

#include <android_bluetooth_flags.h>
#include <base/functional/bind.h>
#include <base/functional/callback.h>
#include <base/strings/string_number_conversions.h>
#ifdef __ANDROID__
#include <com_android_bluetooth_flags.h>
#endif

#include "bta_gatt_queue.h"
#include "btm_iso_api.h"
@@ -307,9 +305,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {

  void notifyLeAudioHealth(LeAudioDeviceGroup* group,
                           le_audio::LeAudioHealthGroupStatType stat) {
#ifdef __ANDROID__
    if (!com::android::bluetooth::flags::
            leaudio_enable_health_based_actions()) {
    if (!IS_FLAG_ENABLED(leaudio_enable_health_based_actions)) {
      return;
    }

@@ -317,7 +313,6 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
    if (leAudioHealthStatus) {
      leAudioHealthStatus->AddStatisticForGroup(group, stat);
    }
#endif
  }

  void ProcessGattCtpNotification(LeAudioDeviceGroup* group, uint8_t* value,