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

Commit c1f306b2 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12004070 from 6d4fcdca to 24Q4-release

Change-Id: I3e282a6e8f65ef51c0d019ff27cfd1a84c640442
parents 56bce9d3 6d4fcdca
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -19,6 +19,27 @@
# accommodate for handling of the large legacy code base.
#

# AOSP is based on google style with some modification commented below
BasedOnStyle: Google
CommentPragmas: NOLINT:.*
DerivePointerAlignment: false

---
Language: Cpp
# AOSP ask for 4, but we are not ready to touch every single line
# IndentWidth: 4 # vs 2
ColumnLimit: 100 # vs 80
ContinuationIndentWidth: 8 # vs 4
AccessModifierOffset: -2 # vs -1 Should be -4 when updating IndentWidth to 4
Standard: c++20 # vs Auto
AllowShortIfStatementsOnASingleLine: Never # vs WithoutElse
AllowShortLoopsOnASingleLine: false # vs true
SpacesBeforeTrailingComments: 1 # vs 2

# Allow clang-format to automatically fix more things
RemoveSemicolon: true
InsertBraces: true
RemoveParentheses: ReturnStatement

---
Language: Java
# Java format is handled by google-java-format
DisableFormat: true
+3 −0
Original line number Diff line number Diff line
set noparent
linelength=100
# Do not check access modifier indentation.
# CPPLint enforces +1, but our rule is no indentation.
filter=-whitespace/indent
 No newline at end of file

android/app/.clang-format

deleted100644 → 0
+0 −30
Original line number Diff line number Diff line
#
# Copyright (C) 2016 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.
#

#
# Below are some minor deviations from the default Google style to
# accommodate for handling of the large legacy code base.
#

BasedOnStyle: Google
CommentPragmas: NOLINT:.*
DerivePointerAlignment: false

