0
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -17,7 +17,7 @@
     <bool name="profile_supported_a2dp_sink">false</bool>
     <bool name="profile_supported_hdp">true</bool>
     <bool name="profile_supported_hs_hfp">true</bool>
-    <bool name="profile_supported_hfpclient">false</bool>
+    <bool name="profile_supported_hfpclient">true</bool>

08-29 14:16:35.703 4697 4697 I crash_dump64:从墓碑获取输出 fd,类型:kDebuggerdTombstone

08-29 14:16:35.704 3147 3147 I /system/bin/tombstoned:收到 pid 3559 的崩溃请求 08-29 14:16:35.704 4697 4697 I crash_dump64:执行进程 3450 的转储(目标 tid = 3559)08- 29 14:16:35.711 3636 3636 D StrictMode:StrictMode 策略违规:android.os.strictmode.InstanceCountViolation:com.android.settings.SubSettings 类;实例=2;限制=1 08-29 14:16:35.711 3636 3636 D StrictMode:在 android.os.StrictMode.setClassInstanceLimit(StrictMode.java:1)

08-29 14:16:35.722 4697 4697 F 调试:


08-29 14:16:35.722 4697 4697 F 调试:构建指纹:'Android/proline_basic_proto3/proline_basic_proto3:9/2.0.0-ga-rc4/root08230119:eng/dev-keys' 08-29 14:16:35.722 4697 4697 F 调试:修订:'0' 08-29 14:16:35.722 4697 4697 F 调试:ABI:'arm64' 08-29 14:16:35.722 4697 4697 F 调试:pid:3450,tid:3559,名称: BT 服务调用 >>> com.android.bluetooth <<< 08-29 14:16:35.723 4697 4697 F DEBUG:信号 6 (SIGABRT),代码 -6 (SI_TKILL),故障地址 --------

08-29 14:16:35.723 4697 4697 F 调试:中止消息:'java_vm_ext.cc:542] JNI 检测到应用程序错误:无法调用 void com.android.bluetooth.hfpclient.NativeInterface.onConnectionStateChanged(int,int, int, byte[]) 在 java.lang.Class 的实例上'

08-29 14:16:35.723 4697 4697 F 调试:x0 0000000000000000 x1 0000000000000de7 x2 0000000000000006 x3 0000000000000008

08-29 14:16:35.723 4697 4697 F 调试:x4 fefff69db9b60667 x5 fefff69db9b60667 x6 fefff69db9b60667 x7 7f7ffffffff7f7f

08-29 14:16:35.723 4697 4697 F 调试:x8 0000000000000083 x9 0000f79eba2b7a68 x10 fffffff87ffffbdf x11 0000000000000001

08-29 14:16:35.723 4697 4697 F 调试:x12 0000f79ea06813[172.909846] alloc_contig_range:[a7f00,a8285)PFNs 忙 38 x13 ffffffffffffffff ffffff ffffffff ffffff ffffff ff

08-29 14:16:35.723 4697 4697 F调试:X16 0000F79EBA2F02C8 X17 0000F79EBA22E2D8 [172.929388] ALLOC_CONTIG_RANGE:ALLOC_CONTIG_RANGE:[A7F00,A8285,A8285)

08-29 14:16:35.723 4697 4697 F 调试:x20 0000000000000de7 x21 0000000000000083 x22 0000f79eb32fd400 x23 0000f79e9e23c000

08-29 14:16:35.723 4697 4697 F 调试:x24 0000000000000000 x25 0000000000000012 x26 0000000000000005 x27 0000f79eb9906c13

08-29 14:16:35.723 4697 4697 F 调试:x28 0000f79eb9906ac7 x29 0000f79ea0681890

08-29 14:16:35.723 4697 4697 F 调试:sp 0000f79ea0681850 lr 0000f79eba222a90 pc 0000f79eba222abc

08-29 14:16:35.765 4697 4697 F 调试:

08-29 14:16:35.765 4697 4697 F 调试:回溯:

