diff --git a/Android.bp b/Android.bp
index d585c6c9ca8ca57197d8b9b4ebd8f333271eb60b..2066ba6d4b81efd72bd132dcd3cec6b1983bf942 100644
--- a/Android.bp
+++ b/Android.bp
@@ -70,5 +70,5 @@ cc_defaults {
"-Werror=reorder-init-list",
],
c_std: "c99",
- cpp_std: "c++17",
+ cpp_std: "c++20",
}
diff --git a/OWNERS_leaudio b/OWNERS_leaudio
index 30db38d7995a5464633021e6f1f61d743d5e8eb1..0ba606bbf0a93823fbc6d975e4764668385a7116 100644
--- a/OWNERS_leaudio
+++ b/OWNERS_leaudio
@@ -1,3 +1,4 @@
siyuanh@google.com
jpawlowski@google.com
rongxuan@google.com
+yuyangh@google.com
diff --git a/README.md b/README.md
index 60daa85761dbb04c4e2e158d9a6da1e9ee4621b9..3df5e04b6d58623edbcdb0aa0b245db879a580f6 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ sudo apt-get install repo git-core gnupg flex bison gperf build-essential \
libgl1-mesa-dev libxml2-utils xsltproc unzip liblz4-tool libssl-dev \
libc++-dev libevent-dev \
flatbuffers-compiler libflatbuffers1 openssl \
- libflatbuffers-dev libtinyxml2-dev \
+ libflatbuffers-dev libfmt-dev libtinyxml2-dev \
libglib2.0-dev libevent-dev libnss3-dev libdbus-1-dev \
libprotobuf-dev ninja-build generate-ninja protobuf-compiler \
libre2-9 debmake \
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 4e568c8a98c06c3a7713d86f40c1649b3667f671..8f167cf47bef32ce0d6bcc4102b31c0ae4d4f06f 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -323,9 +323,15 @@
{
"name": "bluetooth_le_audio_codec_manager_test"
},
+ {
+ "name": "bluetooth-test-audio-hal-a2dp-provider-info"
+ },
{
"name": "bluetooth_test_gdx_unit"
},
+ {
+ "name": "CtsStrictJavaPackagesTestCases"
+ },
{
"name": "asrc_resampler_test"
}
diff --git a/android/app/Android.bp b/android/app/Android.bp
index 1d43cfefa3445f04077b9f95e0a66543e8dbac17..835fb9f9317ac8d5beb46f9eec0ce7dc765d920f 100644
--- a/android/app/Android.bp
+++ b/android/app/Android.bp
@@ -37,6 +37,9 @@ java_library {
],
min_sdk_version: "Tiramisu",
sdk_version: "module_current",
+ lint: {
+ baseline_filename: "lint-baseline.xml",
+ },
}
java_library {
@@ -49,6 +52,9 @@ java_library {
],
min_sdk_version: "Tiramisu",
sdk_version: "module_current",
+ lint: {
+ baseline_filename: "lint-baseline.xml",
+ },
}
// Bluetooth JNI
@@ -99,17 +105,21 @@ cc_library_shared {
"libbase",
"libbluetooth",
"libbluetooth-dumpsys",
+ "libbluetooth-gdx",
"libbluetooth-types",
"libbluetooth_core_rs",
"libbluetooth_core_rs_bridge",
"libbluetooth_crypto_toolbox",
"libbluetooth_gd",
+ "libbluetooth_log",
+ "libbt-audio-asrc",
"libbt-audio-hal-interface",
"libbt-bta",
"libbt-bta-core",
"libbt-btu-main-thread",
"libbt-common",
"libbt-hci",
+ "libbt-jni-thread",
"libbt-sbc-decoder",
"libbt-sbc-encoder",
"libbt-stack",
@@ -228,6 +238,7 @@ android_app {
jni_uses_platform_apis: true,
libs: [
"app-compat-annotations",
+ "bluetooth_flags_java_lib",
"error_prone_annotations",
"framework-annotations-lib",
"framework-bluetooth-pre-jarjar",
@@ -255,7 +266,6 @@ android_app {
"bluetooth-protos-lite",
"bluetooth.change-ids",
"bluetooth.mapsapi",
- "bluetooth_flags_java_lib",
"com.android.obex",
"com.android.vcard",
"guava",
@@ -290,7 +300,7 @@ android_app {
"UseSparseArrays",
"UseValueOf",
],
- strict_updatability_linting: true,
+ baseline_filename: "lint-baseline.xml",
},
optimize: {
diff --git a/android/app/AndroidManifest.xml b/android/app/AndroidManifest.xml
index 3e07cc5b0f58da57d85960c1436b8b34b8b55d36..c0548dd8325cb423f03cd38aa6cad185f19ca7f4 100644
--- a/android/app/AndroidManifest.xml
+++ b/android/app/AndroidManifest.xml
@@ -104,64 +104,16 @@
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android/app/aidl/Android.bp b/android/app/aidl/Android.bp
index 8a5e2612d55d38a65b7aac28324155e5cad3a8c8..6d9c8871c3bf04539497b5d1edfdc2d7ff6f3759 100644
--- a/android/app/aidl/Android.bp
+++ b/android/app/aidl/Android.bp
@@ -57,7 +57,6 @@ filegroup {
"android/bluetooth/IBluetoothQualityReportReadyCallback.aidl",
"android/bluetooth/IBluetoothSap.aidl",
"android/bluetooth/IBluetoothSocketManager.aidl",
- "android/bluetooth/IBluetoothStateChangeCallback.aidl",
"android/bluetooth/IBluetoothVolumeControl.aidl",
"android/bluetooth/IBluetoothVolumeControlCallback.aidl",
"android/bluetooth/IncomingRfcommSocketInfo.aidl",
diff --git a/android/app/aidl/android/bluetooth/IBluetooth.aidl b/android/app/aidl/android/bluetooth/IBluetooth.aidl
index 80c6fe426f1c5c16098d82529dbbc21e52fa02bd..b937d99d97ecd8f2d19b2a21a395c2bc28d68a42 100644
--- a/android/app/aidl/android/bluetooth/IBluetooth.aidl
+++ b/android/app/aidl/android/bluetooth/IBluetooth.aidl
@@ -26,7 +26,6 @@ import android.bluetooth.IBluetoothConnectionCallback;
import android.bluetooth.IBluetoothMetadataListener;
import android.bluetooth.IBluetoothOobDataCallback;
import android.bluetooth.IBluetoothSocketManager;
-import android.bluetooth.IBluetoothStateChangeCallback;
import android.bluetooth.BluetoothActivityEnergyInfo;
import android.bluetooth.BluetoothSinkAudioPolicy;
import android.bluetooth.BluetoothClass;
@@ -176,7 +175,9 @@ interface IBluetooth
IBluetoothSocketManager getSocketManager();
@JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
- oneway void logL2capcocClientConnection(in BluetoothDevice device, int port, boolean isSecured, int result, long socketCreationTimeMillis, long socketCreationLatencyMillis, long socketConnectionTimeMillis, in SynchronousResultReceiver receiver);
+ oneway void logL2capcocClientConnection(in BluetoothDevice device, int port, boolean isSecured, int result, long socketCreationTimeNanos, long socketCreationLatencyNanos, long socketConnectionTimeNanos, in SynchronousResultReceiver receiver);
+ @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
+ oneway void logRfcommConnectionAttempt(in BluetoothDevice device, boolean isSecured, int resultCode, long socketCreationTimeNanos, boolean isSerialPort, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
oneway void factoryReset(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@@ -309,4 +310,13 @@ interface IBluetooth
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
oneway void unregAllGattClient(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
+
+ @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
+ oneway void getProfile(int profile, in SynchronousResultReceiver receiver);
+
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ oneway void setActiveAudioDevicePolicy(in BluetoothDevice device, int activeAudioDevicePolicy, in AttributionSource source, in SynchronousResultReceiver receiver);
+
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ oneway void getActiveAudioDevicePolicy(in BluetoothDevice device, in AttributionSource source, in SynchronousResultReceiver receiver);
}
diff --git a/android/app/aidl/android/bluetooth/IBluetoothGatt.aidl b/android/app/aidl/android/bluetooth/IBluetoothGatt.aidl
index 8c5305e02aa6f2687d42c84854fd987f4dc25dd6..ab05c5156c216bd79f35bb6b9ddd3f3ef255d018 100644
--- a/android/app/aidl/android/bluetooth/IBluetoothGatt.aidl
+++ b/android/app/aidl/android/bluetooth/IBluetoothGatt.aidl
@@ -190,4 +190,10 @@ oneway interface IBluetoothGatt {
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void stopDistanceMeasurement(in ParcelUuid uuid, in BluetoothDevice device, in int method, in AttributionSource attributionSource,
in SynchronousResultReceiver receiver);
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ void getChannelSoundingMaxSupportedSecurityLevel(in BluetoothDevice remoteDevice, in AttributionSource attributionSource,
+ in SynchronousResultReceiver receiver);
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ void getLocalChannelSoundingMaxSupportedSecurityLevel(in AttributionSource attributionSource,
+ in SynchronousResultReceiver receiver);
}
diff --git a/android/app/aidl/android/bluetooth/IBluetoothHidHost.aidl b/android/app/aidl/android/bluetooth/IBluetoothHidHost.aidl
index 421e1ada88844a986c65fcf01dd1b23bb3008f28..1753700b6b88cd2a7bd6838fe62950bf3695b037 100644
--- a/android/app/aidl/android/bluetooth/IBluetoothHidHost.aidl
+++ b/android/app/aidl/android/bluetooth/IBluetoothHidHost.aidl
@@ -42,6 +42,10 @@ oneway interface IBluetoothHidHost {
void setConnectionPolicy(in BluetoothDevice device, int connectionPolicy, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void getConnectionPolicy(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ void setPreferredTransport(in BluetoothDevice device, int transport, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ void getPreferredTransport(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
void getProtocolMode(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
diff --git a/android/app/aidl/android/bluetooth/IBluetoothLeAudio.aidl b/android/app/aidl/android/bluetooth/IBluetoothLeAudio.aidl
index d2dd14563ca3dd8933e0c96e04115f3e1e275bc1..9c6f87e7c5257ecf2171bdb15ddb4890fe72a870 100644
--- a/android/app/aidl/android/bluetooth/IBluetoothLeAudio.aidl
+++ b/android/app/aidl/android/bluetooth/IBluetoothLeAudio.aidl
@@ -81,6 +81,9 @@ oneway interface IBluetoothLeAudio {
const int GROUP_NODE_ADDED = 1;
const int GROUP_NODE_REMOVED = 2;
+ const int GROUP_STREAM_STATUS_IDLE = 0;
+ const int GROUP_STREAM_STATUS_STREAMING = 1;
+
/**
* Get device group id. Devices with same group id belong to same group (i.e left and right
* earbud)
@@ -119,4 +122,6 @@ oneway interface IBluetoothLeAudio {
void getMaximumStreamsPerBroadcast(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT})")
void getMaximumSubgroupsPerBroadcast(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ void isBroadcastActive(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
}
diff --git a/android/app/aidl/android/bluetooth/IBluetoothLeAudioCallback.aidl b/android/app/aidl/android/bluetooth/IBluetoothLeAudioCallback.aidl
index 547b3cb0c6ebb9302721c7e7194b79cd030fe6f1..92ecfe814d4218aec4c5847bbe82131041f54d1d 100644
--- a/android/app/aidl/android/bluetooth/IBluetoothLeAudioCallback.aidl
+++ b/android/app/aidl/android/bluetooth/IBluetoothLeAudioCallback.aidl
@@ -31,4 +31,5 @@ oneway interface IBluetoothLeAudioCallback {
void onGroupNodeAdded(in BluetoothDevice device, int groupId);
void onGroupNodeRemoved(in BluetoothDevice device, int groupId);
void onGroupStatusChanged(int groupId, int groupStatus);
+ void onGroupStreamStatusChanged(int groupId, int groupStreamStatus);
}
diff --git a/android/app/aidl/android/bluetooth/IBluetoothVolumeControl.aidl b/android/app/aidl/android/bluetooth/IBluetoothVolumeControl.aidl
index 179cb8ac7e302763dd0ee66bbaa07f4eabef1efa..b269181545732ad6d924e7f665ca4d319d8822b5 100644
--- a/android/app/aidl/android/bluetooth/IBluetoothVolumeControl.aidl
+++ b/android/app/aidl/android/bluetooth/IBluetoothVolumeControl.aidl
@@ -37,28 +37,30 @@ oneway interface IBluetoothVolumeControl {
void connect(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
void disconnect(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
- @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void getConnectedDevices(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
- @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void getDevicesMatchingConnectionStates(in int[] states, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
- @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void getConnectionState(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void setConnectionPolicy(in BluetoothDevice device, int connectionPolicy, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void getConnectionPolicy(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
- @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void isVolumeOffsetAvailable(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
- @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
- void setVolumeOffset(in BluetoothDevice device, int volumeOffset, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ void getNumberOfVolumeOffsetInstances(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ void setVolumeOffset(in BluetoothDevice device, int instanceId, int volumeOffset, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
void setGroupVolume(int group_id, int volume, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
void getGroupVolume(int group_id, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
void setGroupActive(int group_id, boolean active, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
- @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void setDeviceVolume(in BluetoothDevice device, int volume, boolean isGroupOp, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
@@ -75,4 +77,6 @@ oneway interface IBluetoothVolumeControl {
void registerCallback(in IBluetoothVolumeControlCallback callback, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
void unregisterCallback(in IBluetoothVolumeControlCallback callback, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
+ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
+ void notifyNewRegisteredCallback(in IBluetoothVolumeControlCallback callback, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
}
diff --git a/android/app/aidl/android/bluetooth/IBluetoothVolumeControlCallback.aidl b/android/app/aidl/android/bluetooth/IBluetoothVolumeControlCallback.aidl
index 4467be1e9b67fdd4aa1c434598d6aa8a40da1861..e0679897395270a67f1d2fce3afbe08ea7fa84a0 100644
--- a/android/app/aidl/android/bluetooth/IBluetoothVolumeControlCallback.aidl
+++ b/android/app/aidl/android/bluetooth/IBluetoothVolumeControlCallback.aidl
@@ -26,6 +26,8 @@ import java.util.List;
* @hide
*/
oneway interface IBluetoothVolumeControlCallback {
- void onVolumeOffsetChanged(in BluetoothDevice device, in int volumeOffset);
+ void onVolumeOffsetChanged(in BluetoothDevice device, in int instanceId, in int volumeOffset);
+ void onVolumeOffsetAudioLocationChanged(in BluetoothDevice device, in int instanceId, in int audioLocation);
+ void onVolumeOffsetAudioDescriptionChanged(in BluetoothDevice device, in int instanceId, in String audioDescription);
void onDeviceVolumeChanged(in BluetoothDevice device, in int volume);
}
diff --git a/android/app/aidl/android/bluetooth/le/IAdvertisingSetCallback.aidl b/android/app/aidl/android/bluetooth/le/IAdvertisingSetCallback.aidl
index 2e3241c360f17b8f581053d61e87f53e40b81b95..35e88a4a6848c886b753b3d82f58729541220212 100644
--- a/android/app/aidl/android/bluetooth/le/IAdvertisingSetCallback.aidl
+++ b/android/app/aidl/android/bluetooth/le/IAdvertisingSetCallback.aidl
@@ -20,7 +20,7 @@ package android.bluetooth.le;
* @hide
*/
oneway interface IAdvertisingSetCallback {
- void onAdvertisingSetStarted(in int advertiserId, in int tx_power, in int status);
+ void onAdvertisingSetStarted(in IBinder gattBinder, in int advertiserId, in int tx_power, in int status);
void onOwnAddressRead(in int advertiserId, in int addressType, in String address);
void onAdvertisingSetStopped(in int advertiserId);
void onAdvertisingEnabled(in int advertiserId, in boolean enable, in int status);
diff --git a/android/app/jni/OWNERS b/android/app/jni/OWNERS
index 3baddf6903d5b9bc00ce5ef86c6cf8c50e2f029e..826f56b4e06f6c1d60c4ec0d20f37e565071869f 100644
--- a/android/app/jni/OWNERS
+++ b/android/app/jni/OWNERS
@@ -1 +1,4 @@
per-file com_android_bluetooth_hearing_aid.cpp=file:/OWNERS_hearingaid
+per-file com_android_bluetooth_csip_set_coordinator.cpp=file:/OWNERS_leaudio
+per-file com_android_bluetooth_le_audio.cpp=file:/OWNERS_leaudio
+per-file com_android_bluetooth_vc.cpp=file:/OWNERS_leaudio
diff --git a/android/app/jni/com_android_bluetooth.h b/android/app/jni/com_android_bluetooth.h
index 502e695621090456862c7ca6f8dc885ad77d4f4a..45b4e74d1314799e5e2a932f714b24e0176ce54e 100644
--- a/android/app/jni/com_android_bluetooth.h
+++ b/android/app/jni/com_android_bluetooth.h
@@ -15,15 +15,16 @@
* limitations under the License.
*/
-#ifndef COM_ANDROID_BLUETOOTH_H
-#define COM_ANDROID_BLUETOOTH_H
+#pragma once
+
+#include
#include "hardware/bluetooth.h"
#include "hardware/hardware.h"
#include "jni.h"
-#include "jni_logging.h"
#include "nativehelper/ScopedLocalRef.h"
-#include "utils/Log.h"
+
+namespace log = bluetooth::log;
namespace android {
@@ -38,15 +39,15 @@ public:
~CallbackEnv() {
if (mCallbackEnv && mCallbackEnv->ExceptionCheck()) {
- ALOGE("An exception was thrown by callback '%s'.", mName);
- LOGE_EX(mCallbackEnv);
- mCallbackEnv->ExceptionClear();
+ log::error("An exception was thrown by callback '{}'.", mName);
+ jniLogException(mCallbackEnv, ANDROID_LOG_ERROR, LOG_TAG);
+ mCallbackEnv->ExceptionClear();
}
}
bool valid() const {
if (!mCallbackEnv || !isCallbackThread()) {
- ALOGE("%s: Callback env fail", mName);
+ log::error("{}: Callback env fail", mName);
return false;
}
return true;
@@ -184,5 +185,3 @@ void jniGetMethodsOrDie(JNIEnv* env, const char* className,
jniGetMethodsOrDie(env, classname, methodsArray, NELEM(methodsArray))
} // namespace android
-
-#endif /* COM_ANDROID_BLUETOOTH_H */
diff --git a/android/app/jni/com_android_bluetooth_BluetoothQualityReport.cpp b/android/app/jni/com_android_bluetooth_BluetoothQualityReport.cpp
index 6472ef2397c57fb3f907b2a5b373535a812110af..747e25fbde43af4f1e32bcb97c138408dd81ce44 100644
--- a/android/app/jni/com_android_bluetooth_BluetoothQualityReport.cpp
+++ b/android/app/jni/com_android_bluetooth_BluetoothQualityReport.cpp
@@ -22,7 +22,7 @@
#include "base/logging.h"
#include "com_android_bluetooth.h"
-#include "gd/common/init_flags.h"
+#include "common/init_flags.h"
#include "hardware/bt_bqr.h"
using bluetooth::bqr::BluetoothQualityReportCallbacks;
@@ -46,7 +46,7 @@ class BluetoothQualityReportCallbacksImpl
void bqr_delivery_callback(const RawAddress bd_addr, uint8_t lmp_ver,
uint16_t lmp_subver, uint16_t manufacturer_id,
std::vector bqr_raw_data) override {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -57,7 +57,7 @@ class BluetoothQualityReportCallbacksImpl
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Error while allocation byte array for addr in %s", __func__);
+ log::error("Error while allocation byte array for addr");
return;
}
@@ -67,8 +67,7 @@ class BluetoothQualityReportCallbacksImpl
ScopedLocalRef raw_data(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(bqr_raw_data.size()));
if (!raw_data.get()) {
- ALOGE("Error while allocation byte array for bqr raw data in %s",
- __func__);
+ log::error("Error while allocation byte array for bqr raw data");
return;
}
sCallbackEnv->SetByteArrayRegion(raw_data.get(), 0, bqr_raw_data.size(),
@@ -93,32 +92,32 @@ static void initNative(JNIEnv* env, jobject object) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
if (sBluetoothQualityReportInterface != nullptr) {
- LOG(INFO) << "Cleaning up BluetoothQualityReport Interface before "
- "initializing...";
+ log::info(
+ "Cleaning up BluetoothQualityReport Interface before initializing...");
sBluetoothQualityReportInterface = nullptr;
}
if (mCallbacksObj != nullptr) {
- LOG(INFO) << "Cleaning up BluetoothQualityReport callback object";
+ log::info("Cleaning up BluetoothQualityReport callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = nullptr;
}
if ((mCallbacksObj = env->NewGlobalRef(object)) == nullptr) {
- LOG(ERROR)
- << "Failed to allocate Global Ref for BluetoothQualityReport Callbacks";
+ log::error(
+ "Failed to allocate Global Ref for BluetoothQualityReport Callbacks");
return;
}
sBluetoothQualityReportInterface =
(BluetoothQualityReportInterface*)btInf->get_profile_interface(BT_BQR_ID);
if (sBluetoothQualityReportInterface == nullptr) {
- LOG(ERROR) << "Failed to get BluetoothQualityReport Interface";
+ log::error("Failed to get BluetoothQualityReport Interface");
return;
}
@@ -131,7 +130,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
diff --git a/android/app/jni/com_android_bluetooth_a2dp.cpp b/android/app/jni/com_android_bluetooth_a2dp.cpp
index c2427e10bf04ae2dc0ce21f64aae627c65bfc063..7486ccbb58920cd39a1ada3d4a27a105f600a373 100644
--- a/android/app/jni/com_android_bluetooth_a2dp.cpp
+++ b/android/app/jni/com_android_bluetooth_a2dp.cpp
@@ -44,6 +44,7 @@ static struct {
} android_bluetooth_BluetoothCodecConfig;
static const btav_source_interface_t* sBluetoothA2dpInterface = nullptr;
+static std::vector supported_codecs;
static std::shared_timed_mutex interface_mutex;
static jobject mCallbacksObj = nullptr;
@@ -52,7 +53,7 @@ static std::shared_timed_mutex callbacks_mutex;
static void bta2dp_connection_state_callback(const RawAddress& bd_addr,
btav_connection_state_t state,
const btav_error_t& /* error */) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -61,7 +62,7 @@ static void bta2dp_connection_state_callback(const RawAddress& bd_addr,
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Fail to new jbyteArray bd addr", __func__);
+ log::error("Fail to new jbyteArray bd addr");
return;
}
@@ -74,7 +75,7 @@ static void bta2dp_connection_state_callback(const RawAddress& bd_addr,
static void bta2dp_audio_state_callback(const RawAddress& bd_addr,
btav_audio_state_t state) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -83,7 +84,7 @@ static void bta2dp_audio_state_callback(const RawAddress& bd_addr,
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Fail to new jbyteArray bd addr", __func__);
+ log::error("Fail to new jbyteArray bd addr");
return;
}
@@ -98,7 +99,7 @@ static void bta2dp_audio_config_callback(
const RawAddress& bd_addr, btav_a2dp_codec_config_t codec_config,
std::vector codecs_local_capabilities,
std::vector codecs_selectable_capabilities) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -150,7 +151,7 @@ static void bta2dp_audio_config_callback(
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(RawAddress::kLength));
if (!addr.get()) {
- ALOGE("%s: Fail to new jbyteArray bd addr", __func__);
+ log::error("Fail to new jbyteArray bd addr");
return;
}
sCallbackEnv->SetByteArrayRegion(
@@ -164,7 +165,7 @@ static void bta2dp_audio_config_callback(
static bool bta2dp_mandatory_codec_preferred_callback(
const RawAddress& bd_addr) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -173,7 +174,7 @@ static bool bta2dp_mandatory_codec_preferred_callback(
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(RawAddress::kLength));
if (!addr.get()) {
- ALOGE("%s: Fail to new jbyteArray bd addr", __func__);
+ log::error("Fail to new jbyteArray bd addr");
return false;
}
sCallbackEnv->SetByteArrayRegion(
@@ -201,7 +202,7 @@ static std::vector prepareCodecPreferences(
if (jcodecConfig == nullptr) continue;
if (!env->IsInstanceOf(jcodecConfig,
android_bluetooth_BluetoothCodecConfig.clazz)) {
- ALOGE("%s: Invalid BluetoothCodecConfig instance", __func__);
+ log::error("Invalid BluetoothCodecConfig instance");
continue;
}
jint codecType = env->CallIntMethod(
@@ -251,32 +252,31 @@ static void initNative(JNIEnv* env, jobject object,
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- ALOGE("%s: Bluetooth module is not loaded", __func__);
+ log::error("Bluetooth module is not loaded");
return;
}
if (sBluetoothA2dpInterface != nullptr) {
- ALOGW("%s: Cleaning up A2DP Interface before initializing...", __func__);
+ log::warn("Cleaning up A2DP Interface before initializing...");
sBluetoothA2dpInterface->cleanup();
sBluetoothA2dpInterface = nullptr;
}
if (mCallbacksObj != nullptr) {
- ALOGW("%s: Cleaning up A2DP callback object", __func__);
+ log::warn("Cleaning up A2DP callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = nullptr;
}
if ((mCallbacksObj = env->NewGlobalRef(object)) == nullptr) {
- ALOGE("%s: Failed to allocate Global Ref for A2DP Callbacks", __func__);
+ log::error("Failed to allocate Global Ref for A2DP Callbacks");
return;
}
android_bluetooth_BluetoothCodecConfig.clazz = (jclass)env->NewGlobalRef(
env->FindClass("android/bluetooth/BluetoothCodecConfig"));
if (android_bluetooth_BluetoothCodecConfig.clazz == nullptr) {
- ALOGE("%s: Failed to allocate Global Ref for BluetoothCodecConfig class",
- __func__);
+ log::error("Failed to allocate Global Ref for BluetoothCodecConfig class");
return;
}
@@ -284,7 +284,7 @@ static void initNative(JNIEnv* env, jobject object,
(btav_source_interface_t*)btInf->get_profile_interface(
BT_PROFILE_ADVANCED_AUDIO_ID);
if (sBluetoothA2dpInterface == nullptr) {
- ALOGE("%s: Failed to get Bluetooth A2DP Interface", __func__);
+ log::error("Failed to get Bluetooth A2DP Interface");
return;
}
@@ -296,10 +296,10 @@ static void initNative(JNIEnv* env, jobject object,
bt_status_t status = sBluetoothA2dpInterface->init(
&sBluetoothA2dpCallbacks, maxConnectedAudioDevices, codec_priorities,
- codec_offloading);
+ codec_offloading, &supported_codecs);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Failed to initialize Bluetooth A2DP, status: %d", __func__,
- status);
+ log::error("Failed to initialize Bluetooth A2DP, status: {}",
+ bt_status_text(status));
sBluetoothA2dpInterface = nullptr;
return;
}
@@ -311,7 +311,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- ALOGE("%s: Bluetooth module is not loaded", __func__);
+ log::error("Bluetooth module is not loaded");
return;
}
@@ -330,44 +330,38 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
}
static jobjectArray getSupportedCodecTypesNative(JNIEnv* env) {
- ALOGI("%s: %p", __func__, sBluetoothA2dpInterface);
+ log::info("{}", fmt::ptr(sBluetoothA2dpInterface));
jclass android_bluetooth_BluetoothCodecType_clazz = (jclass)env->NewGlobalRef(
env->FindClass("android/bluetooth/BluetoothCodecType"));
if (android_bluetooth_BluetoothCodecType_clazz == nullptr) {
- ALOGE("%s: Failed to allocate Global Ref for BluetoothCodecType class",
- __func__);
+ log::error("Failed to allocate Global Ref for BluetoothCodecType class");
return nullptr;
}
- jmethodID createFromType = env->GetStaticMethodID(
- android_bluetooth_BluetoothCodecType_clazz, "createFromType",
- "(I)Landroid/bluetooth/BluetoothCodecType;");
- if (createFromType == nullptr) {
- ALOGE(
- "%s: Failed to find method createFromType of BluetoothCodecType class",
- __func__);
+ jmethodID init = env->GetMethodID(android_bluetooth_BluetoothCodecType_clazz,
+ "", "(IJLjava/lang/String;)V");
+
+ if (init == nullptr) {
+ log::error("Failed to find method of BluetoothCodecType class");
return nullptr;
}
- std::array default_supported_codecs = {
- BTAV_A2DP_CODEC_INDEX_SOURCE_SBC, BTAV_A2DP_CODEC_INDEX_SOURCE_AAC,
- BTAV_A2DP_CODEC_INDEX_SOURCE_APTX, BTAV_A2DP_CODEC_INDEX_SOURCE_APTX_HD,
- BTAV_A2DP_CODEC_INDEX_SOURCE_LDAC, BTAV_A2DP_CODEC_INDEX_SOURCE_OPUS,
- };
jobjectArray result =
- env->NewObjectArray(default_supported_codecs.size(),
+ env->NewObjectArray(supported_codecs.size(),
android_bluetooth_BluetoothCodecType_clazz, nullptr);
+
if (result == nullptr) {
- ALOGE("%s: Failed to allocate result array of BluetoothCodecType",
- __func__);
+ log::error("Failed to allocate result array of BluetoothCodecType");
return nullptr;
}
- for (size_t index = 0; index < default_supported_codecs.size(); index++) {
- jobject codec_type = env->CallStaticObjectMethod(
- android_bluetooth_BluetoothCodecType_clazz, createFromType,
- (jint)default_supported_codecs[index]);
+ for (size_t index = 0; index < supported_codecs.size(); index++) {
+ jobject codec_type = env->NewObject(
+ android_bluetooth_BluetoothCodecType_clazz, init,
+ (jint)supported_codecs[index].codec_type,
+ (jlong)supported_codecs[index].codec_id,
+ env->NewStringUTF(supported_codecs[index].codec_name.c_str()));
env->SetObjectArrayElement(result, index, codec_type);
}
@@ -376,10 +370,10 @@ static jobjectArray getSupportedCodecTypesNative(JNIEnv* env) {
static jboolean connectA2dpNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
- ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface);
+ log::info("sBluetoothA2dpInterface: {}", fmt::ptr(sBluetoothA2dpInterface));
std::shared_lock lock(interface_mutex);
if (!sBluetoothA2dpInterface) {
- ALOGE("%s: Failed to get the Bluetooth A2DP Interface", __func__);
+ log::error("Failed to get the Bluetooth A2DP Interface");
return JNI_FALSE;
}
@@ -393,7 +387,7 @@ static jboolean connectA2dpNative(JNIEnv* env, jobject /* object */,
bd_addr.FromOctets(reinterpret_cast(addr));
bt_status_t status = sBluetoothA2dpInterface->connect(bd_addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Failed A2DP connection, status: %d", __func__, status);
+ log::error("Failed A2DP connection, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -401,10 +395,10 @@ static jboolean connectA2dpNative(JNIEnv* env, jobject /* object */,
static jboolean disconnectA2dpNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
- ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface);
+ log::info("sBluetoothA2dpInterface: {}", fmt::ptr(sBluetoothA2dpInterface));
std::shared_lock lock(interface_mutex);
if (!sBluetoothA2dpInterface) {
- ALOGE("%s: Failed to get the Bluetooth A2DP Interface", __func__);
+ log::error("Failed to get the Bluetooth A2DP Interface");
return JNI_FALSE;
}
@@ -418,7 +412,7 @@ static jboolean disconnectA2dpNative(JNIEnv* env, jobject /* object */,
bd_addr.FromOctets(reinterpret_cast(addr));
bt_status_t status = sBluetoothA2dpInterface->disconnect(bd_addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Failed A2DP disconnection, status: %d", __func__, status);
+ log::error("Failed A2DP disconnection, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -426,10 +420,10 @@ static jboolean disconnectA2dpNative(JNIEnv* env, jobject /* object */,
static jboolean setSilenceDeviceNative(JNIEnv* env, jobject /* object */,
jbyteArray address, jboolean silence) {
- ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface);
+ log::info("sBluetoothA2dpInterface: {}", fmt::ptr(sBluetoothA2dpInterface));
std::shared_lock lock(interface_mutex);
if (!sBluetoothA2dpInterface) {
- ALOGE("%s: Failed to get the Bluetooth A2DP Interface", __func__);
+ log::error("Failed to get the Bluetooth A2DP Interface");
return JNI_FALSE;
}
@@ -445,7 +439,8 @@ static jboolean setSilenceDeviceNative(JNIEnv* env, jobject /* object */,
bt_status_t status =
sBluetoothA2dpInterface->set_silence_device(bd_addr, silence);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Failed A2DP set_silence_device, status: %d", __func__, status);
+ log::error("Failed A2DP set_silence_device, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -453,10 +448,10 @@ static jboolean setSilenceDeviceNative(JNIEnv* env, jobject /* object */,
static jboolean setActiveDeviceNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
- ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface);
+ log::info("sBluetoothA2dpInterface: {}", fmt::ptr(sBluetoothA2dpInterface));
std::shared_lock lock(interface_mutex);
if (!sBluetoothA2dpInterface) {
- ALOGE("%s: Failed to get the Bluetooth A2DP Interface", __func__);
+ log::error("Failed to get the Bluetooth A2DP Interface");
return JNI_FALSE;
}
@@ -468,7 +463,8 @@ static jboolean setActiveDeviceNative(JNIEnv* env, jobject /* object */,
}
bt_status_t status = sBluetoothA2dpInterface->set_active_device(bd_addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Failed A2DP set_active_device, status: %d", __func__, status);
+ log::error("Failed A2DP set_active_device, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -477,10 +473,10 @@ static jboolean setActiveDeviceNative(JNIEnv* env, jobject /* object */,
static jboolean setCodecConfigPreferenceNative(JNIEnv* env, jobject object,
jbyteArray address,
jobjectArray codecConfigArray) {
- ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface);
+ log::info("sBluetoothA2dpInterface: {}", fmt::ptr(sBluetoothA2dpInterface));
std::shared_lock lock(interface_mutex);
if (!sBluetoothA2dpInterface) {
- ALOGE("%s: Failed to get the Bluetooth A2DP Interface", __func__);
+ log::error("Failed to get the Bluetooth A2DP Interface");
return JNI_FALSE;
}
@@ -498,7 +494,8 @@ static jboolean setCodecConfigPreferenceNative(JNIEnv* env, jobject object,
bt_status_t status =
sBluetoothA2dpInterface->config_codec(bd_addr, codec_preferences);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Failed codec configuration, status: %d", __func__, status);
+ log::error("Failed codec configuration, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
diff --git a/android/app/jni/com_android_bluetooth_a2dp_sink.cpp b/android/app/jni/com_android_bluetooth_a2dp_sink.cpp
index d2abfb6055a0c09fa3e7b6869698c2a525b43358..c4ffb2e2a437dc16b604e1661743693f1a787a29 100644
--- a/android/app/jni/com_android_bluetooth_a2dp_sink.cpp
+++ b/android/app/jni/com_android_bluetooth_a2dp_sink.cpp
@@ -37,7 +37,7 @@ static std::shared_timed_mutex callbacks_mutex;
static void a2dp_sink_connection_state_callback(
const RawAddress& bd_addr, btav_connection_state_t state,
const btav_error_t& /* error */) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(callbacks_mutex);
if (!mCallbacksObj) return;
@@ -47,7 +47,7 @@ static void a2dp_sink_connection_state_callback(
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for connection state");
+ log::error("Fail to new jbyteArray bd addr for connection state");
return;
}
@@ -59,7 +59,7 @@ static void a2dp_sink_connection_state_callback(
static void a2dp_sink_audio_state_callback(const RawAddress& bd_addr,
btav_audio_state_t state) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(callbacks_mutex);
if (!mCallbacksObj) return;
@@ -69,7 +69,7 @@ static void a2dp_sink_audio_state_callback(const RawAddress& bd_addr,
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for connection state");
+ log::error("Fail to new jbyteArray bd addr for connection state");
return;
}
@@ -82,7 +82,7 @@ static void a2dp_sink_audio_state_callback(const RawAddress& bd_addr,
static void a2dp_sink_audio_config_callback(const RawAddress& bd_addr,
uint32_t sample_rate,
uint8_t channel_count) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(callbacks_mutex);
if (!mCallbacksObj) return;
@@ -92,7 +92,7 @@ static void a2dp_sink_audio_config_callback(const RawAddress& bd_addr,
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for connection state");
+ log::error("Fail to new jbyteArray bd addr for connection state");
return;
}
@@ -116,18 +116,18 @@ static void initNative(JNIEnv* env, jobject object,
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == NULL) {
- ALOGE("Bluetooth module is not loaded");
+ log::error("Bluetooth module is not loaded");
return;
}
if (sBluetoothA2dpInterface != NULL) {
- ALOGW("Cleaning up A2DP Interface before initializing...");
+ log::warn("Cleaning up A2DP Interface before initializing...");
sBluetoothA2dpInterface->cleanup();
sBluetoothA2dpInterface = NULL;
}
if (mCallbacksObj != NULL) {
- ALOGW("Cleaning up A2DP callback object");
+ log::warn("Cleaning up A2DP callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = NULL;
}
@@ -136,14 +136,15 @@ static void initNative(JNIEnv* env, jobject object,
(btav_sink_interface_t*)btInf->get_profile_interface(
BT_PROFILE_ADVANCED_AUDIO_SINK_ID);
if (sBluetoothA2dpInterface == NULL) {
- ALOGE("Failed to get Bluetooth A2DP Sink Interface");
+ log::error("Failed to get Bluetooth A2DP Sink Interface");
return;
}
bt_status_t status = sBluetoothA2dpInterface->init(&sBluetoothA2dpCallbacks,
maxConnectedAudioDevices);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to initialize Bluetooth A2DP Sink, status: %d", status);
+ log::error("Failed to initialize Bluetooth A2DP Sink, status: {}",
+ bt_status_text(status));
sBluetoothA2dpInterface = NULL;
return;
}
@@ -156,7 +157,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == NULL) {
- ALOGE("Bluetooth module is not loaded");
+ log::error("Bluetooth module is not loaded");
return;
}
@@ -173,7 +174,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
static jboolean connectA2dpNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
- ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface);
+ log::info("sBluetoothA2dpInterface: {}", fmt::ptr(sBluetoothA2dpInterface));
if (!sBluetoothA2dpInterface) return JNI_FALSE;
jbyte* addr = env->GetByteArrayElements(address, NULL);
@@ -186,7 +187,7 @@ static jboolean connectA2dpNative(JNIEnv* env, jobject /* object */,
bd_addr.FromOctets(reinterpret_cast(addr));
bt_status_t status = sBluetoothA2dpInterface->connect(bd_addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed HF connection, status: %d", status);
+ log::error("Failed HF connection, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -206,7 +207,7 @@ static jboolean disconnectA2dpNative(JNIEnv* env, jobject /* object */,
bd_addr.FromOctets(reinterpret_cast(addr));
bt_status_t status = sBluetoothA2dpInterface->disconnect(bd_addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed HF disconnection, status: %d", status);
+ log::error("Failed HF disconnection, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -228,7 +229,7 @@ static jboolean setActiveDeviceNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
if (!sBluetoothA2dpInterface) return JNI_FALSE;
- ALOGI("%s: sBluetoothA2dpInterface: %p", __func__, sBluetoothA2dpInterface);
+ log::info("sBluetoothA2dpInterface: {}", fmt::ptr(sBluetoothA2dpInterface));
jbyte* addr = env->GetByteArrayElements(address, NULL);
if (!addr) {
@@ -240,7 +241,8 @@ static jboolean setActiveDeviceNative(JNIEnv* env, jobject /* object */,
rawAddress.FromOctets((uint8_t*)addr);
bt_status_t status = sBluetoothA2dpInterface->set_active_device(rawAddress);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending passthru command, status: %d", status);
+ log::error("Failed sending passthru command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
diff --git a/android/app/jni/com_android_bluetooth_avrcp_controller.cpp b/android/app/jni/com_android_bluetooth_avrcp_controller.cpp
index 6382f460937bfc2b9a6cbcd8699cfe2c2f805d02..13c26c15ce91d9aaf7a08ab981ac7b89fa1e6b07 100644
--- a/android/app/jni/com_android_bluetooth_avrcp_controller.cpp
+++ b/android/app/jni/com_android_bluetooth_avrcp_controller.cpp
@@ -55,28 +55,28 @@ static std::shared_timed_mutex sCallbacks_mutex;
static void btavrcp_passthrough_response_callback(
const RawAddress& /* bd_addr */, int id, int pressed) {
- ALOGV("%s: id: %d, pressed: %d --- Not implemented", __func__, id, pressed);
+ log::verbose("id: {}, pressed: {} --- Not implemented", id, pressed);
}
static void btavrcp_groupnavigation_response_callback(int id, int pressed) {
- ALOGV("%s: id: %d, pressed: %d --- Not implemented", __func__, id, pressed);
+ log::verbose("id: {}, pressed: {} --- Not implemented", id, pressed);
}
static void btavrcp_connection_state_callback(bool rc_connect, bool br_connect,
const RawAddress& bd_addr) {
- ALOGI("%s: conn state: rc: %d br: %d", __func__, rc_connect, br_connect);
+ log::info("conn state: rc: {} br: {}", rc_connect, br_connect);
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -89,30 +89,30 @@ static void btavrcp_connection_state_callback(bool rc_connect, bool br_connect,
static void btavrcp_get_rcfeatures_callback(const RawAddress& /* bd_addr */,
int /* features */) {
- ALOGV("%s --- Not implemented", __func__);
+ log::verbose("--- Not implemented");
}
static void btavrcp_setplayerapplicationsetting_rsp_callback(
const RawAddress& /* bd_addr */, uint8_t /* accepted */) {
- ALOGV("%s --- Not implemented", __func__);
+ log::verbose("--- Not implemented");
}
static void btavrcp_playerapplicationsetting_callback(
const RawAddress& bd_addr, uint8_t num_attr,
btrc_player_app_attr_t* app_attrs, uint8_t /* num_ext_attr */,
btrc_player_app_ext_attr_t* /* ext_attrs */) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -125,12 +125,12 @@ static void btavrcp_playerapplicationsetting_callback(
/*2 bytes for id and num */
arraylen += 2 + app_attrs[i].num_val;
}
- ALOGV(" arraylen %d", arraylen);
+ log::verbose(" arraylen {}", arraylen);
ScopedLocalRef playerattribs(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(arraylen));
if (!playerattribs.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -152,19 +152,19 @@ static void btavrcp_playerapplicationsetting_callback(
static void btavrcp_playerapplicationsetting_changed_callback(
const RawAddress& bd_addr, const btrc_player_settings_t& vals) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -174,7 +174,7 @@ static void btavrcp_playerapplicationsetting_changed_callback(
ScopedLocalRef playerattribs(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(arraylen));
if (!playerattribs.get()) {
- ALOGE("Fail to new jbyteArray playerattribs ");
+ log::error("Fail to new jbyteArray playerattribs ");
return;
}
/*
@@ -195,19 +195,19 @@ static void btavrcp_playerapplicationsetting_changed_callback(
static void btavrcp_set_abs_vol_cmd_callback(const RawAddress& bd_addr,
uint8_t abs_vol, uint8_t label) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -219,19 +219,19 @@ static void btavrcp_set_abs_vol_cmd_callback(const RawAddress& bd_addr,
static void btavrcp_register_notification_absvol_callback(
const RawAddress& bd_addr, uint8_t label) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -249,26 +249,26 @@ static void btavrcp_track_changed_callback(const RawAddress& bd_addr,
* byteArray will be formatted like this: id,len,string
* Assuming text feild to be null terminated.
*/
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
ScopedLocalRef attribIds(sCallbackEnv.get(),
sCallbackEnv->NewIntArray(num_attr));
if (!attribIds.get()) {
- ALOGE(" failed to set new array for attribIds");
+ log::error(" failed to set new array for attribIds");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -279,7 +279,7 @@ static void btavrcp_track_changed_callback(const RawAddress& bd_addr,
sCallbackEnv.get(),
sCallbackEnv->NewObjectArray((jint)num_attr, strclazz, 0));
if (!stringArray.get()) {
- ALOGE(" failed to get String array");
+ log::error(" failed to get String array");
return;
}
@@ -288,7 +288,7 @@ static void btavrcp_track_changed_callback(const RawAddress& bd_addr,
sCallbackEnv.get(),
sCallbackEnv->NewStringUTF((char*)(p_attrs[i].text)));
if (!str.get()) {
- ALOGE("Unable to get str");
+ log::error("Unable to get str");
return;
}
sCallbackEnv->SetIntArrayRegion(attribIds.get(), i, 1,
@@ -304,19 +304,19 @@ static void btavrcp_track_changed_callback(const RawAddress& bd_addr,
static void btavrcp_play_position_changed_callback(const RawAddress& bd_addr,
uint32_t song_len,
uint32_t song_pos) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -327,19 +327,19 @@ static void btavrcp_play_position_changed_callback(const RawAddress& bd_addr,
static void btavrcp_play_status_changed_callback(
const RawAddress& bd_addr, btrc_play_status_t play_status) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -355,19 +355,19 @@ static void btavrcp_get_folder_items_callback(
* BTRC_ITEM_MEDIA, BTRC_ITEM_FOLDER. Here we translate them to their java
* counterparts by calling the java constructor for each of the items.
*/
- ALOGV("%s count %d", __func__, count);
+ log::verbose("count {}", count);
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -389,12 +389,12 @@ static void btavrcp_get_folder_items_callback(
(jint)count, class_AvrcpItem, 0));
}
if (!itemArray.get()) {
- ALOGE("%s itemArray allocation failed.", __func__);
+ log::error("itemArray allocation failed.");
return;
}
for (int i = 0; i < count; i++) {
const btrc_folder_items_t* item = &(folder_items[i]);
- ALOGV("%s item type %d", __func__, item->item_type);
+ log::verbose("item type {}", item->item_type);
switch (item->item_type) {
case BTRC_ITEM_MEDIA: {
// Parse name
@@ -402,7 +402,7 @@ static void btavrcp_get_folder_items_callback(
sCallbackEnv.get(),
sCallbackEnv->NewStringUTF((const char*)item->media.name));
if (!mediaName.get()) {
- ALOGE("%s can't allocate media name string!", __func__);
+ log::error("can't allocate media name string!");
return;
}
// Parse UID
@@ -412,7 +412,7 @@ static void btavrcp_get_folder_items_callback(
sCallbackEnv.get(),
sCallbackEnv->NewIntArray(item->media.num_attrs));
if (!attrIdArray.get()) {
- ALOGE("%s can't allocate attr id array!", __func__);
+ log::error("can't allocate attr id array!");
return;
}
ScopedLocalRef attrValArray(
@@ -421,7 +421,7 @@ static void btavrcp_get_folder_items_callback(
item->media.num_attrs,
sCallbackEnv->FindClass("java/lang/String"), 0));
if (!attrValArray.get()) {
- ALOGE("%s can't allocate attr val array!", __func__);
+ log::error("can't allocate attr val array!");
return;
}
@@ -444,7 +444,7 @@ static void btavrcp_get_folder_items_callback(
(jint)item->media.type, mediaName.get(), attrIdArray.get(),
attrValArray.get()));
if (!mediaObj.get()) {
- ALOGE("%s failed to create AvrcpItem for type ITEM_MEDIA", __func__);
+ log::error("failed to create AvrcpItem for type ITEM_MEDIA");
return;
}
sCallbackEnv->SetObjectArrayElement(itemArray.get(), i, mediaObj.get());
@@ -457,7 +457,7 @@ static void btavrcp_get_folder_items_callback(
sCallbackEnv.get(),
sCallbackEnv->NewStringUTF((const char*)item->folder.name));
if (!folderName.get()) {
- ALOGE("%s can't allocate folder name string!", __func__);
+ log::error("can't allocate folder name string!");
return;
}
// Parse UID
@@ -470,7 +470,7 @@ static void btavrcp_get_folder_items_callback(
(jint)item->folder.type, folderName.get(),
(jint)item->folder.playable));
if (!folderObj.get()) {
- ALOGE("%s failed to create AvrcpItem for type ITEM_FOLDER", __func__);
+ log::error("failed to create AvrcpItem for type ITEM_FOLDER");
return;
}
sCallbackEnv->SetObjectArrayElement(itemArray.get(), i,
@@ -489,7 +489,7 @@ static void btavrcp_get_folder_items_callback(
sCallbackEnv->NewByteArray(BTRC_FEATURE_BIT_MASK_SIZE *
sizeof(uint8_t)));
if (!featureBitArray.get()) {
- ALOGE("%s failed to allocate featureBitArray", __func__);
+ log::error("failed to allocate featureBitArray");
return;
}
sCallbackEnv->SetByteArrayRegion(
@@ -500,7 +500,7 @@ static void btavrcp_get_folder_items_callback(
sCallbackEnv.get(),
sCallbackEnv->NewStringUTF((const char*)item->player.name));
if (!playerName.get()) {
- ALOGE("%s can't allocate player name string!", __func__);
+ log::error("can't allocate player name string!");
return;
}
ScopedLocalRef playerObj(
@@ -511,7 +511,7 @@ static void btavrcp_get_folder_items_callback(
playerName.get(), featureBitArray.get(), playStatus,
playerType));
if (!playerObj.get()) {
- ALOGE("%s failed to create AvrcpPlayer from ITEM_PLAYER", __func__);
+ log::error("failed to create AvrcpPlayer from ITEM_PLAYER");
return;
}
sCallbackEnv->SetObjectArrayElement(itemArray.get(), i,
@@ -520,7 +520,7 @@ static void btavrcp_get_folder_items_callback(
}
default:
- ALOGE("%s cannot understand type %d", __func__, item->item_type);
+ log::error("cannot understand type {}", item->item_type);
}
}
@@ -535,18 +535,18 @@ static void btavrcp_get_folder_items_callback(
static void btavrcp_change_path_callback(const RawAddress& bd_addr,
uint32_t count) {
- ALOGI("%s count %d", __func__, count);
+ log::info("count {}", count);
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -560,18 +560,18 @@ static void btavrcp_change_path_callback(const RawAddress& bd_addr,
static void btavrcp_set_browsed_player_callback(const RawAddress& bd_addr,
uint8_t num_items,
uint8_t depth) {
- ALOGI("%s items %d depth %d", __func__, num_items, depth);
+ log::info("items {} depth {}", num_items, depth);
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -584,18 +584,18 @@ static void btavrcp_set_browsed_player_callback(const RawAddress& bd_addr,
static void btavrcp_set_addressed_player_callback(const RawAddress& bd_addr,
uint8_t status) {
- ALOGI("%s status %d", __func__, status);
+ log::info("status {}", status);
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -609,18 +609,18 @@ static void btavrcp_set_addressed_player_callback(const RawAddress& bd_addr,
static void btavrcp_addressed_player_changed_callback(const RawAddress& bd_addr,
uint16_t id) {
- ALOGI("%s status %d", __func__, id);
+ log::info("status {}", id);
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -633,14 +633,14 @@ static void btavrcp_addressed_player_changed_callback(const RawAddress& bd_addr,
static void btavrcp_now_playing_content_changed_callback(
const RawAddress& bd_addr) {
- ALOGI("%s", __func__);
+ log::info("");
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -653,19 +653,19 @@ static void btavrcp_now_playing_content_changed_callback(
static void btavrcp_available_player_changed_callback (
const RawAddress& bd_addr) {
- ALOGI("%s", __func__);
+ log::info("");
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
- return;
+ log::error("sCallbacksObj is null");
+ return;
}
if (!sCallbackEnv.valid()) return;
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -677,11 +677,11 @@ static void btavrcp_available_player_changed_callback (
static void btavrcp_get_rcpsm_callback(const RawAddress& bd_addr,
uint16_t psm) {
- ALOGE("%s -> psm received of %d", __func__, psm);
+ log::error("-> psm received of {}", psm);
std::shared_lock lock(sCallbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbacksObj) {
- ALOGE("%s: sCallbacksObj is null", __func__);
+ log::error("sCallbacksObj is null");
return;
}
if (!sCallbackEnv.valid()) return;
@@ -689,7 +689,7 @@ static void btavrcp_get_rcpsm_callback(const RawAddress& bd_addr,
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("%s: Failed to allocate a new byte array", __func__);
+ log::error("Failed to allocate a new byte array");
return;
}
@@ -741,18 +741,18 @@ static void initNative(JNIEnv* env, jobject object) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == NULL) {
- ALOGE("Bluetooth module is not loaded");
+ log::error("Bluetooth module is not loaded");
return;
}
if (sBluetoothAvrcpInterface != NULL) {
- ALOGW("Cleaning up Avrcp Interface before initializing...");
+ log::warn("Cleaning up Avrcp Interface before initializing...");
sBluetoothAvrcpInterface->cleanup();
sBluetoothAvrcpInterface = NULL;
}
if (sCallbacksObj != NULL) {
- ALOGW("Cleaning up Avrcp callback object");
+ log::warn("Cleaning up Avrcp callback object");
env->DeleteGlobalRef(sCallbacksObj);
sCallbacksObj = NULL;
}
@@ -761,15 +761,15 @@ static void initNative(JNIEnv* env, jobject object) {
(btrc_ctrl_interface_t*)btInf->get_profile_interface(
BT_PROFILE_AV_RC_CTRL_ID);
if (sBluetoothAvrcpInterface == NULL) {
- ALOGE("Failed to get Bluetooth Avrcp Controller Interface");
+ log::error("Failed to get Bluetooth Avrcp Controller Interface");
return;
}
bt_status_t status =
sBluetoothAvrcpInterface->init(&sBluetoothAvrcpCallbacks);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to initialize Bluetooth Avrcp Controller, status: %d",
- status);
+ log::error("Failed to initialize Bluetooth Avrcp Controller, status: {}",
+ bt_status_text(status));
sBluetoothAvrcpInterface = NULL;
return;
}
@@ -782,7 +782,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == NULL) {
- ALOGE("Bluetooth module is not loaded");
+ log::error("Bluetooth module is not loaded");
return;
}
@@ -802,9 +802,9 @@ static jboolean sendPassThroughCommandNative(JNIEnv* env, jobject /* object */,
jint key_state) {
if (!sBluetoothAvrcpInterface) return JNI_FALSE;
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
- ALOGI("key_code: %d, key_state: %d", key_code, key_state);
+ log::info("key_code: {}, key_state: {}", key_code, key_state);
jbyte* addr = env->GetByteArrayElements(address, NULL);
if (!addr) {
@@ -817,7 +817,8 @@ static jboolean sendPassThroughCommandNative(JNIEnv* env, jobject /* object */,
bt_status_t status = sBluetoothAvrcpInterface->send_pass_through_cmd(
rawAddress, (uint8_t)key_code, (uint8_t)key_state);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending passthru command, status: %d", status);
+ log::error("Failed sending passthru command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
@@ -831,9 +832,9 @@ static jboolean sendGroupNavigationCommandNative(JNIEnv* env,
jint key_state) {
if (!sBluetoothAvrcpInterface) return JNI_FALSE;
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
- ALOGI("key_code: %d, key_state: %d", key_code, key_state);
+ log::info("key_code: {}, key_state: {}", key_code, key_state);
jbyte* addr = env->GetByteArrayElements(address, NULL);
if (!addr) {
@@ -846,7 +847,8 @@ static jboolean sendGroupNavigationCommandNative(JNIEnv* env,
bt_status_t status = sBluetoothAvrcpInterface->send_group_navigation_cmd(
rawAddress, (uint8_t)key_code, (uint8_t)key_state);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending Grp Navigation command, status: %d", status);
+ log::error("Failed sending Grp Navigation command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
@@ -856,7 +858,7 @@ static jboolean sendGroupNavigationCommandNative(JNIEnv* env,
static void setPlayerApplicationSettingValuesNative(
JNIEnv* env, jobject /* object */, jbyteArray address, jbyte num_attrib,
jbyteArray attrib_ids, jbyteArray attrib_val) {
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
if (!sBluetoothAvrcpInterface) return;
jbyte* addr = env->GetByteArrayElements(address, NULL);
@@ -869,7 +871,8 @@ static void setPlayerApplicationSettingValuesNative(
uint8_t* pAttrsVal = new uint8_t[num_attrib];
if ((!pAttrs) || (!pAttrsVal)) {
delete[] pAttrs;
- ALOGE("setPlayerApplicationSettingValuesNative: not have enough memeory");
+ log::error(
+ "setPlayerApplicationSettingValuesNative: not have enough memory");
return;
}
@@ -893,7 +896,8 @@ static void setPlayerApplicationSettingValuesNative(
bt_status_t status = sBluetoothAvrcpInterface->set_player_app_setting_cmd(
rawAddress, (uint8_t)num_attrib, pAttrs, pAttrsVal);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending setPlAppSettValNative command, status: %d", status);
+ log::error("Failed sending setPlAppSettValNative command, status: {}",
+ bt_status_text(status));
}
delete[] pAttrs;
delete[] pAttrsVal;
@@ -912,14 +916,15 @@ static void sendAbsVolRspNative(JNIEnv* env, jobject /* object */,
return;
}
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
bt_status_t status = sBluetoothAvrcpInterface->set_volume_rsp(
rawAddress, (uint8_t)abs_vol, (uint8_t)label);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending sendAbsVolRspNative command, status: %d", status);
+ log::error("Failed sending sendAbsVolRspNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -934,7 +939,7 @@ static void sendRegisterAbsVolRspNative(JNIEnv* env, jobject /* object */,
jniThrowIOException(env, EINVAL);
return;
}
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
@@ -942,8 +947,8 @@ static void sendRegisterAbsVolRspNative(JNIEnv* env, jobject /* object */,
rawAddress, (btrc_notification_type_t)rsp_type, (uint8_t)abs_vol,
(uint8_t)label);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending sendRegisterAbsVolRspNative command, status: %d",
- status);
+ log::error("Failed sending sendRegisterAbsVolRspNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -957,14 +962,16 @@ static void getCurrentMetadataNative(JNIEnv* env, jobject /* object */,
jniThrowIOException(env, EINVAL);
return;
}
- ALOGV("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::verbose("sBluetoothAvrcpInterface: {}",
+ fmt::ptr(sBluetoothAvrcpInterface));
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
bt_status_t status =
sBluetoothAvrcpInterface->get_current_metadata_cmd(rawAddress);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending getCurrentMetadataNative command, status: %d", status);
+ log::error("Failed sending getCurrentMetadataNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -978,14 +985,16 @@ static void getPlaybackStateNative(JNIEnv* env, jobject /* object */,
jniThrowIOException(env, EINVAL);
return;
}
- ALOGV("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::verbose("sBluetoothAvrcpInterface: {}",
+ fmt::ptr(sBluetoothAvrcpInterface));
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
bt_status_t status =
sBluetoothAvrcpInterface->get_playback_state_cmd(rawAddress);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending getPlaybackStateNative command, status: %d", status);
+ log::error("Failed sending getPlaybackStateNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -998,14 +1007,16 @@ static void getNowPlayingListNative(JNIEnv* env, jobject /* object */,
jniThrowIOException(env, EINVAL);
return;
}
- ALOGV("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::verbose("sBluetoothAvrcpInterface: {}",
+ fmt::ptr(sBluetoothAvrcpInterface));
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
bt_status_t status = sBluetoothAvrcpInterface->get_now_playing_list_cmd(
rawAddress, start, end);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending getNowPlayingListNative command, status: %d", status);
+ log::error("Failed sending getNowPlayingListNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -1018,14 +1029,16 @@ static void getFolderListNative(JNIEnv* env, jobject /* object */,
jniThrowIOException(env, EINVAL);
return;
}
- ALOGV("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::verbose("sBluetoothAvrcpInterface: {}",
+ fmt::ptr(sBluetoothAvrcpInterface));
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
bt_status_t status =
sBluetoothAvrcpInterface->get_folder_list_cmd(rawAddress, start, end);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending getFolderListNative command, status: %d", status);
+ log::error("Failed sending getFolderListNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -1038,14 +1051,15 @@ static void getPlayerListNative(JNIEnv* env, jobject /* object */,
jniThrowIOException(env, EINVAL);
return;
}
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
bt_status_t status =
sBluetoothAvrcpInterface->get_player_list_cmd(rawAddress, start, end);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending getPlayerListNative command, status: %d", status);
+ log::error("Failed sending getPlayerListNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -1066,14 +1080,15 @@ static void changeFolderPathNative(JNIEnv* env, jobject /* object */,
// return;
//}
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
bt_status_t status = sBluetoothAvrcpInterface->change_folder_path_cmd(
rawAddress, (uint8_t)direction, (uint8_t*)&uid);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending changeFolderPathNative command, status: %d", status);
+ log::error("Failed sending changeFolderPathNative command, status: {}",
+ bt_status_text(status));
}
// env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -1089,11 +1104,12 @@ static void setBrowsedPlayerNative(JNIEnv* env, jobject /* object */,
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
bt_status_t status = sBluetoothAvrcpInterface->set_browsed_player_cmd(
rawAddress, (uint16_t)id);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending setBrowsedPlayerNative command, status: %d", status);
+ log::error("Failed sending setBrowsedPlayerNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -1109,12 +1125,12 @@ static void setAddressedPlayerNative(JNIEnv* env, jobject /* object */,
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
bt_status_t status = sBluetoothAvrcpInterface->set_addressed_player_cmd(
rawAddress, (uint16_t)id);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending setAddressedPlayerNative command, status: %d",
- status);
+ log::error("Failed sending setAddressedPlayerNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
@@ -1137,11 +1153,12 @@ static void playItemNative(JNIEnv* env, jobject /* object */,
RawAddress rawAddress;
rawAddress.FromOctets((uint8_t*)addr);
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __func__, sBluetoothAvrcpInterface);
+ log::info("sBluetoothAvrcpInterface: {}", fmt::ptr(sBluetoothAvrcpInterface));
bt_status_t status = sBluetoothAvrcpInterface->play_item_cmd(
rawAddress, (uint8_t)scope, (uint8_t*)&uid, (uint16_t)uidCounter);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending playItemNative command, status: %d", status);
+ log::error("Failed sending playItemNative command, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
}
diff --git a/android/app/jni/com_android_bluetooth_avrcp_target.cpp b/android/app/jni/com_android_bluetooth_avrcp_target.cpp
index a5e4949de33a5aaaa1750307fa01833c0d0f1ae3..1e9678cdffe8e53c59699d9e02f739be8c2b10fe 100644
--- a/android/app/jni/com_android_bluetooth_avrcp_target.cpp
+++ b/android/app/jni/com_android_bluetooth_avrcp_target.cpp
@@ -233,7 +233,7 @@ static jmethodID method_getPlayerSettings;
static jmethodID method_setPlayerSettings;
static void initNative(JNIEnv* env, jobject object) {
- ALOGD("%s", __func__);
+ log::debug("");
std::unique_lock interface_lock(interface_mutex);
std::unique_lock callbacks_lock(callbacks_mutex);
mJavaInterface = env->NewGlobalRef(object);
@@ -245,20 +245,20 @@ static void initNative(JNIEnv* env, jobject object) {
static void registerBipServerNative(JNIEnv* /* env */, jobject /* object */,
jint l2cap_psm) {
- ALOGD("%s: l2cap_psm=%d", __func__, (int)l2cap_psm);
+ log::debug("l2cap_psm={}", (int)l2cap_psm);
std::unique_lock interface_lock(interface_mutex);
if (sServiceInterface == nullptr) {
- ALOGW("%s: Service not loaded.", __func__);
+ log::warn("Service not loaded.");
return;
}
sServiceInterface->RegisterBipServer((int)l2cap_psm);
}
static void unregisterBipServerNative(JNIEnv* /* env */, jobject /* object */) {
- ALOGD("%s", __func__);
+ log::debug("");
std::unique_lock interface_lock(interface_mutex);
if (sServiceInterface == nullptr) {
- ALOGW("%s: Service not loaded.", __func__);
+ log::warn("Service not loaded.");
return;
}
sServiceInterface->UnregisterBipServer();
@@ -267,10 +267,10 @@ static void unregisterBipServerNative(JNIEnv* /* env */, jobject /* object */) {
static void sendMediaUpdateNative(JNIEnv* /* env */, jobject /* object */,
jboolean metadata, jboolean state,
jboolean queue) {
- ALOGD("%s", __func__);
+ log::debug("");
std::unique_lock interface_lock(interface_mutex);
if (mServiceCallbacks == nullptr) {
- ALOGW("%s: Service not loaded.", __func__);
+ log::warn("Service not loaded.");
return;
}
@@ -281,10 +281,10 @@ static void sendMediaUpdateNative(JNIEnv* /* env */, jobject /* object */,
static void sendFolderUpdateNative(JNIEnv* /* env */, jobject /* object */,
jboolean available_players,
jboolean addressed_player, jboolean uids) {
- ALOGD("%s", __func__);
+ log::debug("");
std::unique_lock interface_lock(interface_mutex);
if (mServiceCallbacks == nullptr) {
- ALOGW("%s: Service not loaded.", __func__);
+ log::warn("Service not loaded.");
return;
}
@@ -309,10 +309,10 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
jboolean connectDeviceNative(JNIEnv* env, jobject /* object */,
jstring address) {
- ALOGD("%s", __func__);
+ log::debug("");
std::unique_lock interface_lock(interface_mutex);
if (mServiceCallbacks == nullptr) {
- ALOGW("%s: Service not loaded.", __func__);
+ log::warn("Service not loaded.");
return JNI_FALSE;
}
@@ -329,10 +329,10 @@ jboolean connectDeviceNative(JNIEnv* env, jobject /* object */,
jboolean disconnectDeviceNative(JNIEnv* env, jobject /* object */,
jstring address) {
- ALOGD("%s", __func__);
+ log::debug("");
std::unique_lock interface_lock(interface_mutex);
if (mServiceCallbacks == nullptr) {
- ALOGW("%s: Service not loaded.", __func__);
+ log::warn("Service not loaded.");
return JNI_FALSE;
}
@@ -348,7 +348,7 @@ jboolean disconnectDeviceNative(JNIEnv* env, jobject /* object */,
}
static void sendMediaKeyEvent(int key, KeyState state) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -519,7 +519,7 @@ static FolderInfo getFolderInfoFromJavaObj(JNIEnv* env, jobject folder) {
}
static SongInfo getSongInfo() {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return SongInfo();
@@ -532,7 +532,7 @@ static SongInfo getSongInfo() {
}
static PlayStatus getCurrentPlayStatus() {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return PlayStatus();
@@ -542,7 +542,7 @@ static PlayStatus getCurrentPlayStatus() {
sCallbackEnv->CallObjectMethod(mJavaInterface, method_getPlaybackStatus);
if (playStatus == nullptr) {
- ALOGE("%s: Got a null play status", __func__);
+ log::error("Got a null play status");
return status;
}
@@ -564,7 +564,7 @@ static PlayStatus getCurrentPlayStatus() {
}
static std::string getCurrentMediaId() {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return "";
@@ -572,7 +572,7 @@ static std::string getCurrentMediaId() {
jstring media_id = (jstring)sCallbackEnv->CallObjectMethod(
mJavaInterface, method_getCurrentMediaId);
if (media_id == nullptr) {
- ALOGE("%s: Got a null media ID", __func__);
+ log::error("Got a null media ID");
return "";
}
@@ -584,7 +584,7 @@ static std::string getCurrentMediaId() {
}
static std::vector getNowPlayingList() {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return std::vector();
@@ -592,7 +592,7 @@ static std::vector getNowPlayingList() {
jobject song_list =
sCallbackEnv->CallObjectMethod(mJavaInterface, method_getNowPlayingList);
if (song_list == nullptr) {
- ALOGE("%s: Got a null now playing list", __func__);
+ log::error("Got a null now playing list");
return std::vector();
}
@@ -619,7 +619,7 @@ static std::vector getNowPlayingList() {
}
static uint16_t getCurrentPlayerId() {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return 0u;
@@ -631,7 +631,7 @@ static uint16_t getCurrentPlayerId() {
}
static std::vector getMediaPlayerList() {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface)
@@ -641,7 +641,7 @@ static std::vector getMediaPlayerList() {
mJavaInterface, method_getMediaPlayerList);
if (player_list == nullptr) {
- ALOGE("%s: Got a null media player list", __func__);
+ log::error("Got a null media player list");
return std::vector();
}
@@ -697,7 +697,7 @@ static std::vector getMediaPlayerList() {
}
static void setBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCb cb) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -711,7 +711,7 @@ static void setBrowsedPlayerResponseNative(JNIEnv* env, jobject /* object */,
jint /* player_id */,
jboolean success, jstring root_id,
jint num_items) {
- ALOGD("%s", __func__);
+ log::debug("");
std::string root;
if (root_id != nullptr) {
@@ -725,7 +725,7 @@ static void setBrowsedPlayerResponseNative(JNIEnv* env, jobject /* object */,
static void getFolderItemsResponseNative(JNIEnv* env, jobject /* object */,
jstring parent_id, jobject list) {
- ALOGD("%s", __func__);
+ log::debug("");
std::string id;
if (parent_id != nullptr) {
@@ -739,8 +739,8 @@ static void getFolderItemsResponseNative(JNIEnv* env, jobject /* object */,
// that both callbacks can be handled with one lookup if a request comes
// for a folder that is already trying to be looked at.
if (get_folder_items_cb_map.find(id) == get_folder_items_cb_map.end()) {
- ALOGE("Could not find response callback for the request of \"%s\"",
- id.c_str());
+ log::error("Could not find response callback for the request of \"{}\"",
+ id);
return;
}
@@ -748,7 +748,7 @@ static void getFolderItemsResponseNative(JNIEnv* env, jobject /* object */,
get_folder_items_cb_map.erase(id);
if (list == nullptr) {
- ALOGE("%s: Got a null get folder items response list", __func__);
+ log::error("Got a null get folder items response list");
callback.Run(std::vector());
return;
}
@@ -802,7 +802,7 @@ static void getFolderItemsResponseNative(JNIEnv* env, jobject /* object */,
static void getFolderItems(uint16_t player_id, std::string media_id,
GetFolderItemsCb cb) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -818,7 +818,7 @@ static void getFolderItems(uint16_t player_id, std::string media_id,
static void playItem(uint16_t player_id, bool now_playing,
std::string media_id) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -829,7 +829,7 @@ static void playItem(uint16_t player_id, bool now_playing,
}
static void setActiveDevice(const RawAddress& address) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -840,7 +840,7 @@ static void setActiveDevice(const RawAddress& address) {
}
static void volumeDeviceConnected(const RawAddress& address) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -853,7 +853,7 @@ static void volumeDeviceConnected(const RawAddress& address) {
static void volumeDeviceConnected(
const RawAddress& address,
::bluetooth::avrcp::VolumeInterface::VolumeChangedCb cb) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -866,7 +866,7 @@ static void volumeDeviceConnected(
}
static void volumeDeviceDisconnected(const RawAddress& address) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -887,14 +887,14 @@ static void sendVolumeChangedNative(JNIEnv* env, jobject /* object */,
if (!success) return;
- ALOGD("%s", __func__);
+ log::debug("");
if (volumeCallbackMap.find(bdaddr) != volumeCallbackMap.end()) {
volumeCallbackMap.find(bdaddr)->second.Run(volume & 0x7F);
}
}
static void setVolume(int8_t volume) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -906,7 +906,7 @@ static void setBipClientStatusNative(JNIEnv* env, jobject /* object */,
jstring address, jboolean connected) {
std::unique_lock interface_lock(interface_mutex);
if (mServiceCallbacks == nullptr) {
- ALOGW("%s: Service not loaded.", __func__);
+ log::warn("Service not loaded.");
return;
}
@@ -923,7 +923,7 @@ static void setBipClientStatusNative(JNIEnv* env, jobject /* object */,
// Called from native to list available player settings
static void listPlayerSettings(ListPlayerSettingsCb cb) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -934,7 +934,7 @@ static void listPlayerSettings(ListPlayerSettingsCb cb) {
static void listPlayerSettingsResponseNative(JNIEnv* env, jobject /* object */,
jbyteArray attributes) {
- ALOGD("%s", __func__);
+ log::debug("");
std::vector attributes_vector;
copyJavaArraytoCppVector(env, attributes, attributes_vector);
@@ -945,7 +945,7 @@ static void listPlayerSettingsResponseNative(JNIEnv* env, jobject /* object */,
// Called from native to list available values for player setting
static void listPlayerSettingValues(PlayerAttribute attribute,
ListPlayerSettingValuesCb cb) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -959,7 +959,7 @@ static void listPlayerSettingValuesResponseNative(JNIEnv* env,
jobject /* object */,
jbyte attribute,
jbyteArray values) {
- ALOGD("%s", __func__);
+ log::debug("");
PlayerAttribute player_attribute = static_cast(attribute);
std::vector values_vector;
copyJavaArraytoCppVector(env, values, values_vector);
@@ -969,7 +969,7 @@ static void listPlayerSettingValuesResponseNative(JNIEnv* env,
// Called from native to get current player settings
static void getPlayerSettings(std::vector attributes,
GetCurrentPlayerSettingValueCb cb) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -987,7 +987,7 @@ static void getPlayerSettings(std::vector attributes,
static void getPlayerSettingsResponseNative(JNIEnv* env, jobject /* object */,
jbyteArray attributes,
jbyteArray values) {
- ALOGD("%s", __func__);
+ log::debug("");
std::vector attributes_vector;
std::vector values_vector;
copyJavaArraytoCppVector(env, attributes, attributes_vector);
@@ -1000,7 +1000,7 @@ static void getPlayerSettingsResponseNative(JNIEnv* env, jobject /* object */,
static void setPlayerSettings(std::vector attributes,
std::vector values,
SetPlayerSettingValueCb cb) {
- ALOGD("%s", __func__);
+ log::debug("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid() || !mJavaInterface) return;
@@ -1024,16 +1024,16 @@ static void setPlayerSettings(std::vector attributes,
static void setPlayerSettingsResponseNative(JNIEnv* /* env */,
jobject /* object */,
jboolean success) {
- ALOGD("%s", __func__);
+ log::debug("");
set_player_setting_value_cb.Run(success);
}
static void sendPlayerSettingsNative(JNIEnv* env, jobject /* object */,
jbyteArray attributes, jbyteArray values) {
- ALOGD("%s", __func__);
+ log::debug("");
std::unique_lock interface_lock(interface_mutex);
if (mServiceCallbacks == nullptr) {
- ALOGW("%s: Service not loaded.", __func__);
+ log::warn("Service not loaded.");
return;
}
std::vector attributes_vector;
diff --git a/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp b/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp
index e3b197afc2bb2552b4ab348da5fc9959290a86de..6b10df82a7e0dcd74b8aa37a92510bacad1ca6cc 100644
--- a/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp
+++ b/android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp
@@ -16,6 +16,7 @@
*/
#define LOG_TAG "BluetoothServiceJni"
+
#include
#include
#include
@@ -30,7 +31,7 @@
#include "com_android_bluetooth.h"
#include "hardware/bt_sock.h"
-#include "os/logging/log_redaction.h"
+#include "os/logging/log_adapter.h"
#include "utils/Log.h"
#include "utils/misc.h"
@@ -39,6 +40,14 @@ using bluetooth::Uuid;
extern bt_interface_t bluetoothInterface;
#endif
+namespace fmt {
+template <>
+struct formatter : enum_formatter {};
+template <>
+struct formatter : enum_formatter {
+};
+} // namespace fmt
+
namespace android {
// Both
@@ -69,6 +78,7 @@ static jmethodID method_switchCodecCallback;
static jmethodID method_acquireWakeLock;
static jmethodID method_releaseWakeLock;
static jmethodID method_energyInfo;
+static jmethodID method_keyMissingCallback;
static struct {
jclass clazz;
@@ -98,13 +108,13 @@ bool isCallbackThread() {
static void adapter_state_change_callback(bt_state_t status) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
- ALOGV("%s: Status is: %d", __func__, status);
+ log::verbose("Status is: {}", status);
sCallbackEnv->CallVoidMethod(sJniCallbacksObj, method_stateChangeCallback,
(jint)status);
@@ -116,7 +126,7 @@ static int get_properties(int num_properties, bt_property_t* properties,
ScopedLocalRef propVal(
callbackEnv, callbackEnv->NewByteArray(properties[i].len));
if (!propVal.get()) {
- ALOGE("Error while allocation of array in %s", __func__);
+ log::error("Error while allocation of array");
return -1;
}
@@ -132,17 +142,18 @@ static void adapter_properties_callback(bt_status_t status, int num_properties,
bt_property_t* properties) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
- ALOGV("%s: Status is: %d, Properties: %d", __func__, status, num_properties);
+ log::verbose("Status is: {}, Properties: {}", bt_status_text(status),
+ num_properties);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Status %d is incorrect", __func__, status);
+ log::error("Status {} is incorrect", bt_status_text(status));
return;
}
@@ -150,7 +161,7 @@ static void adapter_properties_callback(bt_status_t status, int num_properties,
sCallbackEnv.get(),
(jbyteArray)sCallbackEnv->NewByteArray(num_properties));
if (!val.get()) {
- ALOGE("%s: Error allocating byteArray", __func__);
+ log::error("Error allocating byteArray");
return;
}
@@ -164,14 +175,14 @@ static void adapter_properties_callback(bt_status_t status, int num_properties,
sCallbackEnv.get(),
sCallbackEnv->NewObjectArray(num_properties, mclass.get(), NULL));
if (!props.get()) {
- ALOGE("%s: Error allocating object Array for properties", __func__);
+ log::error("Error allocating object Array for properties");
return;
}
ScopedLocalRef types(
sCallbackEnv.get(), (jintArray)sCallbackEnv->NewIntArray(num_properties));
if (!types.get()) {
- ALOGE("%s: Error allocating int Array for values", __func__);
+ log::error("Error allocating int Array for values");
return;
}
@@ -192,17 +203,18 @@ static void remote_device_properties_callback(bt_status_t status,
bt_property_t* properties) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
- ALOGV("%s: Status is: %d, Properties: %d", __func__, status, num_properties);
+ log::verbose("Status is: {}, Properties: {}", bt_status_text(status),
+ num_properties);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Status %d is incorrect", __func__, status);
+ log::error("Status {} is incorrect", bt_status_text(status));
return;
}
@@ -210,7 +222,7 @@ static void remote_device_properties_callback(bt_status_t status,
sCallbackEnv.get(),
(jbyteArray)sCallbackEnv->NewByteArray(num_properties));
if (!val.get()) {
- ALOGE("%s: Error allocating byteArray", __func__);
+ log::error("Error allocating byteArray");
return;
}
@@ -224,21 +236,21 @@ static void remote_device_properties_callback(bt_status_t status,
sCallbackEnv.get(),
sCallbackEnv->NewObjectArray(num_properties, mclass.get(), NULL));
if (!props.get()) {
- ALOGE("%s: Error allocating object Array for properties", __func__);
+ log::error("Error allocating object Array for properties");
return;
}
ScopedLocalRef types(
sCallbackEnv.get(), (jintArray)sCallbackEnv->NewIntArray(num_properties));
if (!types.get()) {
- ALOGE("%s: Error allocating int Array for values", __func__);
+ log::error("Error allocating int Array for values");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Error while allocation byte array in %s", __func__);
+ log::error("Error while allocation byte array");
return;
}
@@ -260,7 +272,7 @@ static void device_found_callback(int num_properties,
bt_property_t* properties) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
@@ -273,7 +285,7 @@ static void device_found_callback(int num_properties,
if (properties[i].type == BT_PROPERTY_BDADDR) {
addr.reset(sCallbackEnv->NewByteArray(properties[i].len));
if (!addr.get()) {
- ALOGE("Address is NULL (unable to allocate) in %s", __func__);
+ log::error("Address is NULL (unable to allocate)");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, properties[i].len,
@@ -282,12 +294,13 @@ static void device_found_callback(int num_properties,
}
}
if (!addr.get()) {
- ALOGE("Address is NULL in %s", __func__);
+ log::error("Address is NULL");
return;
}
- ALOGV("%s: Properties: %d, Address: %s", __func__, num_properties,
- (const char*)properties[addr_index].val);
+ log::verbose(
+ "Properties: {}, Address: {}", num_properties,
+ ADDRESS_TO_LOGGABLE_STR(*(RawAddress*)properties[addr_index].val));
remote_device_properties_callback(BT_STATUS_SUCCESS,
(RawAddress*)properties[addr_index].val,
@@ -302,7 +315,7 @@ static void bond_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
int fail_reason) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
@@ -310,14 +323,14 @@ static void bond_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
if (!sCallbackEnv.valid()) return;
if (!bd_addr) {
- ALOGE("Address is null in %s", __func__);
+ log::error("Address is null");
return;
}
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Address allocation failed in %s", __func__);
+ log::error("Address allocation failed");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -332,7 +345,7 @@ static void address_consolidate_callback(RawAddress* main_bd_addr,
RawAddress* secondary_bd_addr) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
@@ -341,7 +354,7 @@ static void address_consolidate_callback(RawAddress* main_bd_addr,
ScopedLocalRef main_addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!main_addr.get()) {
- ALOGE("Address allocation failed in %s", __func__);
+ log::error("Address allocation failed");
return;
}
sCallbackEnv->SetByteArrayRegion(main_addr.get(), 0, sizeof(RawAddress),
@@ -350,7 +363,7 @@ static void address_consolidate_callback(RawAddress* main_bd_addr,
ScopedLocalRef secondary_addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!secondary_addr.get()) {
- ALOGE("Address allocation failed in %s", __func__);
+ log::error("Address allocation failed");
return;
}
@@ -366,7 +379,7 @@ static void le_address_associate_callback(RawAddress* main_bd_addr,
RawAddress* secondary_bd_addr) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
@@ -375,7 +388,7 @@ static void le_address_associate_callback(RawAddress* main_bd_addr,
ScopedLocalRef main_addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!main_addr.get()) {
- ALOGE("Address allocation failed in %s", __func__);
+ log::error("Address allocation failed");
return;
}
sCallbackEnv->SetByteArrayRegion(main_addr.get(), 0, sizeof(RawAddress),
@@ -384,7 +397,7 @@ static void le_address_associate_callback(RawAddress* main_bd_addr,
ScopedLocalRef secondary_addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!secondary_addr.get()) {
- ALOGE("Address allocation failed in %s", __func__);
+ log::error("Address allocation failed");
return;
}
@@ -403,13 +416,13 @@ static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
bt_conn_direction_t /* direction */,
uint16_t acl_handle) {
if (!bd_addr) {
- ALOGE("Address is null in %s", __func__);
+ log::error("Address is null");
return;
}
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
@@ -419,7 +432,7 @@ static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Address allocation failed in %s", __func__);
+ log::error("Address allocation failed");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -434,14 +447,14 @@ static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
static void discovery_state_changed_callback(bt_discovery_state_t state) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
- ALOGV("%s: DiscoveryState:%d ", __func__, state);
+ log::verbose("DiscoveryState:{} ", state);
sCallbackEnv->CallVoidMethod(
sJniCallbacksObj, method_discoveryStateChangeCallback, (jint)state);
@@ -450,13 +463,13 @@ static void discovery_state_changed_callback(bt_discovery_state_t state) {
static void pin_request_callback(RawAddress* bd_addr, bt_bdname_t* bdname,
uint32_t cod, bool min_16_digits) {
if (!bd_addr) {
- ALOGE("Address is null in %s", __func__);
+ log::error("Address is null");
return;
}
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
@@ -466,7 +479,7 @@ static void pin_request_callback(RawAddress* bd_addr, bt_bdname_t* bdname,
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Error while allocating in: %s", __func__);
+ log::error("Error while allocating");
return;
}
@@ -476,7 +489,7 @@ static void pin_request_callback(RawAddress* bd_addr, bt_bdname_t* bdname,
ScopedLocalRef devname(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(bt_bdname_t)));
if (!devname.get()) {
- ALOGE("Error while allocating in: %s", __func__);
+ log::error("Error while allocating");
return;
}
@@ -491,13 +504,13 @@ static void ssp_request_callback(RawAddress* bd_addr, bt_bdname_t* bdname,
uint32_t cod, bt_ssp_variant_t pairing_variant,
uint32_t pass_key) {
if (!bd_addr) {
- ALOGE("Address is null in %s", __func__);
+ log::error("Address is null");
return;
}
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
@@ -507,7 +520,7 @@ static void ssp_request_callback(RawAddress* bd_addr, bt_bdname_t* bdname,
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Error while allocating in: %s", __func__);
+ log::error("Error while allocating");
return;
}
@@ -517,7 +530,7 @@ static void ssp_request_callback(RawAddress* bd_addr, bt_bdname_t* bdname,
ScopedLocalRef devname(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(bt_bdname_t)));
if (!devname.get()) {
- ALOGE("Error while allocating in: %s", __func__);
+ log::error("Error while allocating");
return;
}
@@ -530,7 +543,7 @@ static void ssp_request_callback(RawAddress* bd_addr, bt_bdname_t* bdname,
}
static jobject createClassicOobDataObject(JNIEnv* env, bt_oob_data_t oob_data) {
- ALOGV("%s", __func__);
+ log::verbose("");
jmethodID classicBuilderConstructor;
jmethodID setRMethod;
jmethodID setNameMethod;
@@ -594,7 +607,7 @@ static jobject createClassicOobDataObject(JNIEnv* env, bt_oob_data_t oob_data) {
}
static jobject createLeOobDataObject(JNIEnv* env, bt_oob_data_t oob_data) {
- ALOGV("%s", __func__);
+ log::verbose("");
jmethodID leBuilderConstructor;
jmethodID setRMethod;
@@ -655,11 +668,11 @@ static jobject createLeOobDataObject(JNIEnv* env, bt_oob_data_t oob_data) {
static void generate_local_oob_data_callback(tBT_TRANSPORT transport,
bt_oob_data_t oob_data) {
- ALOGV("%s", __func__);
+ log::verbose("");
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
@@ -682,7 +695,7 @@ static void generate_local_oob_data_callback(tBT_TRANSPORT transport,
// TRANSPORT_AUTO is a concept, however, the host stack doesn't fully
// implement it So passing it from the java layer is currently useless until
// the implementation and concept of TRANSPORT_AUTO is fleshed out.
- ALOGE("TRANSPORT: %d not implemented", transport);
+ log::error("TRANSPORT: {} not implemented", transport);
sCallbackEnv->CallVoidMethod(sJniCallbacksObj,
method_oobDataReceivedCallback,
(jint)transport, nullptr);
@@ -695,16 +708,16 @@ static void link_quality_report_callback(
int negative_acknowledgement_count) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
- ALOGV("%s: LinkQualityReportCallback: %d %d %d %d %d %d", __func__,
- report_id, rssi, snr, retransmission_count, packets_not_receive_count,
- negative_acknowledgement_count);
+ log::verbose("LinkQualityReportCallback: {} {} {} {} {} {}", report_id, rssi,
+ snr, retransmission_count, packets_not_receive_count,
+ negative_acknowledgement_count);
sCallbackEnv->CallVoidMethod(
sJniCallbacksObj, method_linkQualityReportCallback,
@@ -716,15 +729,15 @@ static void link_quality_report_callback(
static void switch_buffer_size_callback(bool is_low_latency_buffer_size) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
- ALOGV("%s: SwitchBufferSizeCallback: %s", __func__,
- is_low_latency_buffer_size ? "true" : "false");
+ log::verbose("SwitchBufferSizeCallback: {}",
+ is_low_latency_buffer_size ? "true" : "false");
sCallbackEnv->CallVoidMethod(
sJniCallbacksObj, method_switchBufferSizeCallback,
@@ -734,15 +747,15 @@ static void switch_buffer_size_callback(bool is_low_latency_buffer_size) {
static void switch_codec_callback(bool is_low_latency_buffer_size) {
std::shared_lock lock(jniObjMutex);
if (!sJniCallbacksObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
- ALOGV("%s: SwitchCodecCallback: %s", __func__,
- is_low_latency_buffer_size ? "true" : "false");
+ log::verbose("SwitchCodecCallback: {}",
+ is_low_latency_buffer_size ? "true" : "false");
sCallbackEnv->CallVoidMethod(sJniCallbacksObj, method_switchCodecCallback,
(jboolean)is_low_latency_buffer_size);
@@ -752,6 +765,29 @@ static void le_rand_callback(uint64_t /* random */) {
// Android doesn't support the LeRand API.
}
+static void key_missing_callback(const RawAddress bd_addr) {
+ std::shared_lock lock(jniObjMutex);
+ if (!sJniCallbacksObj) {
+ log::error("JNI obj is null. Failed to call JNI callback");
+ return;
+ }
+
+ CallbackEnv sCallbackEnv(__func__);
+ if (!sCallbackEnv.valid()) return;
+
+ ScopedLocalRef addr(
+ sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
+ if (!addr.get()) {
+ log::error("Address allocation failed");
+ return;
+ }
+ sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
+ (jbyte*)&bd_addr);
+
+ sCallbackEnv->CallVoidMethod(sJniCallbacksObj, method_keyMissingCallback,
+ addr.get());
+}
+
static void callback_thread_event(bt_cb_thread_evt event) {
if (event == ASSOCIATE_JVM) {
JavaVMAttachArgs args;
@@ -762,10 +798,10 @@ static void callback_thread_event(bt_cb_thread_evt event) {
vm->AttachCurrentThread(&callbackEnv, &args);
sHaveCallbackThread = true;
sCallbackThread = pthread_self();
- ALOGV("Callback thread attached: %p", callbackEnv);
+ log::verbose("Callback thread attached: {}", fmt::ptr(callbackEnv));
} else if (event == DISASSOCIATE_JVM) {
if (!isCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __func__);
+ log::error("Callback: '' is not called on the correct thread");
return;
}
vm->DetachCurrentThread();
@@ -779,14 +815,15 @@ static void dut_mode_recv_callback(uint16_t /* opcode */, uint8_t* /* buf */,
static void le_test_mode_recv_callback(bt_status_t status,
uint16_t packet_count) {
- ALOGV("%s: status:%d packet_count:%d ", __func__, status, packet_count);
+ log::verbose("status:{} packet_count:{} ", bt_status_text(status),
+ packet_count);
}
static void energy_info_recv_callback(bt_activity_energy_info* p_energy_info,
bt_uid_traffic_t* uid_data) {
std::shared_lock lock(jniObjMutex);
if (!sJniAdapterServiceObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return;
}
@@ -838,7 +875,8 @@ static bt_callbacks_t sBluetoothCallbacks = {sizeof(sBluetoothCallbacks),
generate_local_oob_data_callback,
switch_buffer_size_callback,
switch_codec_callback,
- le_rand_callback};
+ le_rand_callback,
+ key_missing_callback};
class JNIThreadAttacher {
public:
@@ -846,9 +884,9 @@ class JNIThreadAttacher {
status_ = vm_->GetEnv((void**)&env_, JNI_VERSION_1_6);
if (status_ != JNI_OK && status_ != JNI_EDETACHED) {
- ALOGE(
- "JNIThreadAttacher: unable to get environment for JNI CALL, "
- "status: %d",
+ log::error(
+ "JNIThreadAttacher: unable to get environment for JNI CALL, status: "
+ "{}",
status_);
env_ = nullptr;
return;
@@ -857,8 +895,8 @@ class JNIThreadAttacher {
if (status_ == JNI_EDETACHED) {
char name[17] = {0};
if (prctl(PR_GET_NAME, (unsigned long)name) != 0) {
- ALOGE(
- "JNIThreadAttacher: unable to grab previous thread name, error: %s",
+ log::error(
+ "JNIThreadAttacher: unable to grab previous thread name, error: {}",
strerror(errno));
env_ = nullptr;
return;
@@ -867,7 +905,7 @@ class JNIThreadAttacher {
JavaVMAttachArgs args = {
.version = JNI_VERSION_1_6, .name = name, .group = nullptr};
if (vm_->AttachCurrentThread(&env_, &args) != 0) {
- ALOGE("JNIThreadAttacher: unable to attach thread to VM");
+ log::error("JNIThreadAttacher: unable to attach thread to VM");
env_ = nullptr;
return;
}
@@ -889,7 +927,7 @@ class JNIThreadAttacher {
static int acquire_wake_lock_callout(const char* lock_name) {
std::shared_lock lock(jniObjMutex);
if (!sJniAdapterServiceObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return BT_STATUS_NOT_READY;
}
@@ -897,7 +935,7 @@ static int acquire_wake_lock_callout(const char* lock_name) {
JNIEnv* env = attacher.getEnv();
if (env == nullptr) {
- ALOGE("%s: Unable to get JNI Env", __func__);
+ log::error("Unable to get JNI Env");
return BT_STATUS_JNI_THREAD_ATTACH_ERROR;
}
@@ -909,7 +947,7 @@ static int acquire_wake_lock_callout(const char* lock_name) {
sJniCallbacksObj, method_acquireWakeLock, lock_name_jni.get());
if (!acquired) ret = BT_STATUS_WAKELOCK_ERROR;
} else {
- ALOGE("%s unable to allocate string: %s", __func__, lock_name);
+ log::error("unable to allocate string: {}", lock_name);
ret = BT_STATUS_NOMEM;
}
}
@@ -920,7 +958,7 @@ static int acquire_wake_lock_callout(const char* lock_name) {
static int release_wake_lock_callout(const char* lock_name) {
std::shared_lock lock(jniObjMutex);
if (!sJniAdapterServiceObj) {
- ALOGE("%s, JNI obj is null. Failed to call JNI callback", __func__);
+ log::error("JNI obj is null. Failed to call JNI callback");
return BT_STATUS_NOT_READY;
}
@@ -928,7 +966,7 @@ static int release_wake_lock_callout(const char* lock_name) {
JNIEnv* env = attacher.getEnv();
if (env == nullptr) {
- ALOGE("%s: Unable to get JNI Env", __func__);
+ log::error("Unable to get JNI Env");
return BT_STATUS_JNI_THREAD_ATTACH_ERROR;
}
@@ -940,7 +978,7 @@ static int release_wake_lock_callout(const char* lock_name) {
sJniCallbacksObj, method_releaseWakeLock, lock_name_jni.get());
if (!released) ret = BT_STATUS_WAKELOCK_ERROR;
} else {
- ALOGE("%s unable to allocate string: %s", __func__, lock_name);
+ log::error("unable to allocate string: {}", lock_name);
ret = BT_STATUS_NOMEM;
}
}
@@ -966,20 +1004,20 @@ int hal_util_load_bt_library(const bt_interface_t** interface) {
void* handle = dlopen("libbluetooth.so", RTLD_NOW);
if (!handle) {
const char* err_str = dlerror();
- ALOGE("%s: failed to load Bluetooth library, error=%s", __func__,
- err_str ? err_str : "error unknown");
+ log::error("failed to load Bluetooth library, error={}",
+ err_str ? err_str : "error unknown");
goto error;
}
// Get the address of the bt_interface_t.
itf = (bt_interface_t*)dlsym(handle, sym);
if (!itf) {
- ALOGE("%s: failed to load symbol from Bluetooth library %s", __func__, sym);
+ log::error("failed to load symbol from Bluetooth library {}", sym);
goto error;
}
// Success.
- ALOGI("%s: loaded Bluetooth library successfully", __func__);
+ log::info("loaded Bluetooth library successfully");
*interface = itf;
return 0;
@@ -997,7 +1035,7 @@ static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest,
jstring userDataDirectory) {
std::unique_lock lock(jniObjMutex);
- ALOGV("%s", __func__);
+ log::verbose("");
android_bluetooth_UidTraffic.clazz =
(jclass)env->NewGlobalRef(env->FindClass("android/bluetooth/UidTraffic"));
@@ -1041,13 +1079,13 @@ static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest,
delete[] flagObjs;
if (ret != BT_STATUS_SUCCESS) {
- ALOGE("Error while setting the callbacks: %d\n", ret);
+ log::error("Error while setting the callbacks: {}", ret);
sBluetoothInterface = NULL;
return JNI_FALSE;
}
ret = sBluetoothInterface->set_os_callouts(&sBluetoothOsCallouts);
if (ret != BT_STATUS_SUCCESS) {
- ALOGE("Error while setting Bluetooth callouts: %d\n", ret);
+ log::error("Error while setting Bluetooth callouts: {}", ret);
sBluetoothInterface->cleanup();
sBluetoothInterface = NULL;
return JNI_FALSE;
@@ -1057,7 +1095,7 @@ static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest,
(btsock_interface_t*)sBluetoothInterface->get_profile_interface(
BT_PROFILE_SOCKETS_ID);
if (sBluetoothSocketInterface == NULL) {
- ALOGE("Error getting socket interface");
+ log::error("Error getting socket interface");
}
return JNI_TRUE;
@@ -1066,12 +1104,12 @@ static bool initNative(JNIEnv* env, jobject obj, jboolean isGuest,
static bool cleanupNative(JNIEnv* env, jobject /* obj */) {
std::unique_lock lock(jniObjMutex);
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
sBluetoothInterface->cleanup();
- ALOGI("%s: return from cleanup", __func__);
+ log::info("return from cleanup");
if (sJniCallbacksObj) {
env->DeleteGlobalRef(sJniCallbacksObj);
@@ -1091,7 +1129,7 @@ static bool cleanupNative(JNIEnv* env, jobject /* obj */) {
}
static jboolean enableNative(JNIEnv* /* env */, jobject /* obj */) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
int ret = sBluetoothInterface->enable();
@@ -1100,7 +1138,7 @@ static jboolean enableNative(JNIEnv* /* env */, jobject /* obj */) {
}
static jboolean disableNative(JNIEnv* /* env */, jobject /* obj */) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1113,7 +1151,7 @@ static jboolean disableNative(JNIEnv* /* env */, jobject /* obj */) {
}
static jboolean startDiscoveryNative(JNIEnv* /* env */, jobject /* obj */) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1122,7 +1160,7 @@ static jboolean startDiscoveryNative(JNIEnv* /* env */, jobject /* obj */) {
}
static jboolean cancelDiscoveryNative(JNIEnv* /* env */, jobject /* obj */) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1133,7 +1171,7 @@ static jboolean cancelDiscoveryNative(JNIEnv* /* env */, jobject /* obj */) {
static jboolean createBondNative(JNIEnv* env, jobject /* obj */,
jbyteArray address, jint addrType,
jint transport) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1152,7 +1190,7 @@ static jboolean createBondNative(JNIEnv* env, jobject /* obj */,
}
if (ret != BT_STATUS_SUCCESS) {
- ALOGW("%s: Failed to initiate bonding. Status = %d", __func__, ret);
+ log::warn("Failed to initiate bonding. Status = {}", ret);
}
env->ReleaseByteArrayElements(address, addr, 0);
@@ -1180,7 +1218,7 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
jint transport) {
// Need both arguments to be non NULL
if (oobData == NULL) {
- ALOGE("%s: oobData is null! Nothing to do.", __func__);
+ log::error("oobData is null! Nothing to do.");
return JNI_FALSE;
}
@@ -1192,8 +1230,8 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
// Check the data
int len = env->GetArrayLength(address);
if (len != OOB_ADDRESS_SIZE) {
- ALOGE("%s: addressBytes must be 7 bytes in length (address plus type) 6+1!",
- __func__);
+ log::error(
+ "addressBytes must be 7 bytes in length (address plus type) 6+1!");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -1201,7 +1239,7 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
// Convert the address from byte[]
jbyte* addressBytes = env->GetByteArrayElements(address, NULL);
if (addressBytes == NULL) {
- ALOGE("%s: addressBytes cannot be null!", __func__);
+ log::error("addressBytes cannot be null!");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -1218,10 +1256,10 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
deviceNameBytes = env->GetByteArrayElements(deviceName, NULL);
int len = env->GetArrayLength(deviceName);
if (len > OOB_NAME_MAX_SIZE) {
- ALOGI(
- "%s: wrong length of deviceName, should be empty or less than or "
- "equal to %d bytes.",
- __func__, OOB_NAME_MAX_SIZE);
+ log::info(
+ "wrong length of deviceName, should be empty or less than or equal "
+ "to {} bytes.",
+ OOB_NAME_MAX_SIZE);
jniThrowIOException(env, EINVAL);
env->ReleaseByteArrayElements(deviceName, deviceNameBytes, 0);
return JNI_FALSE;
@@ -1233,7 +1271,7 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
jbyteArray confirmation = callByteArrayGetter(
env, oobData, "android/bluetooth/OobData", "getConfirmationHash");
if (confirmation == NULL) {
- ALOGE("%s: confirmation cannot be null!", __func__);
+ log::error("confirmation cannot be null!");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -1243,10 +1281,8 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
confirmationBytes = env->GetByteArrayElements(confirmation, NULL);
len = env->GetArrayLength(confirmation);
if (confirmationBytes == NULL || len != OOB_C_SIZE) {
- ALOGI(
- "%s: wrong length of Confirmation, should be empty or %d "
- "bytes.",
- __func__, OOB_C_SIZE);
+ log::info("wrong length of Confirmation, should be empty or {} bytes.",
+ OOB_C_SIZE);
jniThrowIOException(env, EINVAL);
env->ReleaseByteArrayElements(confirmation, confirmationBytes, 0);
return JNI_FALSE;
@@ -1262,8 +1298,8 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
randomizerBytes = env->GetByteArrayElements(randomizer, NULL);
int len = env->GetArrayLength(randomizer);
if (randomizerBytes == NULL || len != OOB_R_SIZE) {
- ALOGI("%s: wrong length of Random, should be empty or %d bytes.",
- __func__, OOB_R_SIZE);
+ log::info("wrong length of Random, should be empty or {} bytes.",
+ OOB_R_SIZE);
jniThrowIOException(env, EINVAL);
env->ReleaseByteArrayElements(randomizer, randomizerBytes, 0);
return JNI_FALSE;
@@ -1281,8 +1317,8 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
jbyte* oobDataLengthBytes = NULL;
if (oobDataLength == NULL ||
env->GetArrayLength(oobDataLength) != OOB_DATA_LEN_SIZE) {
- ALOGI("%s: wrong length of oobDataLength, should be empty or %d bytes.",
- __func__, OOB_DATA_LEN_SIZE);
+ log::info("wrong length of oobDataLength, should be empty or {} bytes.",
+ OOB_DATA_LEN_SIZE);
jniThrowIOException(env, EINVAL);
env->ReleaseByteArrayElements(oobDataLength, oobDataLengthBytes, 0);
return JNI_FALSE;
@@ -1300,8 +1336,8 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
classOfDeviceBytes = env->GetByteArrayElements(classOfDevice, NULL);
int len = env->GetArrayLength(classOfDevice);
if (len != OOB_COD_SIZE) {
- ALOGI("%s: wrong length of classOfDevice, should be empty or %d bytes.",
- __func__, OOB_COD_SIZE);
+ log::info("wrong length of classOfDevice, should be empty or {} bytes.",
+ OOB_COD_SIZE);
jniThrowIOException(env, EINVAL);
env->ReleaseByteArrayElements(classOfDevice, classOfDeviceBytes, 0);
return JNI_FALSE;
@@ -1318,8 +1354,8 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
temporaryKeyBytes = env->GetByteArrayElements(temporaryKey, NULL);
int len = env->GetArrayLength(temporaryKey);
if (len != OOB_TK_SIZE) {
- ALOGI("%s: wrong length of temporaryKey, should be empty or %d bytes.",
- __func__, OOB_TK_SIZE);
+ log::info("wrong length of temporaryKey, should be empty or {} bytes.",
+ OOB_TK_SIZE);
jniThrowIOException(env, EINVAL);
env->ReleaseByteArrayElements(temporaryKey, temporaryKeyBytes, 0);
return JNI_FALSE;
@@ -1335,8 +1371,8 @@ static jboolean set_data(JNIEnv* env, bt_oob_data_t& oob_data, jobject oobData,
leAppearanceBytes = env->GetByteArrayElements(leAppearance, NULL);
int len = env->GetArrayLength(leAppearance);
if (len != OOB_LE_APPEARANCE_SIZE) {
- ALOGI("%s: wrong length of leAppearance, should be empty or %d bytes.",
- __func__, OOB_LE_APPEARANCE_SIZE);
+ log::info("wrong length of leAppearance, should be empty or {} bytes.",
+ OOB_LE_APPEARANCE_SIZE);
jniThrowIOException(env, EINVAL);
env->ReleaseByteArrayElements(leAppearance, leAppearanceBytes, 0);
return JNI_FALSE;
@@ -1363,7 +1399,7 @@ static void generateLocalOobDataNative(JNIEnv* /* env */, jobject /* obj */,
if (sBluetoothInterface->generate_local_oob_data(transport) !=
BT_STATUS_SUCCESS) {
- ALOGE("%s: Call to generate_local_oob_data failed!", __func__);
+ log::error("Call to generate_local_oob_data failed!");
bt_oob_data_t oob_data;
oob_data.is_valid = false;
generate_local_oob_data_callback(transport, oob_data);
@@ -1378,7 +1414,7 @@ static jboolean createBondOutOfBandNative(JNIEnv* env, jobject /* obj */,
// No data? Can't do anything
if (p192Data == NULL && p256Data == NULL) {
- ALOGE("%s: All OOB Data are null! Nothing to do.", __func__);
+ log::error("All OOB Data are null! Nothing to do.");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -1387,7 +1423,7 @@ static jboolean createBondOutOfBandNative(JNIEnv* env, jobject /* obj */,
// In the future we want to remove this and just reverse the address
// for the oobdata in the host stack.
if (address == NULL) {
- ALOGE("%s: Address cannot be null! Nothing to do.", __func__);
+ log::error("Address cannot be null! Nothing to do.");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -1395,8 +1431,8 @@ static jboolean createBondOutOfBandNative(JNIEnv* env, jobject /* obj */,
// Check the data
int len = env->GetArrayLength(address);
if (len != 6) {
- ALOGE("%s: addressBytes must be 6 bytes in length (address plus type) 6+1!",
- __func__);
+ log::error(
+ "addressBytes must be 6 bytes in length (address plus type) 6+1!");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -1434,7 +1470,7 @@ static jboolean createBondOutOfBandNative(JNIEnv* env, jobject /* obj */,
static jboolean removeBondNative(JNIEnv* env, jobject /* obj */,
jbyteArray address) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1452,7 +1488,7 @@ static jboolean removeBondNative(JNIEnv* env, jobject /* obj */,
static jboolean cancelBondNative(JNIEnv* env, jobject /* obj */,
jbyteArray address) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1467,9 +1503,17 @@ static jboolean cancelBondNative(JNIEnv* env, jobject /* obj */,
return (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
+static jboolean pairingIsBusyNative(JNIEnv* /*env*/, jobject /* obj */) {
+ log::verbose("");
+
+ if (!sBluetoothInterface) return JNI_FALSE;
+
+ return sBluetoothInterface->pairing_is_busy();
+}
+
static int getConnectionStateNative(JNIEnv* env, jobject /* obj */,
jbyteArray address) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
jbyte* addr = env->GetByteArrayElements(address, NULL);
@@ -1487,7 +1531,7 @@ static int getConnectionStateNative(JNIEnv* env, jobject /* obj */,
static jboolean pinReplyNative(JNIEnv* env, jobject /* obj */,
jbyteArray address, jboolean accept, jint len,
jbyteArray pinArray) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1518,7 +1562,7 @@ static jboolean pinReplyNative(JNIEnv* env, jobject /* obj */,
static jboolean sspReplyNative(JNIEnv* env, jobject /* obj */,
jbyteArray address, jint type, jboolean accept,
jint passkey) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1537,7 +1581,7 @@ static jboolean sspReplyNative(JNIEnv* env, jobject /* obj */,
static jboolean setAdapterPropertyNative(JNIEnv* env, jobject /* obj */,
jint type, jbyteArray value) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1555,7 +1599,7 @@ static jboolean setAdapterPropertyNative(JNIEnv* env, jobject /* obj */,
static jboolean getAdapterPropertiesNative(JNIEnv* /* env */,
jobject /* obj */) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1565,7 +1609,7 @@ static jboolean getAdapterPropertiesNative(JNIEnv* /* env */,
static jboolean getAdapterPropertyNative(JNIEnv* /* env */, jobject /* obj */,
jint type) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1575,7 +1619,7 @@ static jboolean getAdapterPropertyNative(JNIEnv* /* env */, jobject /* obj */,
static jboolean getDevicePropertyNative(JNIEnv* env, jobject /* obj */,
jbyteArray address, jint type) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1594,7 +1638,7 @@ static jboolean getDevicePropertyNative(JNIEnv* env, jobject /* obj */,
static jboolean setDevicePropertyNative(JNIEnv* env, jobject /* obj */,
jbyteArray address, jint type,
jbyteArray value) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1626,7 +1670,7 @@ static jboolean setDevicePropertyNative(JNIEnv* env, jobject /* obj */,
static jboolean getRemoteServicesNative(JNIEnv* env, jobject /* obj */,
jbyteArray address, jint transport) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1643,7 +1687,7 @@ static jboolean getRemoteServicesNative(JNIEnv* env, jobject /* obj */,
}
static int readEnergyInfoNative() {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
int ret = sBluetoothInterface->read_energy_info();
@@ -1652,7 +1696,7 @@ static int readEnergyInfoNative() {
static void dumpNative(JNIEnv* env, jobject /* obj */, jobject fdObj,
jobjectArray argArray) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return;
int fd = jniGetFDFromFileDescriptor(env, fdObj);
@@ -1683,7 +1727,7 @@ static void dumpNative(JNIEnv* env, jobject /* obj */, jobject fdObj,
}
static jbyteArray dumpMetricsNative(JNIEnv* env, jobject /* obj */) {
- ALOGI("%s", __func__);
+ log::info("");
if (!sBluetoothInterface) return env->NewByteArray(0);
std::string output;
@@ -1696,7 +1740,7 @@ static jbyteArray dumpMetricsNative(JNIEnv* env, jobject /* obj */) {
}
static jboolean factoryResetNative(JNIEnv* /* env */, jobject /* obj */) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
int ret = sBluetoothInterface->config_clear();
return (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -1704,7 +1748,7 @@ static jboolean factoryResetNative(JNIEnv* /* env */, jobject /* obj */) {
static jbyteArray obfuscateAddressNative(JNIEnv* env, jobject /* obj */,
jbyteArray address) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return env->NewByteArray(0);
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (addr == nullptr) {
@@ -1724,7 +1768,7 @@ static jbyteArray obfuscateAddressNative(JNIEnv* env, jobject /* obj */,
static jboolean setBufferLengthMillisNative(JNIEnv* /* env */,
jobject /* obj */, jint codec,
jint size) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -1815,7 +1859,7 @@ static void requestMaximumTxDataLengthNative(JNIEnv* env, jobject /* obj */,
static int getMetricIdNative(JNIEnv* env, jobject /* obj */,
jbyteArray address) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return 0; // 0 is invalid id
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (addr == nullptr) {
@@ -1830,7 +1874,7 @@ static int getMetricIdNative(JNIEnv* env, jobject /* obj */,
static jboolean allowLowLatencyAudioNative(JNIEnv* env, jobject /* obj */,
jboolean allowed,
jbyteArray address) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return false;
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (addr == nullptr) {
@@ -1847,7 +1891,7 @@ static jboolean allowLowLatencyAudioNative(JNIEnv* env, jobject /* obj */,
static void metadataChangedNative(JNIEnv* env, jobject /* obj */,
jbyteArray address, jint key,
jbyteArray value) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return;
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (addr == nullptr) {
@@ -1858,7 +1902,7 @@ static void metadataChangedNative(JNIEnv* env, jobject /* obj */,
addr_obj.FromOctets((uint8_t*)addr);
if (value == NULL) {
- ALOGE("metadataChangedNative() ignoring NULL array");
+ log::error("metadataChangedNative() ignoring NULL array");
return;
}
@@ -1876,22 +1920,22 @@ static void metadataChangedNative(JNIEnv* env, jobject /* obj */,
static jboolean isLogRedactionEnabledNative(JNIEnv* /* env */,
jobject /* obj */) {
- ALOGV("%s", __func__);
+ log::verbose("");
return bluetooth::os::should_log_be_redacted();
}
static jboolean interopMatchAddrNative(JNIEnv* env, jclass /* clazz */,
jstring feature_name, jstring address) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) {
- ALOGW("%s: sBluetoothInterface is null.", __func__);
+ log::warn("sBluetoothInterface is null.");
return JNI_FALSE;
}
const char* tmp_addr = env->GetStringUTFChars(address, NULL);
if (!tmp_addr) {
- ALOGW("%s: address is null.", __func__);
+ log::warn("address is null.");
return JNI_FALSE;
}
RawAddress bdaddr;
@@ -1900,13 +1944,13 @@ static jboolean interopMatchAddrNative(JNIEnv* env, jclass /* clazz */,
env->ReleaseStringUTFChars(address, tmp_addr);
if (!success) {
- ALOGW("%s: address is invalid.", __func__);
+ log::warn("address is invalid.");
return JNI_FALSE;
}
const char* feature_name_str = env->GetStringUTFChars(feature_name, NULL);
if (!feature_name_str) {
- ALOGW("%s: feature name is null.", __func__);
+ log::warn("feature name is null.");
return JNI_FALSE;
}
@@ -1919,22 +1963,22 @@ static jboolean interopMatchAddrNative(JNIEnv* env, jclass /* clazz */,
static jboolean interopMatchNameNative(JNIEnv* env, jclass /* clazz */,
jstring feature_name, jstring name) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) {
- ALOGW("%s: sBluetoothInterface is null.", __func__);
+ log::warn("sBluetoothInterface is null.");
return JNI_FALSE;
}
const char* feature_name_str = env->GetStringUTFChars(feature_name, NULL);
if (!feature_name_str) {
- ALOGW("%s: feature name is null.", __func__);
+ log::warn("feature name is null.");
return JNI_FALSE;
}
const char* name_str = env->GetStringUTFChars(name, NULL);
if (!name_str) {
- ALOGW("%s: name is null.", __func__);
+ log::warn("name is null.");
env->ReleaseStringUTFChars(feature_name, feature_name_str);
return JNI_FALSE;
}
@@ -1950,16 +1994,16 @@ static jboolean interopMatchNameNative(JNIEnv* env, jclass /* clazz */,
static jboolean interopMatchAddrOrNameNative(JNIEnv* env, jclass /* clazz */,
jstring feature_name,
jstring address) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) {
- ALOGW("%s: sBluetoothInterface is null.", __func__);
+ log::warn("sBluetoothInterface is null.");
return JNI_FALSE;
}
const char* tmp_addr = env->GetStringUTFChars(address, NULL);
if (!tmp_addr) {
- ALOGW("%s: address is null.", __func__);
+ log::warn("address is null.");
return JNI_FALSE;
}
RawAddress bdaddr;
@@ -1968,13 +2012,13 @@ static jboolean interopMatchAddrOrNameNative(JNIEnv* env, jclass /* clazz */,
env->ReleaseStringUTFChars(address, tmp_addr);
if (!success) {
- ALOGW("%s: address is invalid.", __func__);
+ log::warn("address is invalid.");
return JNI_FALSE;
}
const char* feature_name_str = env->GetStringUTFChars(feature_name, NULL);
if (!feature_name_str) {
- ALOGW("%s: feature name is null.", __func__);
+ log::warn("feature name is null.");
return JNI_FALSE;
}
@@ -1989,22 +2033,21 @@ static void interopDatabaseAddRemoveAddrNative(JNIEnv* env, jclass /* clazz */,
jboolean do_add,
jstring feature_name,
jstring address, jint length) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) {
- ALOGW("%s: sBluetoothInterface is null.", __func__);
+ log::warn("sBluetoothInterface is null.");
return;
}
if ((do_add == JNI_TRUE) && (length <= 0 || length > 6)) {
- ALOGE("%s: address length %d is invalid, valid length is [1,6]", __func__,
- length);
+ log::error("address length {} is invalid, valid length is [1,6]", length);
return;
}
const char* tmp_addr = env->GetStringUTFChars(address, NULL);
if (!tmp_addr) {
- ALOGW("%s: address is null.", __func__);
+ log::warn("address is null.");
return;
}
RawAddress bdaddr;
@@ -2013,13 +2056,13 @@ static void interopDatabaseAddRemoveAddrNative(JNIEnv* env, jclass /* clazz */,
env->ReleaseStringUTFChars(address, tmp_addr);
if (!success) {
- ALOGW("%s: address is invalid.", __func__);
+ log::warn("address is invalid.");
return;
}
const char* feature_name_str = env->GetStringUTFChars(feature_name, NULL);
if (!feature_name_str) {
- ALOGW("%s: feature name is null.", __func__);
+ log::warn("feature name is null.");
return;
}
@@ -2033,22 +2076,22 @@ static void interopDatabaseAddRemoveNameNative(JNIEnv* env, jclass /* clazz */,
jboolean do_add,
jstring feature_name,
jstring name) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) {
- ALOGW("%s: sBluetoothInterface is null.", __func__);
+ log::warn("sBluetoothInterface is null.");
return;
}
const char* feature_name_str = env->GetStringUTFChars(feature_name, NULL);
if (!feature_name_str) {
- ALOGW("%s: feature name is null.", __func__);
+ log::warn("feature name is null.");
return;
}
const char* name_str = env->GetStringUTFChars(name, NULL);
if (!name_str) {
- ALOGW("%s: name is null.", __func__);
+ log::warn("name is null.");
env->ReleaseStringUTFChars(feature_name, feature_name_str);
return;
}
@@ -2062,13 +2105,13 @@ static void interopDatabaseAddRemoveNameNative(JNIEnv* env, jclass /* clazz */,
static int getRemotePbapPceVersionNative(JNIEnv* env, jobject /* obj */,
jstring address) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
const char* tmp_addr = env->GetStringUTFChars(address, NULL);
if (!tmp_addr) {
- ALOGW("%s: address is null.", __func__);
+ log::warn("address is null.");
return JNI_FALSE;
}
@@ -2078,7 +2121,7 @@ static int getRemotePbapPceVersionNative(JNIEnv* env, jobject /* obj */,
env->ReleaseStringUTFChars(address, tmp_addr);
if (!success) {
- ALOGW("%s: address is invalid.", __func__);
+ log::warn("address is invalid.");
return JNI_FALSE;
}
@@ -2087,7 +2130,7 @@ static int getRemotePbapPceVersionNative(JNIEnv* env, jobject /* obj */,
static jboolean pbapPseDynamicVersionUpgradeIsEnabledNative(JNIEnv* /* env */,
jobject /* obj */) {
- ALOGV("%s", __func__);
+ log::verbose("");
if (!sBluetoothInterface) return JNI_FALSE;
@@ -2116,6 +2159,7 @@ int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env) {
(void*)createBondOutOfBandNative},
{"removeBondNative", "([B)Z", (void*)removeBondNative},
{"cancelBondNative", "([B)Z", (void*)cancelBondNative},
+ {"pairingIsBusyNative", "()Z", (void*)pairingIsBusyNative},
{"generateLocalOobDataNative", "(I)V", (void*)generateLocalOobDataNative},
{"getConnectionStateNative", "([B)I", (void*)getConnectionStateNative},
{"pinReplyNative", "([BZI[B)Z", (void*)pinReplyNative},
@@ -2198,6 +2242,7 @@ int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env) {
{"releaseWakeLock", "(Ljava/lang/String;)Z", &method_releaseWakeLock},
{"energyInfoCallback", "(IIJJJJ[Landroid/bluetooth/UidTraffic;)V",
&method_energyInfo},
+ {"keyMissingCallback", "([B)V", &method_keyMissingCallback},
};
GET_JAVA_METHODS(env, "com/android/bluetooth/btservice/JniCallbacks",
javaMethods);
@@ -2208,11 +2253,11 @@ int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env) {
GET_JAVA_METHODS(env, "android/bluetooth/UidTraffic", javaUuidTrafficMethods);
if (env->GetJavaVM(&vm) != JNI_OK) {
- ALOGE("Could not get JavaVM");
+ log::error("Could not get JavaVM");
}
if (hal_util_load_bt_library((bt_interface_t const**)&sBluetoothInterface)) {
- ALOGE("No Bluetooth Library found");
+ log::error("No Bluetooth Library found");
}
return 0;
@@ -2224,123 +2269,151 @@ int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env) {
* JNI Initialization
*/
jint JNI_OnLoad(JavaVM* jvm, void* /* reserved */) {
+ /* Set the default logging level for the process using the tag
+ * "log.tag.bluetooth" and/or "persist.log.tag.bluetooth" via the android
+ * logging framework.
+ */
+ const char* stack_default_log_tag = "bluetooth";
+ int default_prio = ANDROID_LOG_INFO;
+ if (__android_log_is_loggable(ANDROID_LOG_VERBOSE, stack_default_log_tag,
+ default_prio)) {
+ __android_log_set_minimum_priority(ANDROID_LOG_VERBOSE);
+ log::info("Set stack default log level to 'VERBOSE'");
+ } else if (__android_log_is_loggable(ANDROID_LOG_DEBUG, stack_default_log_tag,
+ default_prio)) {
+ __android_log_set_minimum_priority(ANDROID_LOG_DEBUG);
+ log::info("Set stack default log level to 'DEBUG'");
+ } else if (__android_log_is_loggable(ANDROID_LOG_INFO, stack_default_log_tag,
+ default_prio)) {
+ __android_log_set_minimum_priority(ANDROID_LOG_INFO);
+ log::info("Set stack default log level to 'INFO'");
+ } else if (__android_log_is_loggable(ANDROID_LOG_WARN, stack_default_log_tag,
+ default_prio)) {
+ __android_log_set_minimum_priority(ANDROID_LOG_WARN);
+ log::info("Set stack default log level to 'WARN'");
+ } else if (__android_log_is_loggable(ANDROID_LOG_ERROR, stack_default_log_tag,
+ default_prio)) {
+ __android_log_set_minimum_priority(ANDROID_LOG_ERROR);
+ log::info("Set stack default log level to 'ERROR'");
+ }
+
JNIEnv* e;
int status;
- ALOGV("Bluetooth Adapter Service : loading JNI\n");
+ log::verbose("Bluetooth Adapter Service : loading JNI\n");
// Check JNI version
if (jvm->GetEnv((void**)&e, JNI_VERSION_1_6)) {
- ALOGE("JNI version mismatch error");
+ log::error("JNI version mismatch error");
return JNI_ERR;
}
status = android::register_com_android_bluetooth_btservice_AdapterService(e);
if (status < 0) {
- ALOGE("jni adapter service registration failure, status: %d", status);
+ log::error("jni adapter service registration failure, status: {}", status);
return JNI_ERR;
}
status =
android::register_com_android_bluetooth_btservice_BluetoothKeystore(e);
if (status < 0) {
- ALOGE("jni BluetoothKeyStore registration failure: %d", status);
+ log::error("jni BluetoothKeyStore registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_hfp(e);
if (status < 0) {
- ALOGE("jni hfp registration failure, status: %d", status);
+ log::error("jni hfp registration failure, status: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_hfpclient(e);
if (status < 0) {
- ALOGE("jni hfp client registration failure, status: %d", status);
+ log::error("jni hfp client registration failure, status: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_a2dp(e);
if (status < 0) {
- ALOGE("jni a2dp source registration failure: %d", status);
+ log::error("jni a2dp source registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_a2dp_sink(e);
if (status < 0) {
- ALOGE("jni a2dp sink registration failure: %d", status);
+ log::error("jni a2dp sink registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_avrcp_target(e);
if (status < 0) {
- ALOGE("jni new avrcp target registration failure: %d", status);
+ log::error("jni new avrcp target registration failure: {}", status);
}
status = android::register_com_android_bluetooth_avrcp_controller(e);
if (status < 0) {
- ALOGE("jni avrcp controller registration failure: %d", status);
+ log::error("jni avrcp controller registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_hid_host(e);
if (status < 0) {
- ALOGE("jni hid registration failure: %d", status);
+ log::error("jni hid registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_hid_device(e);
if (status < 0) {
- ALOGE("jni hidd registration failure: %d", status);
+ log::error("jni hidd registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_pan(e);
if (status < 0) {
- ALOGE("jni pan registration failure: %d", status);
+ log::error("jni pan registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_gatt(e);
if (status < 0) {
- ALOGE("jni gatt registration failure: %d", status);
+ log::error("jni gatt registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_sdp(e);
if (status < 0) {
- ALOGE("jni sdp registration failure: %d", status);
+ log::error("jni sdp registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_hearing_aid(e);
if (status < 0) {
- ALOGE("jni hearing aid registration failure: %d", status);
+ log::error("jni hearing aid registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_hap_client(e);
if (status < 0) {
- ALOGE("jni le audio hearing access client registration failure: %d",
- status);
+ log::error("jni le audio hearing access client registration failure: {}",
+ status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_le_audio(e);
if (status < 0) {
- ALOGE("jni le_audio registration failure: %d", status);
+ log::error("jni le_audio registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_vc(e);
if (status < 0) {
- ALOGE("jni vc registration failure: %d", status);
+ log::error("jni vc registration failure: {}", status);
return JNI_ERR;
}
status = android::register_com_android_bluetooth_csip_set_coordinator(e);
if (status < 0) {
- ALOGE("jni csis client registration failure: %d", status);
+ log::error("jni csis client registration failure: {}", status);
return JNI_ERR;
}
@@ -2348,7 +2421,7 @@ jint JNI_OnLoad(JavaVM* jvm, void* /* reserved */) {
android::register_com_android_bluetooth_btservice_BluetoothQualityReport(
e);
if (status < 0) {
- ALOGE("jni bluetooth quality report registration failure: %d", status);
+ log::error("jni bluetooth quality report registration failure: {}", status);
return JNI_ERR;
}
@@ -2362,8 +2435,8 @@ void jniGetMethodsOrDie(JNIEnv* env, const char* className,
const JNIJavaMethod* methods, int nMethods) {
jclass clazz = env->FindClass(className);
if (clazz == nullptr) {
- LOG(FATAL) << "Native registration unable to find class '" << className
- << "'; aborting...";
+ log::fatal("Native registration unable to find class '{}' aborting...",
+ className);
}
for (int i = 0; i < nMethods; i++) {
@@ -2374,9 +2447,9 @@ void jniGetMethodsOrDie(JNIEnv* env, const char* className,
*method.id = env->GetMethodID(clazz, method.name, method.signature);
}
if (method.id == nullptr) {
- LOG(FATAL) << "In class " << className << ": Unable to find '"
- << method.name << "' with signature=" << method.signature
- << " is_static=" << method.is_static;
+ log::fatal(
+ "In class {}: Unable to find '{}' with signature={} is_static={}",
+ className, method.name, method.signature, method.is_static);
}
}
diff --git a/android/app/jni/com_android_bluetooth_btservice_BluetoothKeystore.cpp b/android/app/jni/com_android_bluetooth_btservice_BluetoothKeystore.cpp
index 1c5e382c52b07c6f3ad0fb13778ea2f021261861..7d083cc68573ecdd4405d1d66bf332f91f6312cc 100644
--- a/android/app/jni/com_android_bluetooth_btservice_BluetoothKeystore.cpp
+++ b/android/app/jni/com_android_bluetooth_btservice_BluetoothKeystore.cpp
@@ -44,7 +44,7 @@ class BluetoothKeystoreCallbacksImpl
void set_encrypt_key_or_remove_key(
const std::string prefixString,
const std::string decryptedString) override {
- LOG(INFO) << __func__;
+ log::info("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -60,7 +60,7 @@ class BluetoothKeystoreCallbacksImpl
}
std::string get_key(const std::string prefixString) override {
- LOG(INFO) << __func__;
+ log::info("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -72,7 +72,7 @@ class BluetoothKeystoreCallbacksImpl
mCallbacksObj, method_getKeyCallback, j_prefixString);
if (j_decrypt_str == nullptr) {
- ALOGE("%s: Got a null decrypt_str", __func__);
+ log::error("Got a null decrypt_str");
return "";
}
@@ -92,32 +92,30 @@ static void initNative(JNIEnv* env, jobject object) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
if (sBluetoothKeystoreInterface != nullptr) {
- LOG(INFO)
- << "Cleaning up BluetoothKeystore Interface before initializing...";
+ log::info("Cleaning up BluetoothKeystore Interface before initializing...");
sBluetoothKeystoreInterface = nullptr;
}
if (mCallbacksObj != nullptr) {
- LOG(INFO) << "Cleaning up BluetoothKeystore callback object";
+ log::info("Cleaning up BluetoothKeystore callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = nullptr;
}
if ((mCallbacksObj = env->NewGlobalRef(object)) == nullptr) {
- LOG(ERROR)
- << "Failed to allocate Global Ref for BluetoothKeystore Callbacks";
+ log::error("Failed to allocate Global Ref for BluetoothKeystore Callbacks");
return;
}
sBluetoothKeystoreInterface =
(BluetoothKeystoreInterface*)btInf->get_profile_interface(BT_KEYSTORE_ID);
if (sBluetoothKeystoreInterface == nullptr) {
- LOG(ERROR) << "Failed to get BluetoothKeystore Interface";
+ log::error("Failed to get BluetoothKeystore Interface");
return;
}
@@ -130,7 +128,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
diff --git a/android/app/jni/com_android_bluetooth_csip_set_coordinator.cpp b/android/app/jni/com_android_bluetooth_csip_set_coordinator.cpp
index bd24892a76443e2a2dc21a7eeebc9242f0c3dd41..58f8c7fc5dcb6c19d0f4827194252962a331700f 100644
--- a/android/app/jni/com_android_bluetooth_csip_set_coordinator.cpp
+++ b/android/app/jni/com_android_bluetooth_csip_set_coordinator.cpp
@@ -75,8 +75,8 @@ class CsisClientCallbacksImpl : public CsisClientCallbacks {
void OnConnectionState(const RawAddress& bd_addr,
ConnectionState state) override {
- LOG(INFO) << __func__ << ", state:" << int(state)
- << ", addr: " << bd_addr.ToRedactedStringForLogging();
+ log::info("state:{}, addr: {}", int(state),
+ bd_addr.ToRedactedStringForLogging());
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -85,7 +85,7 @@ class CsisClientCallbacksImpl : public CsisClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new bd addr jbyteArray for connection state";
+ log::error("Failed to new bd addr jbyteArray for connection state");
return;
}
@@ -105,7 +105,7 @@ class CsisClientCallbacksImpl : public CsisClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new bd addr jbyteArray for device available";
+ log::error("Failed to new bd addr jbyteArray for device available");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -117,7 +117,7 @@ class CsisClientCallbacksImpl : public CsisClientCallbacks {
}
void OnSetMemberAvailable(const RawAddress& bd_addr, int group_id) override {
- LOG(INFO) << __func__ << ", group id:" << group_id;
+ log::info("group id:{}", group_id);
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -126,7 +126,7 @@ class CsisClientCallbacksImpl : public CsisClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new jbyteArray bd addr for connection state";
+ log::error("Failed to new jbyteArray bd addr for connection state");
return;
}
@@ -138,8 +138,8 @@ class CsisClientCallbacksImpl : public CsisClientCallbacks {
void OnGroupLockChanged(int group_id, bool locked,
CsisGroupLockStatus status) override {
- LOG(INFO) << __func__ << ", group_id: " << int(group_id)
- << ", locked: " << locked << ", status: " << (int)status;
+ log::info("group_id: {}, locked: {}, status: {}", group_id, locked,
+ (int)status);
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -159,31 +159,31 @@ static void initNative(JNIEnv* env, jobject object) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
if (sCsisClientInterface != nullptr) {
- LOG(INFO) << "Cleaning up Csis Interface before initializing...";
+ log::info("Cleaning up Csis Interface before initializing...");
sCsisClientInterface->Cleanup();
sCsisClientInterface = nullptr;
}
if (mCallbacksObj != nullptr) {
- LOG(INFO) << "Cleaning up Csis callback object";
+ log::info("Cleaning up Csis callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = nullptr;
}
if ((mCallbacksObj = env->NewGlobalRef(object)) == nullptr) {
- LOG(ERROR) << "Failed to allocate Global Ref for Csis Client Callbacks";
+ log::error("Failed to allocate Global Ref for Csis Client Callbacks");
return;
}
sCsisClientInterface = (CsisClientInterface*)btInf->get_profile_interface(
BT_PROFILE_CSIS_CLIENT_ID);
if (sCsisClientInterface == nullptr) {
- LOG(ERROR) << "Failed to get Csis Client Interface";
+ log::error("Failed to get Csis Client Interface");
return;
}
@@ -196,7 +196,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
@@ -215,8 +215,7 @@ static jboolean connectNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sCsisClientInterface) {
- LOG(ERROR) << __func__
- << ": Failed to get the Csis Client Interface Interface";
+ log::error("Failed to get the Csis Client Interface Interface");
return JNI_FALSE;
}
@@ -236,7 +235,7 @@ static jboolean disconnectNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sCsisClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Csis Client Interface";
+ log::error("Failed to get the Csis Client Interface");
return JNI_FALSE;
}
@@ -254,11 +253,10 @@ static jboolean disconnectNative(JNIEnv* env, jobject /* object */,
static void groupLockSetNative(JNIEnv* /* env */, jobject /* object */,
jint group_id, jboolean lock) {
- LOG(INFO) << __func__;
+ log::info("");
if (!sCsisClientInterface) {
- LOG(ERROR) << __func__
- << ": Failed to get the Bluetooth Csis Client Interface";
+ log::error("Failed to get the Bluetooth Csis Client Interface");
return;
}
diff --git a/android/app/jni/com_android_bluetooth_gatt.cpp b/android/app/jni/com_android_bluetooth_gatt.cpp
index 0e1836937369d713072fee24fffc594548e9bce8..aaf908a7984478db2396396a06c2f27ad8087bae 100644
--- a/android/app/jni/com_android_bluetooth_gatt.cpp
+++ b/android/app/jni/com_android_bluetooth_gatt.cpp
@@ -26,22 +26,13 @@
#include
#include "com_android_bluetooth.h"
-#include "gd/common/init_flags.h"
+#include "common/init_flags.h"
#include "hardware/bt_gatt.h"
#include "hardware/bt_gatt_types.h"
#include "rust/cxx.h"
#include "rust/src/gatt/ffi/gatt_shim.h"
#include "src/gatt/ffi.rs.h"
#include "utils/Log.h"
-#define info(fmt, ...) ALOGI("%s(L%d): " fmt, __func__, __LINE__, ##__VA_ARGS__)
-#define debug(fmt, ...) \
- ALOGD("%s(L%d): " fmt, __func__, __LINE__, ##__VA_ARGS__)
-#define warn(fmt, ...) \
- ALOGW("WARNING: %s(L%d): " fmt "##", __func__, __LINE__, ##__VA_ARGS__)
-#define error(fmt, ...) \
- ALOGE("ERROR: %s(L%d): " fmt "##", __func__, __LINE__, ##__VA_ARGS__)
-#define asrt(s) \
- if (!(s)) ALOGE("%s(L%d): ASSERT %s failed! ##", __func__, __LINE__, #s)
using bluetooth::Uuid;
@@ -1111,7 +1102,7 @@ class JniScanningCallbacks : ScanningCallbacks {
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!mPeriodicScanCallbacksObj) {
- ALOGE("mPeriodicScanCallbacksObj is NULL. Return.");
+ log::error("mPeriodicScanCallbacksObj is NULL. Return.");
return;
}
ScopedLocalRef addr(sCallbackEnv.get(),
@@ -1154,7 +1145,7 @@ class JniScanningCallbacks : ScanningCallbacks {
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!mPeriodicScanCallbacksObj) {
- ALOGE("mPeriodicScanCallbacksObj is NULL. Return.");
+ log::error("mPeriodicScanCallbacksObj is NULL. Return.");
return;
}
ScopedLocalRef addr(sCallbackEnv.get(),
@@ -1171,7 +1162,7 @@ class JniScanningCallbacks : ScanningCallbacks {
if (!sCallbackEnv.valid()) return;
if (!mPeriodicScanCallbacksObj) {
- ALOGE("mPeriodicScanCallbacksObj is NULL. Return.");
+ log::error("mPeriodicScanCallbacksObj is NULL. Return.");
return;
}
sCallbackEnv->CallVoidMethod(mPeriodicScanCallbacksObj,
@@ -1247,18 +1238,18 @@ static void initializeNative(JNIEnv* env, jobject object) {
btIf = getBluetoothInterface();
if (btIf == NULL) {
- error("Bluetooth module is not loaded");
+ log::error("Bluetooth module is not loaded");
return;
}
if (sGattIf != NULL) {
- ALOGW("Cleaning up Bluetooth GATT Interface before initializing...");
+ log::warn("Cleaning up Bluetooth GATT Interface before initializing...");
sGattIf->cleanup();
sGattIf = NULL;
}
if (mCallbacksObj != NULL) {
- ALOGW("Cleaning up Bluetooth GATT callback object");
+ log::warn("Cleaning up Bluetooth GATT callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = NULL;
}
@@ -1266,13 +1257,14 @@ static void initializeNative(JNIEnv* env, jobject object) {
sGattIf =
(btgatt_interface_t*)btIf->get_profile_interface(BT_PROFILE_GATT_ID);
if (sGattIf == NULL) {
- error("Failed to get Bluetooth GATT Interface");
+ log::error("Failed to get Bluetooth GATT Interface");
return;
}
bt_status_t status = sGattIf->init(&sGattCallbacks);
if (status != BT_STATUS_SUCCESS) {
- error("Failed to initialize Bluetooth GATT, status: %d", status);
+ log::error("Failed to initialize Bluetooth GATT, status: {}",
+ bt_status_text(status));
sGattIf = NULL;
return;
}
@@ -1477,7 +1469,7 @@ static void gattClientWriteCharacteristicNative(JNIEnv* env,
if (!sGattIf) return;
if (value == NULL) {
- warn("gattClientWriteCharacteristicNative() ignoring NULL array");
+ log::warn("gattClientWriteCharacteristicNative() ignoring NULL array");
return;
}
@@ -1505,7 +1497,7 @@ static void gattClientWriteDescriptorNative(JNIEnv* env, jobject /* object */,
if (!sGattIf) return;
if (value == NULL) {
- warn("gattClientWriteDescriptorNative() ignoring NULL array");
+ log::warn("gattClientWriteDescriptorNative() ignoring NULL array");
return;
}
@@ -1551,8 +1543,8 @@ static void gattSetScanParametersNative(JNIEnv* /* env */, jobject /* object */,
jint scan_window_unit) {
if (!sGattIf) return;
sGattIf->scanner->SetScanParameters(
- client_if, scan_interval_unit, scan_window_unit,
- base::Bind(&set_scan_params_cmpl_cb, client_if));
+ client_if, /* use active scan */ 0x01, scan_interval_unit,
+ scan_window_unit, base::Bind(&set_scan_params_cmpl_cb, client_if));
}
void scan_filter_param_cb(uint8_t client_if, uint8_t avbl_space, uint8_t action,
@@ -1716,7 +1708,7 @@ static void gattClientScanFilterAddNative(JNIEnv* env, jobject /* object */,
int len = env->GetArrayLength(irkByteArray.get());
// IRK is 128 bits or 16 octets, set the bytes or zero it out
if (len != 16) {
- ALOGE("%s: Invalid IRK length '%d'; expected 16", __func__, len);
+ log::error("Invalid IRK length '{}'; expected 16", len);
jniThrowIOException(env, EINVAL);
return;
}
@@ -2139,7 +2131,7 @@ static void gattServerSendResponseNative(JNIEnv* env, jobject /* object */,
static void advertiseInitializeNative(JNIEnv* env, jobject object) {
std::unique_lock lock(callbacks_mutex);
if (mAdvertiseCallbacksObj != NULL) {
- ALOGW("Cleaning up Advertise callback object");
+ log::warn("Cleaning up Advertise callback object");
env->DeleteGlobalRef(mAdvertiseCallbacksObj);
mAdvertiseCallbacksObj = NULL;
}
@@ -2230,8 +2222,7 @@ static PeriodicAdvertisingParameters parsePeriodicParams(JNIEnv* env,
uint16_t interval = env->CallIntMethod(i, methodId);
p.enable = true;
- p.include_adi =
- bluetooth::common::init_flags::periodic_advertising_adi_is_enabled();
+ p.include_adi = true;
p.min_interval = interval;
p.max_interval = interval + 16; /* 20ms difference betwen min and max */
uint16_t props = 0;
@@ -2439,17 +2430,15 @@ static void setPeriodicAdvertisingEnableNative(JNIEnv* /* env */,
jboolean enable) {
if (!sGattIf) return;
- bool include_adi =
- bluetooth::common::init_flags::periodic_advertising_adi_is_enabled();
sGattIf->advertiser->SetPeriodicAdvertisingEnable(
- advertiser_id, enable, include_adi,
+ advertiser_id, enable, true /*include_adi*/,
base::Bind(&enablePeriodicSetCb, advertiser_id, enable));
}
static void periodicScanInitializeNative(JNIEnv* env, jobject object) {
std::unique_lock lock(callbacks_mutex);
if (mPeriodicScanCallbacksObj != NULL) {
- ALOGW("Cleaning up periodic scan callback object");
+ log::warn("Cleaning up periodic scan callback object");
env->DeleteGlobalRef(mPeriodicScanCallbacksObj);
mPeriodicScanCallbacksObj = NULL;
}
@@ -2524,7 +2513,7 @@ static void gattTestNative(JNIEnv* env, jobject /* object */, jint command,
static void distanceMeasurementInitializeNative(JNIEnv* env, jobject object) {
std::unique_lock lock(callbacks_mutex);
if (mDistanceMeasurementCallbacksObj != NULL) {
- ALOGW("Cleaning up Advertise callback object");
+ log::warn("Cleaning up Advertise callback object");
env->DeleteGlobalRef(mDistanceMeasurementCallbacksObj);
mDistanceMeasurementCallbacksObj = NULL;
}
@@ -2542,11 +2531,11 @@ static void distanceMeasurementCleanupNative(JNIEnv* env,
}
static void startDistanceMeasurementNative(JNIEnv* env, jobject /* object */,
- jstring address, jint frequency,
+ jstring address, jint interval,
jint method) {
if (!sGattIf) return;
sGattIf->distance_measurement_manager->StartDistanceMeasurement(
- str2addr(env, address), frequency, method);
+ str2addr(env, address), interval, method);
}
static void stopDistanceMeasurementNative(JNIEnv* env, jobject /* object */,
@@ -2589,7 +2578,7 @@ static int register_com_android_bluetooth_gatt_scan(JNIEnv* env) {
{"gattClientScanFilterParamClearAllNative", "(I)V",
(void*)gattClientScanFilterParamClearAllNative},
{"gattClientScanFilterAddNative",
- "(I[Lcom/android/bluetooth/gatt/ScanFilterQueue$Entry;I)V",
+ "(I[Lcom/android/bluetooth/le_scan/ScanFilterQueue$Entry;I)V",
(void*)gattClientScanFilterAddNative},
{"gattClientScanFilterClearNative", "(II)V",
(void*)gattClientScanFilterClearNative},
@@ -2599,7 +2588,7 @@ static int register_com_android_bluetooth_gatt_scan(JNIEnv* env) {
(void*)gattSetScanParametersNative},
};
return REGISTER_NATIVE_METHODS(
- env, "com/android/bluetooth/gatt/ScanNativeInterface", methods);
+ env, "com/android/bluetooth/le_scan/ScanNativeInterface", methods);
}
static int register_com_android_bluetooth_gatt_advertise_manager(JNIEnv* env) {
@@ -2669,7 +2658,7 @@ static int register_com_android_bluetooth_gatt_periodic_scan(JNIEnv* env) {
(void*)transferSetInfoNative},
};
const int result = REGISTER_NATIVE_METHODS(
- env, "com/android/bluetooth/gatt/PeriodicScanNativeInterface", methods);
+ env, "com/android/bluetooth/le_scan/PeriodicScanNativeInterface", methods);
if (result != 0) {
return result;
}
@@ -2683,7 +2672,7 @@ static int register_com_android_bluetooth_gatt_periodic_scan(JNIEnv* env) {
{"onBigInfoReport", "(IZ)V", &method_onBigInfoReport},
};
GET_JAVA_METHODS(env,
- "com/android/bluetooth/gatt/PeriodicScanNativeInterface",
+ "com/android/bluetooth/le_scan/PeriodicScanNativeInterface",
javaMethods);
return 0;
diff --git a/android/app/jni/com_android_bluetooth_hap_client.cpp b/android/app/jni/com_android_bluetooth_hap_client.cpp
index 067af34197bc08cf735b2ba8cd668da87a20c561..148a6e29e2d00136def7d851d3dae65ad5982355 100644
--- a/android/app/jni/com_android_bluetooth_hap_client.cpp
+++ b/android/app/jni/com_android_bluetooth_hap_client.cpp
@@ -73,7 +73,7 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
void OnConnectionState(ConnectionState state,
const RawAddress& bd_addr) override {
- LOG(INFO) << __func__;
+ log::info("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -82,7 +82,7 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new bd addr jbyteArray for connection state";
+ log::error("Failed to new bd addr jbyteArray for connection state");
return;
}
@@ -100,7 +100,7 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new bd addr jbyteArray for device available";
+ log::error("Failed to new bd addr jbyteArray for device available");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -118,7 +118,7 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new bd addr jbyteArray for device available";
+ log::error("Failed to new bd addr jbyteArray for device available");
return;
}
sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
@@ -138,7 +138,7 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new bd addr jbyteArray for preset selected";
+ log::error("Failed to new bd addr jbyteArray for preset selected");
return;
}
sCallbackEnv->SetByteArrayRegion(
@@ -164,8 +164,7 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR)
- << "Failed to new bd addr jbyteArray for preset select error";
+ log::error("Failed to new bd addr jbyteArray for preset select error");
return;
}
sCallbackEnv->SetByteArrayRegion(
@@ -198,14 +197,14 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
for (auto const& info : detail_records) {
const char* name = info.preset_name.c_str();
if (!sCallbackEnv.isValidUtf(name)) {
- ALOGE("%s: name is not a valid UTF string.", __func__);
+ log::error("name is not a valid UTF string.");
name = null_str;
}
ScopedLocalRef name_str(sCallbackEnv.get(),
sCallbackEnv->NewStringUTF(name));
if (!name_str.get()) {
- LOG(ERROR) << "Failed to new preset name String for preset name";
+ log::error("Failed to new preset name String for preset name");
return;
}
@@ -222,7 +221,7 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new bd addr jbyteArray for preset name";
+ log::error("Failed to new bd addr jbyteArray for preset name");
return;
}
sCallbackEnv->SetByteArrayRegion(
@@ -250,8 +249,8 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR)
- << "Failed to new bd addr jbyteArray for preset name get error";
+ log::error(
+ "Failed to new bd addr jbyteArray for preset name get error");
return;
}
sCallbackEnv->SetByteArrayRegion(
@@ -279,8 +278,8 @@ class HasClientCallbacksImpl : public HasClientCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR)
- << "Failed to new bd addr jbyteArray for preset name set error";
+ log::error(
+ "Failed to new bd addr jbyteArray for preset name set error");
return;
}
sCallbackEnv->SetByteArrayRegion(
@@ -307,40 +306,40 @@ static void initNative(JNIEnv* env, jobject object) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
if (sHasClientInterface != nullptr) {
- LOG(INFO) << "Cleaning up HearingAid Interface before initializing...";
+ log::info("Cleaning up HearingAid Interface before initializing...");
sHasClientInterface->Cleanup();
sHasClientInterface = nullptr;
}
if (mCallbacksObj != nullptr) {
- LOG(INFO) << "Cleaning up HearingAid callback object";
+ log::info("Cleaning up HearingAid callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = nullptr;
}
if ((mCallbacksObj = env->NewGlobalRef(object)) == nullptr) {
- LOG(ERROR) << "Failed to allocate Global Ref for Hearing Access Callbacks";
+ log::error("Failed to allocate Global Ref for Hearing Access Callbacks");
return;
}
android_bluetooth_BluetoothHapPresetInfo.clazz = (jclass)env->NewGlobalRef(
env->FindClass("android/bluetooth/BluetoothHapPresetInfo"));
if (android_bluetooth_BluetoothHapPresetInfo.clazz == nullptr) {
- ALOGE("%s: Failed to allocate Global Ref for BluetoothHapPresetInfo class",
- __func__);
+ log::error(
+ "Failed to allocate Global Ref for BluetoothHapPresetInfo class");
return;
}
sHasClientInterface = (HasClientInterface*)btInf->get_profile_interface(
BT_PROFILE_HAP_CLIENT_ID);
if (sHasClientInterface == nullptr) {
- LOG(ERROR)
- << "Failed to get Bluetooth Hearing Access Service Client Interface";
+ log::error(
+ "Failed to get Bluetooth Hearing Access Service Client Interface");
return;
}
@@ -353,7 +352,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
@@ -372,7 +371,7 @@ static jboolean connectHapClientNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return JNI_FALSE;
}
@@ -392,7 +391,7 @@ static jboolean disconnectHapClientNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return JNI_FALSE;
}
@@ -412,7 +411,7 @@ static void selectActivePresetNative(JNIEnv* env, jobject /* object */,
jbyteArray address, jint preset_index) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return;
}
@@ -432,7 +431,7 @@ static void groupSelectActivePresetNative(JNIEnv* /* env */,
jint preset_index) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return;
}
@@ -443,7 +442,7 @@ static void nextActivePresetNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return;
}
@@ -462,7 +461,7 @@ static void groupNextActivePresetNative(JNIEnv* /* env */, jobject /* object */,
jint group_id) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return;
}
@@ -473,7 +472,7 @@ static void previousActivePresetNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return;
}
@@ -493,7 +492,7 @@ static void groupPreviousActivePresetNative(JNIEnv* /* env */,
jint group_id) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return;
}
@@ -504,7 +503,7 @@ static void getPresetInfoNative(JNIEnv* env, jobject /* object */,
jbyteArray address, jint preset_index) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return;
}
@@ -524,7 +523,7 @@ static void setPresetNameNative(JNIEnv* env, jobject /* object */,
jstring name) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return;
}
@@ -552,7 +551,7 @@ static void groupSetPresetNameNative(JNIEnv* env, jobject /* object */,
jstring name) {
std::shared_lock lock(interface_mutex);
if (!sHasClientInterface) {
- LOG(ERROR) << __func__ << ": Failed to get the Bluetooth HAP Interface";
+ log::error("Failed to get the Bluetooth HAP Interface");
return;
}
diff --git a/android/app/jni/com_android_bluetooth_hearing_aid.cpp b/android/app/jni/com_android_bluetooth_hearing_aid.cpp
index 648ff8d1d1d87ca56795a71ae49f22f0b92b8ac0..6ccee327ea75365c9ec53287c8305907d84ff99c 100644
--- a/android/app/jni/com_android_bluetooth_hearing_aid.cpp
+++ b/android/app/jni/com_android_bluetooth_hearing_aid.cpp
@@ -42,7 +42,7 @@ class HearingAidCallbacksImpl : public HearingAidCallbacks {
~HearingAidCallbacksImpl() = default;
void OnConnectionState(ConnectionState state,
const RawAddress& bd_addr) override {
- LOG(INFO) << __func__;
+ log::info("");
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -51,7 +51,7 @@ class HearingAidCallbacksImpl : public HearingAidCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new jbyteArray bd addr for connection state";
+ log::error("Failed to new jbyteArray bd addr for connection state");
return;
}
@@ -63,8 +63,7 @@ class HearingAidCallbacksImpl : public HearingAidCallbacks {
void OnDeviceAvailable(uint8_t capabilities, uint64_t hi_sync_id,
const RawAddress& bd_addr) override {
- LOG(INFO) << __func__ << ": capabilities=" << +capabilities
- << " hi_sync_id=" << hi_sync_id;
+ log::info("capabilities={} hi_sync_id={}", +capabilities, hi_sync_id);
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -73,7 +72,7 @@ class HearingAidCallbacksImpl : public HearingAidCallbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- LOG(ERROR) << "Failed to new jbyteArray bd addr for connection state";
+ log::error("Failed to new jbyteArray bd addr for connection state");
return;
}
@@ -93,31 +92,31 @@ static void initNative(JNIEnv* env, jobject object) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
if (sHearingAidInterface != nullptr) {
- LOG(INFO) << "Cleaning up HearingAid Interface before initializing...";
+ log::info("Cleaning up HearingAid Interface before initializing...");
sHearingAidInterface->Cleanup();
sHearingAidInterface = nullptr;
}
if (mCallbacksObj != nullptr) {
- LOG(INFO) << "Cleaning up HearingAid callback object";
+ log::info("Cleaning up HearingAid callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = nullptr;
}
if ((mCallbacksObj = env->NewGlobalRef(object)) == nullptr) {
- LOG(ERROR) << "Failed to allocate Global Ref for Hearing Aid Callbacks";
+ log::error("Failed to allocate Global Ref for Hearing Aid Callbacks");
return;
}
sHearingAidInterface = (HearingAidInterface*)btInf->get_profile_interface(
BT_PROFILE_HEARING_AID_ID);
if (sHearingAidInterface == nullptr) {
- LOG(ERROR) << "Failed to get Bluetooth Hearing Aid Interface";
+ log::error("Failed to get Bluetooth Hearing Aid Interface");
return;
}
@@ -130,7 +129,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == nullptr) {
- LOG(ERROR) << "Bluetooth module is not loaded";
+ log::error("Bluetooth module is not loaded");
return;
}
@@ -147,7 +146,7 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
static jboolean connectHearingAidNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
- LOG(INFO) << __func__;
+ log::info("");
std::shared_lock lock(interface_mutex);
if (!sHearingAidInterface) return JNI_FALSE;
@@ -165,7 +164,7 @@ static jboolean connectHearingAidNative(JNIEnv* env, jobject /* object */,
static jboolean disconnectHearingAidNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
- LOG(INFO) << __func__;
+ log::info("");
std::shared_lock lock(interface_mutex);
if (!sHearingAidInterface) return JNI_FALSE;
@@ -200,8 +199,7 @@ static jboolean addToAcceptlistNative(JNIEnv* env, jobject /* object */,
static void setVolumeNative(JNIEnv* /* env */, jclass /* clazz */,
jint volume) {
if (!sHearingAidInterface) {
- LOG(ERROR) << __func__
- << ": Failed to get the Bluetooth Hearing Aid Interface";
+ log::error("Failed to get the Bluetooth Hearing Aid Interface");
return;
}
sHearingAidInterface->SetVolume(volume);
diff --git a/android/app/jni/com_android_bluetooth_hfp.cpp b/android/app/jni/com_android_bluetooth_hfp.cpp
index d33669f49150ef7743d6e2e85c023cf08b4eafb7..beea022c679be57a8bd97e387af8e05a6cd4ee65 100644
--- a/android/app/jni/com_android_bluetooth_hfp.cpp
+++ b/android/app/jni/com_android_bluetooth_hfp.cpp
@@ -61,7 +61,7 @@ static jbyteArray marshall_bda(RawAddress* bd_addr) {
jbyteArray addr = sCallbackEnv->NewByteArray(sizeof(RawAddress));
if (!addr) {
- ALOGE("Fail to new jbyteArray bd addr");
+ log::error("Fail to new jbyteArray bd addr");
return nullptr;
}
sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(RawAddress),
@@ -79,7 +79,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
void ConnectionStateCallback(
bluetooth::headset::bthf_connection_state_t state,
RawAddress* bd_addr) override {
- ALOGI("%s %d for %s", __func__, state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr));
+ log::info("{} for {}", state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr));
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -94,7 +94,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
void AudioStateCallback(bluetooth::headset::bthf_audio_state_t state,
RawAddress* bd_addr) override {
- ALOGI("%s, %d for %s", __func__, state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr));
+ log::info("{} for {}", state, ADDRESS_TO_LOGGABLE_CSTR(*bd_addr));
std::shared_lock lock(callbacks_mutex);
CallbackEnv sCallbackEnv(__func__);
@@ -115,7 +115,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -130,7 +130,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -145,7 +145,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -161,7 +161,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -176,13 +176,13 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
char null_str[] = "";
if (!sCallbackEnv.isValidUtf(number)) {
- ALOGE("%s: number is not a valid UTF string.", __func__);
+ log::error("number is not a valid UTF string.");
number = null_str;
}
@@ -199,7 +199,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -216,7 +216,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onNoiseReductionEnable,
@@ -260,7 +260,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(
sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -277,7 +277,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -291,7 +291,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -305,7 +305,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -319,7 +319,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -333,13 +333,13 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
char null_str[] = "";
if (!sCallbackEnv.isValidUtf(at_string)) {
- ALOGE("%s: at_string is not a valid UTF string.", __func__);
+ log::error("at_string is not a valid UTF string.");
at_string = null_str;
}
@@ -356,7 +356,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
+ log::error("Fail to new jbyteArray bd addr for audio state");
return;
}
@@ -374,7 +374,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
char null_str[] = "";
if (!sCallbackEnv.isValidUtf(at_string)) {
- ALOGE("%s: at_string is not a valid UTF string.", __func__);
+ log::error("at_string is not a valid UTF string.");
at_string = null_str;
}
@@ -417,7 +417,7 @@ class JniHeadsetCallbacks : bluetooth::headset::Callbacks {
uint64_t /* end_ts */,
const char* /* pkt_status_in_hex */,
const char* /* pkt_status_in_binary */) override {
- ALOGE("Not implemented and shouldn't be called");
+ log::error("Not implemented and shouldn't be called");
}
};
@@ -428,20 +428,19 @@ static void initializeNative(JNIEnv* env, jobject object, jint max_hf_clients,
const bt_interface_t* btInf = getBluetoothInterface();
if (!btInf) {
- ALOGE("%s: Bluetooth module is not loaded", __func__);
+ log::error("Bluetooth module is not loaded");
jniThrowIOException(env, EINVAL);
return;
}
if (sBluetoothHfpInterface) {
- ALOGI("%s: Cleaning up Bluetooth Handsfree Interface before initializing",
- __func__);
+ log::info("Cleaning up Bluetooth Handsfree Interface before initializing");
sBluetoothHfpInterface->Cleanup();
sBluetoothHfpInterface = nullptr;
}
if (mCallbacksObj) {
- ALOGI("%s: Cleaning up Bluetooth Handsfree callback object", __func__);
+ log::info("Cleaning up Bluetooth Handsfree callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = nullptr;
}
@@ -450,7 +449,7 @@ static void initializeNative(JNIEnv* env, jobject object, jint max_hf_clients,
(bluetooth::headset::Interface*)btInf->get_profile_interface(
BT_PROFILE_HANDSFREE_ID);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: Failed to get Bluetooth Handsfree Interface", __func__);
+ log::warn("Failed to get Bluetooth Handsfree Interface");
jniThrowIOException(env, EINVAL);
return;
}
@@ -458,8 +457,8 @@ static void initializeNative(JNIEnv* env, jobject object, jint max_hf_clients,
sBluetoothHfpInterface->Init(JniHeadsetCallbacks::GetInstance(),
max_hf_clients, inband_ringing_enabled);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Failed to initialize Bluetooth Handsfree Interface, status: %d",
- __func__, status);
+ log::error("Failed to initialize Bluetooth Handsfree Interface, status: {}",
+ bt_status_text(status));
sBluetoothHfpInterface = nullptr;
return;
}
@@ -473,18 +472,18 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (!btInf) {
- ALOGW("%s: Bluetooth module is not loaded", __func__);
+ log::warn("Bluetooth module is not loaded");
return;
}
if (sBluetoothHfpInterface) {
- ALOGI("%s: Cleaning up Bluetooth Handsfree Interface", __func__);
+ log::info("Cleaning up Bluetooth Handsfree Interface");
sBluetoothHfpInterface->Cleanup();
sBluetoothHfpInterface = nullptr;
}
if (mCallbacksObj) {
- ALOGI("%s: Cleaning up Bluetooth Handsfree callback object", __func__);
+ log::info("Cleaning up Bluetooth Handsfree callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = nullptr;
}
@@ -494,20 +493,19 @@ static jboolean connectHfpNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
- ALOGI("%s: device %s", __func__,
- ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
+ log::info("device {}", ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
bt_status_t status = sBluetoothHfpInterface->Connect((RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed HF connection, status: %d", status);
+ log::error("Failed HF connection, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -517,20 +515,19 @@ static jboolean disconnectHfpNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
- ALOGI("%s: device %s", __func__,
- ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
+ log::info("device {}", ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
bt_status_t status = sBluetoothHfpInterface->Disconnect((RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed HF disconnection, status: %d", status);
+ log::error("Failed HF disconnection, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -540,21 +537,21 @@ static jboolean connectAudioNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
- ALOGI("%s: device %s", __func__,
- ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
+ log::info("device {}", ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
bt_status_t status =
sBluetoothHfpInterface->ConnectAudio((RawAddress*)addr, 0);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed HF audio connection, status: %d", status);
+ log::error("Failed HF audio connection, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -564,21 +561,21 @@ static jboolean disconnectAudioNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
- ALOGI("%s: device %s", __func__,
- ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
+ log::info("device {}", ADDRESS_TO_LOGGABLE_CSTR(*((RawAddress*)addr)));
bt_status_t status =
sBluetoothHfpInterface->DisconnectAudio((RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed HF audio disconnection, status: %d", status);
+ log::error("Failed HF audio disconnection, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -589,12 +586,12 @@ static jboolean isNoiseReductionSupportedNative(JNIEnv* env,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -609,12 +606,12 @@ static jboolean isVoiceRecognitionSupportedNative(JNIEnv* env,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -628,19 +625,20 @@ static jboolean startVoiceRecognitionNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
bt_status_t status =
sBluetoothHfpInterface->StartVoiceRecognition((RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to start voice recognition, status: %d", status);
+ log::error("Failed to start voice recognition, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -650,19 +648,20 @@ static jboolean stopVoiceRecognitionNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
bt_status_t status =
sBluetoothHfpInterface->StopVoiceRecognition((RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to stop voice recognition, status: %d", status);
+ log::error("Failed to stop voice recognition, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -673,12 +672,12 @@ static jboolean setVolumeNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -686,7 +685,7 @@ static jboolean setVolumeNative(JNIEnv* env, jobject /* object */,
(bluetooth::headset::bthf_volume_type_t)volume_type, volume,
(RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("FAILED to control volume, status: %d", status);
+ log::error("FAILED to control volume, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -698,12 +697,12 @@ static jboolean notifyDeviceStatusNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -713,7 +712,8 @@ static jboolean notifyDeviceStatusNative(JNIEnv* env, jobject /* object */,
battery_charge, (RawAddress*)addr);
env->ReleaseByteArrayElements(address, addr, 0);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("FAILED to notify device status, status: %d", status);
+ log::error("FAILED to notify device status, status: {}",
+ bt_status_text(status));
}
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
@@ -722,12 +722,12 @@ static jboolean copsResponseNative(JNIEnv* env, jobject /* object */,
jstring operator_str, jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -735,7 +735,8 @@ static jboolean copsResponseNative(JNIEnv* env, jobject /* object */,
bt_status_t status =
sBluetoothHfpInterface->CopsResponse(operator_name, (RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending cops response, status: %d", status);
+ log::error("Failed sending cops response, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
env->ReleaseStringUTFChars(operator_str, operator_name);
@@ -748,12 +749,12 @@ static jboolean cindResponseNative(JNIEnv* env, jobject /* object */,
jint battery_charge, jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -762,7 +763,7 @@ static jboolean cindResponseNative(JNIEnv* env, jobject /* object */,
(bluetooth::headset::bthf_call_state_t)call_state, signal, roam,
battery_charge, (RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: failed, status: %d", __func__, status);
+ log::error("failed, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -773,12 +774,12 @@ static jboolean atResponseStringNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -786,7 +787,8 @@ static jboolean atResponseStringNative(JNIEnv* env, jobject /* object */,
bt_status_t status =
sBluetoothHfpInterface->FormattedAtResponse(response, (RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed formatted AT response, status: %d", status);
+ log::error("Failed formatted AT response, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
env->ReleaseStringUTFChars(response_str, response);
@@ -798,12 +800,12 @@ static jboolean atResponseCodeNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -811,7 +813,7 @@ static jboolean atResponseCodeNative(JNIEnv* env, jobject /* object */,
(bluetooth::headset::bthf_at_response_t)response_code, cmee_code,
(RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed AT response, status: %d", status);
+ log::error("Failed AT response, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -823,12 +825,12 @@ static jboolean clccResponseNative(JNIEnv* env, jobject /* object */,
jint type, jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -845,7 +847,8 @@ static jboolean clccResponseNative(JNIEnv* env, jobject /* object */,
number, (bluetooth::headset::bthf_call_addrtype_t)type,
(RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending CLCC response, status: %d", status);
+ log::error("Failed sending CLCC response, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
if (number) {
@@ -861,12 +864,12 @@ static jboolean phoneStateChangeNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, nullptr);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
@@ -880,7 +883,8 @@ static jboolean phoneStateChangeNative(JNIEnv* env, jobject /* object */,
number, (bluetooth::headset::bthf_call_addrtype_t)type, name,
(RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed report phone state change, status: %d", status);
+ log::error("Failed report phone state change, status: {}",
+ bt_status_text(status));
}
env->ReleaseStringUTFChars(number_str, number);
if (name != nullptr) {
@@ -894,12 +898,12 @@ static jboolean setScoAllowedNative(JNIEnv* /* env */, jobject /* object */,
jboolean value) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
bt_status_t status = sBluetoothHfpInterface->SetScoAllowed(value == JNI_TRUE);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed HF set sco allowed, status: %d", status);
+ log::error("Failed HF set sco allowed, status: {}", bt_status_text(status));
}
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
@@ -908,19 +912,20 @@ static jboolean sendBsirNative(JNIEnv* env, jobject /* object */,
jboolean value, jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, NULL);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
bt_status_t status =
sBluetoothHfpInterface->SendBsir(value == JNI_TRUE, (RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed sending BSIR, value=%d, status=%d", value, status);
+ log::error("Failed sending BSIR, value={}, status={}", value,
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -930,19 +935,20 @@ static jboolean setActiveDeviceNative(JNIEnv* env, jobject /* object */,
jbyteArray address) {
std::shared_lock lock(interface_mutex);
if (!sBluetoothHfpInterface) {
- ALOGW("%s: sBluetoothHfpInterface is null", __func__);
+ log::warn("sBluetoothHfpInterface is null");
return JNI_FALSE;
}
jbyte* addr = env->GetByteArrayElements(address, NULL);
if (!addr) {
- ALOGE("%s: failed to get device address", __func__);
+ log::error("failed to get device address");
jniThrowIOException(env, EINVAL);
return JNI_FALSE;
}
bt_status_t status =
sBluetoothHfpInterface->SetActiveDevice((RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to set active device, status: %d", status);
+ log::error("Failed to set active device, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
diff --git a/android/app/jni/com_android_bluetooth_hfpclient.cpp b/android/app/jni/com_android_bluetooth_hfpclient.cpp
index b5d5910372fc1e2bc30c483d4148d6d1ee48b3c2..f51255bf6e97c680b63b360b472ca077a424d53c 100644
--- a/android/app/jni/com_android_bluetooth_hfpclient.cpp
+++ b/android/app/jni/com_android_bluetooth_hfpclient.cpp
@@ -17,11 +17,11 @@
#define LOG_TAG "BluetoothHeadsetClientServiceJni"
+#include
+
#include "com_android_bluetooth.h"
#include "hardware/bt_hf_client.h"
-#include "utils/Log.h"
-
-#include
+#include "os/logging/log_adapter.h"
namespace android {
@@ -60,7 +60,7 @@ static jbyteArray marshall_bda(const RawAddress* bd_addr) {
jbyteArray addr = sCallbackEnv->NewByteArray(sizeof(RawAddress));
if (!addr) {
- ALOGE("Fail to new jbyteArray bd addr");
+ log::error("Fail to new jbyteArray bd addr");
return NULL;
}
sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(RawAddress),
@@ -79,7 +79,7 @@ static void connection_state_cb(const RawAddress* bd_addr,
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) return;
- ALOGD("%s: state %d peer_feat %d chld_feat %d", __func__, state, peer_feat, chld_feat);
+ log::debug("state {} peer_feat {} chld_feat {}", state, peer_feat, chld_feat);
sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onConnectionStateChanged,
(jint)state, (jint)peer_feat, (jint)chld_feat,
addr.get());
@@ -170,7 +170,7 @@ static void current_operator_cb(const RawAddress* bd_addr, const char* name) {
const char null_str[] = "";
if (!sCallbackEnv.isValidUtf(name)) {
- ALOGE("%s: name is not a valid UTF string.", __func__);
+ log::error("name is not a valid UTF string.");
name = null_str;
}
@@ -201,9 +201,7 @@ static void callsetup_cb(const RawAddress* bd_addr,
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) return;
- ALOGD("callsetup_cb bdaddr %02x:%02x:%02x:%02x:%02x:%02x",
- bd_addr->address[0], bd_addr->address[1], bd_addr->address[2],
- bd_addr->address[3], bd_addr->address[4], bd_addr->address[5]);
+ log::debug("callsetup_cb bdaddr {}", ADDRESS_TO_LOGGABLE_STR(*bd_addr));
sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCallSetup,
(jint)callsetup, addr.get());
@@ -245,7 +243,7 @@ static void clip_cb(const RawAddress* bd_addr, const char* number) {
const char null_str[] = "";
if (!sCallbackEnv.isValidUtf(number)) {
- ALOGE("%s: number is not a valid UTF string.", __func__);
+ log::error("number is not a valid UTF string.");
number = null_str;
}
@@ -265,7 +263,7 @@ static void call_waiting_cb(const RawAddress* bd_addr, const char* number) {
const char null_str[] = "";
if (!sCallbackEnv.isValidUtf(number)) {
- ALOGE("%s: number is not a valid UTF string.", __func__);
+ log::error("number is not a valid UTF string.");
number = null_str;
}
@@ -289,7 +287,7 @@ static void current_calls_cb(const RawAddress* bd_addr, int index,
const char null_str[] = "";
if (!sCallbackEnv.isValidUtf(number)) {
- ALOGE("%s: number is not a valid UTF string.", __func__);
+ log::error("number is not a valid UTF string.");
number = null_str;
}
@@ -334,7 +332,7 @@ static void subscriber_info_cb(const RawAddress* bd_addr, const char* name,
const char null_str[] = "";
if (!sCallbackEnv.isValidUtf(name)) {
- ALOGE("%s: name is not a valid UTF string.", __func__);
+ log::error("name is not a valid UTF string.");
name = null_str;
}
@@ -367,7 +365,7 @@ static void last_voice_tag_number_cb(const RawAddress* bd_addr,
const char null_str[] = "";
if (!sCallbackEnv.isValidUtf(number)) {
- ALOGE("%s: number is not a valid UTF string.", __func__);
+ log::error("number is not a valid UTF string.");
number = null_str;
}
@@ -430,24 +428,24 @@ static bthf_client_callbacks_t sBluetoothHfpClientCallbacks = {
};
static void initializeNative(JNIEnv* env, jobject object) {
- ALOGD("%s: HfpClient", __func__);
+ log::debug("HfpClient");
std::unique_lock interface_lock(interface_mutex);
std::unique_lock callbacks_lock(callbacks_mutex);
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == NULL) {
- ALOGE("Bluetooth module is not loaded");
+ log::error("Bluetooth module is not loaded");
return;
}
if (sBluetoothHfpClientInterface != NULL) {
- ALOGW("Cleaning up Bluetooth HFP Client Interface before initializing");
+ log::warn("Cleaning up Bluetooth HFP Client Interface before initializing");
sBluetoothHfpClientInterface->cleanup();
sBluetoothHfpClientInterface = NULL;
}
if (mCallbacksObj != NULL) {
- ALOGW("Cleaning up Bluetooth HFP Client callback object");
+ log::warn("Cleaning up Bluetooth HFP Client callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = NULL;
}
@@ -456,14 +454,15 @@ static void initializeNative(JNIEnv* env, jobject object) {
(bthf_client_interface_t*)btInf->get_profile_interface(
BT_PROFILE_HANDSFREE_CLIENT_ID);
if (sBluetoothHfpClientInterface == NULL) {
- ALOGE("Failed to get Bluetooth HFP Client Interface");
+ log::error("Failed to get Bluetooth HFP Client Interface");
return;
}
bt_status_t status =
sBluetoothHfpClientInterface->init(&sBluetoothHfpClientCallbacks);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to initialize Bluetooth HFP Client, status: %d", status);
+ log::error("Failed to initialize Bluetooth HFP Client, status: {}",
+ bt_status_text(status));
sBluetoothHfpClientInterface = NULL;
return;
}
@@ -477,18 +476,18 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == NULL) {
- ALOGE("Bluetooth module is not loaded");
+ log::error("Bluetooth module is not loaded");
return;
}
if (sBluetoothHfpClientInterface != NULL) {
- ALOGW("Cleaning up Bluetooth HFP Client Interface...");
+ log::warn("Cleaning up Bluetooth HFP Client Interface...");
sBluetoothHfpClientInterface->cleanup();
sBluetoothHfpClientInterface = NULL;
}
if (mCallbacksObj != NULL) {
- ALOGW("Cleaning up Bluetooth HFP Client callback object");
+ log::warn("Cleaning up Bluetooth HFP Client callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = NULL;
}
@@ -508,7 +507,7 @@ static jboolean connectNative(JNIEnv* env, jobject /* object */,
bt_status_t status =
sBluetoothHfpClientInterface->connect((const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed AG connection, status: %d", status);
+ log::error("Failed AG connection, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -528,7 +527,7 @@ static jboolean disconnectNative(JNIEnv* env, jobject /* object */,
bt_status_t status =
sBluetoothHfpClientInterface->disconnect((const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed AG disconnection, status: %d", status);
+ log::error("Failed AG disconnection, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -548,7 +547,8 @@ static jboolean connectAudioNative(JNIEnv* env, jobject /* object */,
bt_status_t status =
sBluetoothHfpClientInterface->connect_audio((const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed AG audio connection, status: %d", status);
+ log::error("Failed AG audio connection, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -568,7 +568,8 @@ static jboolean disconnectAudioNative(JNIEnv* env, jobject /* object */,
bt_status_t status =
sBluetoothHfpClientInterface->disconnect_audio((const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed AG audio disconnection, status: %d", status);
+ log::error("Failed AG audio disconnection, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -588,7 +589,8 @@ static jboolean startVoiceRecognitionNative(JNIEnv* env, jobject /* object */,
bt_status_t status = sBluetoothHfpClientInterface->start_voice_recognition(
(const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to start voice recognition, status: %d", status);
+ log::error("Failed to start voice recognition, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -608,7 +610,8 @@ static jboolean stopVoiceRecognitionNative(JNIEnv* env, jobject /* object */,
bt_status_t status = sBluetoothHfpClientInterface->stop_voice_recognition(
(const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to stop voice recognition, status: %d", status);
+ log::error("Failed to stop voice recognition, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -629,7 +632,7 @@ static jboolean setVolumeNative(JNIEnv* env, jobject /* object */,
bt_status_t status = sBluetoothHfpClientInterface->volume_control(
(const RawAddress*)addr, (bthf_client_volume_type_t)volume_type, volume);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("FAILED to control volume, status: %d", status);
+ log::error("FAILED to control volume, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -655,7 +658,7 @@ static jboolean dialNative(JNIEnv* env, jobject /* object */,
number == nullptr ? "" : number);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to dial, status: %d", status);
+ log::error("Failed to dial, status: {}", bt_status_text(status));
}
if (number != nullptr) {
env->ReleaseStringUTFChars(number_str, number);
@@ -678,7 +681,8 @@ static jboolean dialMemoryNative(JNIEnv* env, jobject /* object */,
bt_status_t status = sBluetoothHfpClientInterface->dial_memory(
(const RawAddress*)addr, (int)location);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to dial from memory, status: %d", status);
+ log::error("Failed to dial from memory, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
@@ -701,7 +705,8 @@ static jboolean handleCallActionNative(JNIEnv* env, jobject /* object */,
(const RawAddress*)addr, (bthf_client_call_action_t)action, (int)index);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to enter private mode, status: %d", status);
+ log::error("Failed to enter private mode, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -722,7 +727,8 @@ static jboolean queryCurrentCallsNative(JNIEnv* env, jobject /* object */,
(const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to query current calls, status: %d", status);
+ log::error("Failed to query current calls, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
@@ -744,7 +750,8 @@ static jboolean queryCurrentOperatorNameNative(JNIEnv* env,
sBluetoothHfpClientInterface->query_current_operator_name(
(const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to query current operator name, status: %d", status);
+ log::error("Failed to query current operator name, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
@@ -765,7 +772,8 @@ static jboolean retrieveSubscriberInfoNative(JNIEnv* env, jobject /* object */,
bt_status_t status = sBluetoothHfpClientInterface->retrieve_subscriber_info(
(const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to retrieve subscriber info, status: %d", status);
+ log::error("Failed to retrieve subscriber info, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
@@ -786,7 +794,7 @@ static jboolean sendDtmfNative(JNIEnv* env, jobject /* object */,
bt_status_t status = sBluetoothHfpClientInterface->send_dtmf(
(const RawAddress*)addr, (char)code);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to send DTMF, status: %d", status);
+ log::error("Failed to send DTMF, status: {}", bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
@@ -810,7 +818,8 @@ static jboolean requestLastVoiceTagNumberNative(JNIEnv* env,
(const RawAddress*)addr);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to request last Voice Tag number, status: %d", status);
+ log::error("Failed to request last Voice Tag number, status: {}",
+ bt_status_text(status));
}
env->ReleaseByteArrayElements(address, addr, 0);
@@ -837,7 +846,7 @@ static jboolean sendATCmdNative(JNIEnv* env, jobject /* object */,
(const RawAddress*)addr, cmd, val1, val2, arg);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to send cmd, status: %d", status);
+ log::error("Failed to send cmd, status: {}", bt_status_text(status));
}
if (arg != NULL) {
@@ -868,7 +877,7 @@ static jboolean sendAndroidAtNative(JNIEnv* env, jobject /* object */,
(const RawAddress*)addr, arg);
if (status != BT_STATUS_SUCCESS) {
- ALOGE("FAILED to control volume, status: %d", status);
+ log::error("FAILED to control volume, status: {}", bt_status_text(status));
}
if (arg != NULL) {
diff --git a/android/app/jni/com_android_bluetooth_hid_device.cpp b/android/app/jni/com_android_bluetooth_hid_device.cpp
index 4a7c1553e1f45799ad12ac5b4f1e332909222302..e4cff153af6d3cff9c76a2fdf6a466ee46eede01 100644
--- a/android/app/jni/com_android_bluetooth_hid_device.cpp
+++ b/android/app/jni/com_android_bluetooth_hid_device.cpp
@@ -41,7 +41,7 @@ static jbyteArray marshall_bda(RawAddress* bd_addr) {
jbyteArray addr = sCallbackEnv->NewByteArray(sizeof(RawAddress));
if (!addr) {
- ALOGE("Fail to new jbyteArray bd addr");
+ log::error("Fail to new jbyteArray bd addr");
return NULL;
}
sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(RawAddress),
@@ -64,7 +64,7 @@ static void application_state_callback(RawAddress* bd_addr,
if (bd_addr) {
addr.reset(marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("%s: failed to allocate storage for bt_addr", __FUNCTION__);
+ log::error("failed to allocate storage for bt_addr");
return;
}
}
@@ -79,7 +79,7 @@ static void connection_state_callback(RawAddress* bd_addr,
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("%s: failed to allocate storage for bt_addr", __FUNCTION__);
+ log::error("failed to allocate storage for bt_addr");
return;
}
@@ -102,7 +102,7 @@ static void set_report_callback(uint8_t type, uint8_t id, uint16_t len,
ScopedLocalRef data(sCallbackEnv.get(),
sCallbackEnv->NewByteArray(len));
if (!data.get()) {
- ALOGE("%s: failed to allocate storage for report data", __FUNCTION__);
+ log::error("failed to allocate storage for report data");
return;
}
sCallbackEnv->SetByteArrayRegion(data.get(), 0, len, (jbyte*)p_data);
@@ -124,7 +124,7 @@ static void intr_data_callback(uint8_t report_id, uint16_t len,
ScopedLocalRef data(sCallbackEnv.get(),
sCallbackEnv->NewByteArray(len));
if (!data.get()) {
- ALOGE("%s: failed to allocate storage for report data", __FUNCTION__);
+ log::error("failed to allocate storage for report data");
return;
}
sCallbackEnv->SetByteArrayRegion(data.get(), 0, len, (jbyte*)p_data);
@@ -154,58 +154,58 @@ static void initNative(JNIEnv* env, jobject object) {
const bt_interface_t* btif;
bt_status_t status;
- ALOGV("%s enter", __FUNCTION__);
+ log::verbose("enter");
if ((btif = getBluetoothInterface()) == NULL) {
- ALOGE("Cannot obtain BT interface");
+ log::error("Cannot obtain BT interface");
return;
}
if (sHiddIf != NULL) {
- ALOGW("Cleaning up interface");
+ log::warn("Cleaning up interface");
sHiddIf->cleanup();
sHiddIf = NULL;
}
if (mCallbacksObj != NULL) {
- ALOGW("Cleaning up callback object");
+ log::warn("Cleaning up callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = NULL;
}
if ((sHiddIf = (bthd_interface_t*)btif->get_profile_interface(
BT_PROFILE_HIDDEV_ID)) == NULL) {
- ALOGE("Cannot obtain interface");
+ log::error("Cannot obtain interface");
return;
}
if ((status = sHiddIf->init(&sHiddCb)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to initialize interface (%d)", status);
+ log::error("Failed to initialize interface ({})", bt_status_text(status));
sHiddIf = NULL;
return;
}
mCallbacksObj = env->NewGlobalRef(object);
- ALOGV("%s done", __FUNCTION__);
+ log::verbose("done");
}
static void cleanupNative(JNIEnv* env, jobject /* object */) {
- ALOGV("%s enter", __FUNCTION__);
+ log::verbose("enter");
if (sHiddIf != NULL) {
- ALOGI("Cleaning up interface");
+ log::info("Cleaning up interface");
sHiddIf->cleanup();
sHiddIf = NULL;
}
if (mCallbacksObj != NULL) {
- ALOGI("Cleaning up callback object");
+ log::info("Cleaning up callback object");
env->DeleteGlobalRef(mCallbacksObj);
mCallbacksObj = NULL;
}
- ALOGV("%s done", __FUNCTION__);
+ log::verbose("done");
}
static void fill_qos(JNIEnv* env, jintArray in, bthd_qos_param_t* out) {
@@ -241,10 +241,10 @@ static jboolean registerAppNative(JNIEnv* env, jobject /* thiz */, jstring name,
jstring description, jstring provider,
jbyte subclass, jbyteArray descriptors,
jintArray p_in_qos, jintArray p_out_qos) {
- ALOGV("%s enter", __FUNCTION__);
+ log::verbose("enter");
if (!sHiddIf) {
- ALOGE("%s: Failed to get the Bluetooth HIDD Interface", __func__);
+ log::error("Failed to get the Bluetooth HIDD Interface");
return JNI_FALSE;
}
@@ -273,7 +273,7 @@ static jboolean registerAppNative(JNIEnv* env, jobject /* thiz */, jstring name,
bt_status_t ret = sHiddIf->register_app(&app_param, &in_qos, &out_qos);
- ALOGV("%s: register_app() returned %d", __FUNCTION__, ret);
+ log::verbose("register_app() returned {}", bt_status_text(ret));
if (ret == BT_STATUS_SUCCESS) {
result = JNI_TRUE;
@@ -286,30 +286,30 @@ static jboolean registerAppNative(JNIEnv* env, jobject /* thiz */, jstring name,
free(data);
}
- ALOGV("%s done (%d)", __FUNCTION__, result);
+ log::verbose("done ({})", result);
return result;
}
static jboolean unregisterAppNative(JNIEnv* /* env */, jobject /* thiz */) {
- ALOGV("%s enter", __FUNCTION__);
+ log::verbose("enter");
jboolean result = JNI_FALSE;
if (!sHiddIf) {
- ALOGE("%s: Failed to get the Bluetooth HIDD Interface", __func__);
+ log::error("Failed to get the Bluetooth HIDD Interface");
return JNI_FALSE;
}
bt_status_t ret = sHiddIf->unregister_app();
- ALOGV("%s: unregister_app() returned %d", __FUNCTION__, ret);
+ log::verbose("unregister_app() returned {}", bt_status_text(ret));
if (ret == BT_STATUS_SUCCESS) {
result = JNI_TRUE;
}
- ALOGV("%s done (%d)", __FUNCTION__, result);
+ log::verbose("done ({})", result);
return result;
}
@@ -319,7 +319,7 @@ static jboolean sendReportNative(JNIEnv* env, jobject /* thiz */, jint id,
jboolean result = JNI_FALSE;
if (!sHiddIf) {
- ALOGE("%s: Failed to get the Bluetooth HIDD Interface", __func__);
+ log::error("Failed to get the Bluetooth HIDD Interface");
return JNI_FALSE;
}
@@ -347,10 +347,10 @@ static jboolean sendReportNative(JNIEnv* env, jobject /* thiz */, jint id,
static jboolean replyReportNative(JNIEnv* env, jobject /* thiz */, jbyte type,
jbyte id, jbyteArray data) {
- ALOGV("%s enter", __FUNCTION__);
+ log::verbose("enter");
if (!sHiddIf) {
- ALOGE("%s: Failed to get the Bluetooth HIDD Interface", __func__);
+ log::error("Failed to get the Bluetooth HIDD Interface");
return JNI_FALSE;
}
@@ -368,7 +368,7 @@ static jboolean replyReportNative(JNIEnv* env, jobject /* thiz */, jbyte type,
bt_status_t ret =
sHiddIf->send_report((bthd_report_type_t)report_type, id, size, buf);
- ALOGV("%s: send_report() returned %d", __FUNCTION__, ret);
+ log::verbose("send_report() returned {}", bt_status_text(ret));
if (ret == BT_STATUS_SUCCESS) {
result = JNI_TRUE;
@@ -377,17 +377,17 @@ static jboolean replyReportNative(JNIEnv* env, jobject /* thiz */, jbyte type,
free(buf);
}
- ALOGV("%s done (%d)", __FUNCTION__, result);
+ log::verbose("done ({})", result);
return result;
}
static jboolean reportErrorNative(JNIEnv* /* env */, jobject /* thiz */,
jbyte error) {
- ALOGV("%s enter", __FUNCTION__);
+ log::verbose("enter");
if (!sHiddIf) {
- ALOGE("%s: Failed to get the Bluetooth HIDD Interface", __func__);
+ log::error("Failed to get the Bluetooth HIDD Interface");
return JNI_FALSE;
}
@@ -395,22 +395,22 @@ static jboolean reportErrorNative(JNIEnv* /* env */, jobject /* thiz */,
bt_status_t ret = sHiddIf->report_error(error);
- ALOGV("%s: report_error() returned %d", __FUNCTION__, ret);
+ log::verbose("report_error() returned {}", bt_status_text(ret));
if (ret == BT_STATUS_SUCCESS) {
result = JNI_TRUE;
}
- ALOGV("%s done (%d)", __FUNCTION__, result);
+ log::verbose("done ({})", result);
return result;
}
static jboolean unplugNative(JNIEnv* /* env */, jobject /* thiz */) {
- ALOGV("%s enter", __FUNCTION__);
+ log::verbose("enter");
if (!sHiddIf) {
- ALOGE("%s: Failed to get the Bluetooth HIDD Interface", __func__);
+ log::error("Failed to get the Bluetooth HIDD Interface");
return JNI_FALSE;
}
@@ -418,23 +418,23 @@ static jboolean unplugNative(JNIEnv* /* env */, jobject /* thiz */) {
bt_status_t ret = sHiddIf->virtual_cable_unplug();
- ALOGV("%s: virtual_cable_unplug() returned %d", __FUNCTION__, ret);
+ log::verbose("virtual_cable_unplug() returned {}", bt_status_text(ret));
if (ret == BT_STATUS_SUCCESS) {
result = JNI_TRUE;
}
- ALOGV("%s done (%d)", __FUNCTION__, result);
+ log::verbose("done ({})", result);
return result;
}
static jboolean connectNative(JNIEnv* env, jobject /* thiz */,
jbyteArray address) {
- ALOGV("%s enter", __FUNCTION__);
+ log::verbose("enter");
if (!sHiddIf) {
- ALOGE("%s: Failed to get the Bluetooth HIDD Interface", __func__);
+ log::error("Failed to get the Bluetooth HIDD Interface");
return JNI_FALSE;
}
@@ -442,28 +442,28 @@ static jboolean connectNative(JNIEnv* env, jobject /* thiz */,
jbyte* addr = env->GetByteArrayElements(address, NULL);
if (!addr) {
- ALOGE("Bluetooth device address null");
+ log::error("Bluetooth device address null");
return JNI_FALSE;
}
bt_status_t ret = sHiddIf->connect((RawAddress*)addr);
- ALOGV("%s: connect() returned %d", __FUNCTION__, ret);
+ log::verbose("connect() returned {}", bt_status_text(ret));
if (ret == BT_STATUS_SUCCESS) {
result = JNI_TRUE;
}
- ALOGV("%s done (%d)", __FUNCTION__, result);
+ log::verbose("done ({})", result);
return result;
}
static jboolean disconnectNative(JNIEnv* /* env */, jobject /* thiz */) {
- ALOGV("%s enter", __FUNCTION__);
+ log::verbose("enter");
if (!sHiddIf) {
- ALOGE("%s: Failed to get the Bluetooth HIDD Interface", __func__);
+ log::error("Failed to get the Bluetooth HIDD Interface");
return JNI_FALSE;
}
@@ -471,13 +471,13 @@ static jboolean disconnectNative(JNIEnv* /* env */, jobject /* thiz */) {
bt_status_t ret = sHiddIf->disconnect();
- ALOGV("%s: disconnect() returned %d", __FUNCTION__, ret);
+ log::verbose("disconnect() returned {}", bt_status_text(ret));
if (ret == BT_STATUS_SUCCESS) {
result = JNI_TRUE;
}
- ALOGV("%s done (%d)", __FUNCTION__, result);
+ log::verbose("done ({})", result);
return result;
}
diff --git a/android/app/jni/com_android_bluetooth_hid_host.cpp b/android/app/jni/com_android_bluetooth_hid_host.cpp
index e89ce844c29a069b47dcb90dfb7c7ebdbde3661a..b21fc9c5b5b35f894173c20e7040e064c316e28f 100644
--- a/android/app/jni/com_android_bluetooth_hid_host.cpp
+++ b/android/app/jni/com_android_bluetooth_hid_host.cpp
@@ -41,7 +41,7 @@ static jbyteArray marshall_bda(RawAddress* bd_addr) {
jbyteArray addr = sCallbackEnv->NewByteArray(sizeof(RawAddress));
if (!addr) {
- ALOGE("Fail to new jbyteArray bd addr");
+ log::error("Fail to new jbyteArray bd addr");
return NULL;
}
sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(RawAddress),
@@ -55,12 +55,12 @@ static void connection_state_callback(RawAddress* bd_addr,
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!mCallbacksObj) {
- ALOGE("%s: mCallbacksObj is null", __func__);
+ log::error("mCallbacksObj is null");
return;
}
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for HID channel state");
+ log::error("Fail to new jbyteArray bd addr for HID channel state");
return;
}
@@ -75,17 +75,17 @@ static void get_protocol_mode_callback(RawAddress* bd_addr,
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!mCallbacksObj) {
- ALOGE("%s: mCallbacksObj is null", __func__);
+ log::error("mCallbacksObj is null");
return;
}
if (hh_status != BTHH_OK) {
- ALOGE("BTHH Status is not OK!");
+ log::error("BTHH Status is not OK!");
return;
}
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for get protocal mode callback");
+ log::error("Fail to new jbyteArray bd addr for get protocol mode callback");
return;
}
@@ -99,23 +99,23 @@ static void get_report_callback(RawAddress* bd_addr, bthh_status_t hh_status,
CallbackEnv sCallbackEnv(__func__);
if (!sCallbackEnv.valid()) return;
if (!mCallbacksObj) {
- ALOGE("%s: mCallbacksObj is null", __func__);
+ log::error("mCallbacksObj is null");
return;
}
if (hh_status != BTHH_OK) {
- ALOGE("BTHH Status is not OK!");
+ log::error("BTHH Status is not OK!");
return;
}
ScopedLocalRef addr(sCallbackEnv.get(), marshall_bda(bd_addr));
if (!addr.get()) {
- ALOGE("Fail to new jbyteArray bd addr for get report callback");
+ log::error("Fail to new jbyteArray bd addr for get report callback");
return;
}
ScopedLocalRef