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

Commit 85e190e7 authored by Hui Peng's avatar Hui Peng
Browse files

Replace Log Statements in android/app/jni

Test: refactoring CL. Existing unit tests still pass
Bug: 174487588
Tag: #security
Change-Id: Ie180df76ef1df3e13f49072f6ad7eae5f6202df7
parent 509a9318
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -63,6 +63,7 @@ cc_library_shared {
    ],
    ],
    include_dirs: [
    include_dirs: [
        "packages/modules/Bluetooth/system/types",
        "packages/modules/Bluetooth/system/types",
        "packages/modules/Bluetooth/system/gd",
    ],
    ],
    static_libs: [
    static_libs: [
        "libbluetooth-types",
        "libbluetooth-types",
+14 −10
Original line number Original line Diff line number Diff line
@@ -16,14 +16,14 @@


#define LOG_TAG "BluetoothHeadsetServiceJni"
#define LOG_TAG "BluetoothHeadsetServiceJni"


#include <mutex>
#include <shared_mutex>

#include "com_android_bluetooth.h"
#include "com_android_bluetooth.h"
#include "hardware/bluetooth_headset_callbacks.h"
#include "hardware/bluetooth_headset_callbacks.h"
#include "hardware/bluetooth_headset_interface.h"
#include "hardware/bluetooth_headset_interface.h"
#include "hardware/bt_hf.h"
#include "hardware/bt_hf.h"
#include "utils/Log.h"
#include "os/log.h"

#include <mutex>
#include <shared_mutex>


namespace android {
namespace android {


@@ -78,7 +78,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
  void ConnectionStateCallback(
  void ConnectionStateCallback(
      bluetooth::headset::bthf_connection_state_t state,
      bluetooth::headset::bthf_connection_state_t state,
      RawAddress* bd_addr) override {
      RawAddress* bd_addr) override {
    ALOGI("%s %d for %s", __func__, state, bd_addr->ToString().c_str());
    ALOGI("%s %d for %s", __func__, state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr));


    std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex);
    std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex);
    CallbackEnv sCallbackEnv(__func__);
    CallbackEnv sCallbackEnv(__func__);
@@ -93,7 +93,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {


  void AudioStateCallback(bluetooth::headset::bthf_audio_state_t state,
  void AudioStateCallback(bluetooth::headset::bthf_audio_state_t state,
                          RawAddress* bd_addr) override {
                          RawAddress* bd_addr) override {
    ALOGI("%s, %d for %s", __func__, state, bd_addr->ToString().c_str());
    ALOGI("%s, %d for %s", __func__, state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr));


    std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex);
    std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex);
    CallbackEnv sCallbackEnv(__func__);
    CallbackEnv sCallbackEnv(__func__);
@@ -515,7 +515,8 @@ static jboolean connectHfpNative(JNIEnv* env, jobject object,
    jniThrowIOException(env, EINVAL);
    jniThrowIOException(env, EINVAL);
    return JNI_FALSE;
    return JNI_FALSE;
  }
  }
  ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str());
  ALOGI("%s: device %s", __func__,
        ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
  bt_status_t status = sBluetoothHfpInterface->Connect((RawAddress*)addr);
  bt_status_t status = sBluetoothHfpInterface->Connect((RawAddress*)addr);
  if (status != BT_STATUS_SUCCESS) {
  if (status != BT_STATUS_SUCCESS) {
    ALOGE("Failed HF connection, status: %d", status);
    ALOGE("Failed HF connection, status: %d", status);
@@ -537,7 +538,8 @@ static jboolean disconnectHfpNative(JNIEnv* env, jobject object,
    jniThrowIOException(env, EINVAL);
    jniThrowIOException(env, EINVAL);
    return JNI_FALSE;
    return JNI_FALSE;
  }
  }
  ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str());
  ALOGI("%s: device %s", __func__,
        ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
  bt_status_t status = sBluetoothHfpInterface->Disconnect((RawAddress*)addr);
  bt_status_t status = sBluetoothHfpInterface->Disconnect((RawAddress*)addr);
  if (status != BT_STATUS_SUCCESS) {
  if (status != BT_STATUS_SUCCESS) {
    ALOGE("Failed HF disconnection, status: %d", status);
    ALOGE("Failed HF disconnection, status: %d", status);
@@ -559,7 +561,8 @@ static jboolean connectAudioNative(JNIEnv* env, jobject object,
    jniThrowIOException(env, EINVAL);
    jniThrowIOException(env, EINVAL);
    return JNI_FALSE;
    return JNI_FALSE;
  }
  }
  ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str());
  ALOGI("%s: device %s", __func__,
        ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
  bt_status_t status =
  bt_status_t status =
      sBluetoothHfpInterface->ConnectAudio((RawAddress*)addr, false);
      sBluetoothHfpInterface->ConnectAudio((RawAddress*)addr, false);
  if (status != BT_STATUS_SUCCESS) {
  if (status != BT_STATUS_SUCCESS) {
@@ -582,7 +585,8 @@ static jboolean disconnectAudioNative(JNIEnv* env, jobject object,
    jniThrowIOException(env, EINVAL);
    jniThrowIOException(env, EINVAL);
    return JNI_FALSE;
    return JNI_FALSE;
  }
  }
  ALOGI("%s: device %s", __func__, ((RawAddress*)addr)->ToString().c_str());
  ALOGI("%s: device %s", __func__,
        ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
  bt_status_t status =
  bt_status_t status =
      sBluetoothHfpInterface->DisconnectAudio((RawAddress*)addr);
      sBluetoothHfpInterface->DisconnectAudio((RawAddress*)addr);
  if (status != BT_STATUS_SUCCESS) {
  if (status != BT_STATUS_SUCCESS) {