08-29 14:16:35.765 4697 4697 F 调试:#00 pc 0000000000021abc /system/lib64/libc.so(中止+124)

08-29 14:16:35.765 4697 4697 F 调试:#01 pc 000000000046adb0 /system/lib64/libart.so (art::Runtime::Abort(char const*)+1208)

08-29 14:16:35.765 4697 4697 F 调试:#02 pc 0000000000008d2c /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+724)

08-29 14:16:35.765 4697 4697 F 调试:#03 pc 00000000002e8908 /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1656)

08-29 14:16:35.765 4697 4697 F 调试:#04 pc 00000000002e8a7c /system/lib64/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+108)

08-29 14:16:35.765 4697 4697 F 调试:#05 pc 00000000000fd5f8 /system/lib64/libart.so (art::(匿名命名空间)::ScopedCheck::AbortF(char const*, ...)+144 )

08-29 14:16:35.765 4697 4697 F 调试:#06 pc 00000000001015a8 /system/lib64/libart.so (art::(匿名命名空间)::ScopedCheck::CheckMethodAndSig(art::ScopedObjectAccess&, _jobject*, _jclass* , _jmethodID*, art::Primitive::Type, art::InvokeType)+1920)

08-29 14:16:35.765 4697 4697 F 调试:#07 pc 00000000000ffcb4 /system/lib64/libart.so (art::(匿名命名空间)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)+756)

08-29 14:16:35.765 4697 4697 F 调试:#08 pc 00000000000ed5d4 /system/lib64/libart.so (art::(匿名命名空间)::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std ::__va_list)+84)

08-29 14:16:35.765 4697 4697 F 调试:#09 pc 0000000000017ec0 /system/lib64/libbluetooth_jni.so (_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+120)

08-29 14:16:35.765 4697 4697 F 调试:#10 pc 000000000001d71c /system/lib64/libbluetooth_jni.so (android::connection_state_cb(RawAddress const*, bthf_client_connection_state_t, unsigned int, unsigned int)+268)

08-29 14:16:35.765 4697 4697 F 调试:#11 pc 000000000012b8d8 /system/lib64/libbluetooth.so (btif_hf_client_upstreams_evt(unsigned short, char*)+3488)

08-29 14:16:35.765 4697 4697 F 调试:#12 pc 0000000000116124 /system/lib64/libbluetooth.so (bt_jni_msg_ready(void*)+116)

08-29 14:16:35.765 4697 4697 F 调试:#13 pc 0000000000096aec /system/lib64/libchrome.so (base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*)+244)

08-29 14:16:35.766 4697 4697 F 调试:#14 pc 00000000000b0388 /system/lib64/libchrome.so (base::MessageLoop::RunTask(base::PendingTask*)+416)

08-29 14:16:35.766 4697 4697 F 调试:#15 pc 00000000000b0634 /system/lib64/libchrome.so (base::MessageLoop::DeferOrRunPendingTask(base::PendingTask)+52)

08-29 14:16:35.766 4697 4697 F 调试:#16 pc 00000000000b0a7c /system/lib64/libchrome.so (base::MessageLoop::DoWork()+380)

08-29 14:16:35.766 4697 4697 F 调试:#17 pc 00000000000b1e44 /system/lib64/libchrome.so (base::MessagePumpDefault::Run(base::MessagePump::Delegate*)+180)

08-29 14:16:35.766 4697 4697 F 调试:#18 pc 00000000000b0070 /system/lib64/libchrome.so (base::MessageLoop::RunHandler()+112)

08-29 14:16:35.766 4697 4697 F 调试:#19 pc 00000000000cd200 /system/lib64/libchrome.so (base::RunLoop::Run()+136)

08-29 14:16:35.766 4697 4697 F 调试:#20 pc 0000000000114334 /system/lib64/libbluetooth.so (run_message_loop(void*)+284)

08-29 14:16:35.766 4697 4697 F 调试:#21 pc 0000000000232874 /system/lib64/libbluetooth.so (work_queue_read_cb(void*)+92)