---
Language: Java
# Java format is handled by check_style hook
DisableFormat: true
SortIncludes: false
+3 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ cc_library_shared {
        "libchrome",
        "libcutils",
        "libevent",
        "libexpresslog",
        "libflatbuffers-cpp",
        "libfmq",
        "libg722codec",
@@ -144,6 +145,8 @@ cc_library_shared {
        "libosi",
        "libprotobuf-cpp-lite",
        "libstatslog_bt",
        "libstatslog_express",
        "libtextclassifier_hash_static",
        "libudrv-uipc",
        "libutils",
        "server_configurable_flags",
+21 −39
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@

#define LOG_TAG "BluetoothA2dpSinkServiceJni"

#include <string.h>
#include <bluetooth/log.h>

#include <cstring>
#include <mutex>
#include <shared_mutex>

#include "btif/include/btif_av.h"
#include "com_android_bluetooth.h"
#include "hardware/bt_av.h"

@@ -29,7 +31,6 @@ static jmethodID method_onConnectionStateChanged;
static jmethodID method_onAudioStateChanged;
static jmethodID method_onAudioConfigChanged;

static const btav_sink_interface_t* sBluetoothA2dpInterface = NULL;
static jobject mCallbacksObj = NULL;
static std::shared_timed_mutex callbacks_mutex;

@@ -119,11 +120,7 @@ static void initNative(JNIEnv* env, jobject object,
    return;
  }

  if (sBluetoothA2dpInterface != NULL) {
    log::warn("Cleaning up A2DP Interface before initializing...");
    sBluetoothA2dpInterface->cleanup();
    sBluetoothA2dpInterface = NULL;
  }
  btif_av_sink_cleanup();

  if (mCallbacksObj != NULL) {
    log::warn("Cleaning up A2DP callback object");
@@ -131,20 +128,11 @@ static void initNative(JNIEnv* env, jobject object,
    mCallbacksObj = NULL;
  }

  sBluetoothA2dpInterface =
      (btav_sink_interface_t*)btInf->get_profile_interface(
          BT_PROFILE_ADVANCED_AUDIO_SINK_ID);
  if (sBluetoothA2dpInterface == NULL) {
    log::error("Failed to get Bluetooth A2DP Sink Interface");
    return;
  }

  bt_status_t status = sBluetoothA2dpInterface->init(&sBluetoothA2dpCallbacks,
                                                     maxConnectedAudioDevices);
  bt_status_t status =
      btif_av_sink_init(&sBluetoothA2dpCallbacks, maxConnectedAudioDevices);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed to initialize Bluetooth A2DP Sink, status: {}",
               bt_status_text(status));
    sBluetoothA2dpInterface = NULL;
    return;
  }

@@ -160,10 +148,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
    return;
  }

  if (sBluetoothA2dpInterface != NULL) {
    sBluetoothA2dpInterface->cleanup();
    sBluetoothA2dpInterface = NULL;
  }
  btif_av_sink_cleanup();

  if (mCallbacksObj != NULL) {
    env->DeleteGlobalRef(mCallbacksObj);
@@ -173,9 +158,6 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {

static jboolean connectA2dpNative(JNIEnv* env, jobject /* object */,
                                  jbyteArray address) {
  log::info("sBluetoothA2dpInterface: {}", fmt::ptr(sBluetoothA2dpInterface));
  if (!sBluetoothA2dpInterface) return JNI_FALSE;

  jbyte* addr = env->GetByteArrayElements(address, NULL);
  if (!addr) {
    jniThrowIOException(env, EINVAL);
@@ -184,18 +166,19 @@ static jboolean connectA2dpNative(JNIEnv* env, jobject /* object */,

  RawAddress bd_addr;
  bd_addr.FromOctets(reinterpret_cast<const uint8_t*>(addr));
  bt_status_t status = sBluetoothA2dpInterface->connect(bd_addr);

  log::info("{}", bd_addr);
  bt_status_t status = btif_av_sink_connect(bd_addr);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed HF connection, status: {}", bt_status_text(status));
  }

  env->ReleaseByteArrayElements(address, addr, 0);
  return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}

static jboolean disconnectA2dpNative(JNIEnv* env, jobject /* object */,
                                     jbyteArray address) {
  if (!sBluetoothA2dpInterface) return JNI_FALSE;

  jbyte* addr = env->GetByteArrayElements(address, NULL);
  if (!addr) {
    jniThrowIOException(env, EINVAL);
@@ -204,32 +187,29 @@ static jboolean disconnectA2dpNative(JNIEnv* env, jobject /* object */,

  RawAddress bd_addr;
  bd_addr.FromOctets(reinterpret_cast<const uint8_t*>(addr));
  bt_status_t status = sBluetoothA2dpInterface->disconnect(bd_addr);

  log::info("{}", bd_addr);
  bt_status_t status = btif_av_sink_disconnect(bd_addr);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed HF disconnection, status: {}", bt_status_text(status));
  }

  env->ReleaseByteArrayElements(address, addr, 0);
  return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}

static void informAudioFocusStateNative(JNIEnv* /* env */, jobject /* object */,
                                        jint focus_state) {
  if (!sBluetoothA2dpInterface) return;
  sBluetoothA2dpInterface->set_audio_focus_state((uint8_t)focus_state);
  btif_av_sink_set_audio_focus_state((uint8_t)focus_state);
}

static void informAudioTrackGainNative(JNIEnv* /* env */, jobject /* object */,
                                       jfloat gain) {
  if (!sBluetoothA2dpInterface) return;
  sBluetoothA2dpInterface->set_audio_track_gain((float)gain);
  btif_av_sink_set_audio_track_gain((float)gain);
}

static jboolean setActiveDeviceNative(JNIEnv* env, jobject /* object */,
                                      jbyteArray address) {
  if (!sBluetoothA2dpInterface) return JNI_FALSE;

  log::info("sBluetoothA2dpInterface: {}", fmt::ptr(sBluetoothA2dpInterface));

  jbyte* addr = env->GetByteArrayElements(address, NULL);
  if (!addr) {
    jniThrowIOException(env, EINVAL);
@@ -238,13 +218,15 @@ static jboolean setActiveDeviceNative(JNIEnv* env, jobject /* object */,

  RawAddress rawAddress;
  rawAddress.FromOctets((uint8_t*)addr);
  bt_status_t status = sBluetoothA2dpInterface->set_active_device(rawAddress);

  log::info("{}", rawAddress);
  bt_status_t status = btif_av_sink_set_active_device(rawAddress);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed sending passthru command, status: {}",
               bt_status_text(status));
  }
  env->ReleaseByteArrayElements(address, addr, 0);

  env->ReleaseByteArrayElements(address, addr, 0);
  return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}

Loading