08-29 14:16:35.766 4697 4697 F 调试:#22 pc 0000000000230a90 /system/lib64/libbluetooth.so (run_reactor(reactor_t*, int)+320)

08-29 14:16:35.766 4697 4697 F 调试:#23 pc 0000000000230924 /system/lib64/libbluetooth.so (reactor_start(reactor_t*)+84)

08-29 14:16:35.766 4697 4697 F 调试:#24 pc 00000000002322f8 /system/lib64/libbluetooth.so (run_thread(void*)+184)

08-29 14:16:35.766 4697 4697 F 调试:#25 pc 0000000000083194 /system/lib64/libc.so (__pthread_start(void*)+36)

08-29 14:16:35.766 4697 4697 F 调试:#26 pc 00000000000233bc /system/lib64/libc.so (__start_thread+68)

08-29 14:16:35.776 4697 4697 I crash_dump64: type=1400 audit(0.0:53): avc: denied { read } for name="btopp.db-shm" dev="mmcblk2p12" ino=758 scontext=u :r:crash_dump:s0

一旦在 Android 的蓝牙 Apk 中启用了启动 hfpclient 服务的标志,然后当启用了标志的图像加载到设备上并与设备启动配对时,我在 JNI 界面中看到崩溃。

我从崩溃日志中看到的主要原因是:JNI DETECTED ERROR IN APPLICATION: can't call void com.android.bluetooth.hfpclient.NativeInterface.onConnectionStateChanged(int, int, int, byte[]) on instance of java .lang.Class'

@@ -350,6 +368,14 @@ static bthf_client_callbacks_t sBluetoothHfpClientCallbacks = {
 static void classInitNative(JNIEnv* env, jclass clazz) {
   method_onConnectionStateChanged =
       env->GetMethodID(clazz, "onConnectionStateChanged", "(III[B)V");
+  if(method_onConnectionStateChanged == 0)
+  {
+         ALOGE("%s : FAILED TO INIT OBJ",__func__);
+  }
+  else
+  {
+         ALOGE("%s : INIT OBJ",__func__);
+  }

我可以从上面的代码中验证 MethodID 是否已分配给变量。

@@ -68,13 +72,27 @@ static void connection_state_cb(const RawAddress* bd_addr,
                                 bthf_client_connection_state_t state,
                                 unsigned int peer_feat,
                                 unsigned int chld_feat) {
+  std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex);
   CallbackEnv sCallbackEnv(__func__);
-  if (!sCallbackEnv.valid()) return;
+  if (!sCallbackEnv.valid() || !mCallbacksObj)
+  {
+         ALOGE("****ERRORR****");
+         return;
+  }

   ScopedLocalRef<jbyteArray> 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);
+  if(method_onConnectionStateChanged == 0)
+{
+        ALOGE("%s : FAILED TO INIT OBJ",__func__);
+}
+else
+{
+        ALOGE("%s : INIT OBJ",__func__);
+}
   sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onConnectionStateChanged,
                                (jint)state, (jint)peer_feat, (jint)chld_feat,
                                addr.get());

此外,我已经在调用 CallVoidMethod() 的地方验证了相同的内容,即使在那里我也可以看到 method_onConnectionStateChanged 并没有失去它的范围。

所以,我不确定是什么导致了这个错误:JNI DETECTED ERROR IN APPLICATION: can't call void com.android.bluetooth.hfpclient.NativeInterface.onConnectionStateChanged(int, int, int, byte[]) on instance of java.语言类

4

1 回答 1

0

我遇到了同样的问题,发现它实际上已在 android 中修复:请参阅https://android.googlesource.com/platform/packages/apps/Bluetooth/+/c8e910d0393d2d7f3bf46d90746819d024ec7510

另请注意,如果未启用JNI 检查(例如:在用户模式下构建),则不会发生此问题。

于 2019-10-21T14:03:51.883 回答