UsbDeviceConnection requestWait()本机崩溃

时间:2014-07-14 11:51:14

标签: android multithreading usb endpoint libusb

我正在使用我想要从2个线程进行通信的设备的2个中断端点(IN和OUT):

一个WriteThread,它通过初始化OUT端点的UsbRequest对数据包进行排队(这是从我的应用程序到设备的通信)

一个ReadThread,它通过初始化IN端点的UsbRequest对设备进行排队读取(这是从设备到我的应用程序的通信)

我这样做是因为UsbDeviceConnection.requestWait()阻止了ReadThread线程,我需要能够同时写入和读取。 问题是,当我尝试写入和读取同时我的应用程序崩溃。崩溃似乎发生在requestWait()方法中,具有下面的堆栈跟踪。我注意到如果我在某些手机上使用Thead.sleep(100)会让崩溃消失,但在其他手机上,即使我使用更大的延迟也会发生崩溃,所以睡眠方法就是&# 39;不是一个可行的解决方案。 我想知道你们中是否有人遇到过同样的问题,你们是如何克服它的。

我已经看过这个帖子了:

UsbRequest.queue crashing Android 3.1 application

但是我需要使用中断的端点,我编写应用程序的设备没有批量端点,因此我无法在上面的链接中执行他们所说的解决方法。

在崩溃的堆栈跟踪之下。

07-03 17:55:11.991: E/dalvikvm(28658): JNI ERROR (app bug): accessed stale global reference 0x7ad003fa (index 254 in a table of size 254)
07-03 17:55:11.991: E/dalvikvm(28658): VM aborting
07-03 17:55:11.991: A/libc(28658): Fatal signal 6 (SIGABRT) at 0x00006ff2 (code=-6), thread 28784 (ReadThread)
07-03 17:55:12.101: I/DEBUG(258): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-03 17:55:12.101: I/DEBUG(258): Build fingerprint: 'samsung/hltexx/hlte:4.4.2/KOT49H/N9005XXUEND3:user/release-keys'
07-03 17:55:12.101: I/DEBUG(258): Revision: '8'
07-03 17:55:12.101: I/DEBUG(258): pid: 28658, tid: 28784, name: ReadThread  >>>  <<<
07-03 17:55:12.101: I/DEBUG(258): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
07-03 17:55:12.221: I/DEBUG(258):     r0 00000000  r1 00007070  r2 00000006  r3 00000000
07-03 17:55:12.221: I/DEBUG(258):     r4 00000006  r5 00000016  r6 00007070  r7 0000010c
07-03 17:55:12.221: I/DEBUG(258):     r8 00000000  r9 42bf1850  sl 737df400  fp 42bf3cf0
07-03 17:55:12.221: I/DEBUG(258):     ip 00000001  sp 77d44880  lr 400dd1ad  pc 400ec154  cpsr 000f0010
07-03 17:55:12.221: I/DEBUG(258):     d0  0000000000000000  d1  0000000000000000
07-03 17:55:12.221: I/DEBUG(258):     d2  0000000000000000  d3  0000000000000000
07-03 17:55:12.221: I/DEBUG(258):     d4  0000000000000000  d5  0000000000000000
07-03 17:55:12.221: I/DEBUG(258):     d6  0000000000000000  d7  0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d8  0000000000000000  d9  0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d10 0000000000000000  d11 0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d12 0000000000000000  d13 0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d14 0000000000000000  d15 0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d16 61742061206e6920  d17 7320666f20656c62
07-03 17:55:12.231: I/DEBUG(258):     d18 0000000000000000  d19 0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d20 0000000000000000  d21 0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d22 0000000000000000  d23 0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d24 3fc74721cad6b0ed  d25 3fc2f112df3e5244
07-03 17:55:12.231: I/DEBUG(258):     d26 40026bb1bbb55516  d27 0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d28 0000000000000000  d29 0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     d30 0000000000000000  d31 0000000000000000
07-03 17:55:12.231: I/DEBUG(258):     scr 20000010
07-03 17:55:12.231: I/DEBUG(258): backtrace:
07-03 17:55:12.231: I/DEBUG(258):     #00  pc 00022154  /system/lib/libc.so (tgkill+12)
07-03 17:55:12.231: I/DEBUG(258):     #01  pc 000131a9  /system/lib/libc.so (pthread_kill+48)
07-03 17:55:12.231: I/DEBUG(258):     #02  pc 000133bd  /system/lib/libc.so (raise+10)
07-03 17:55:12.231: I/DEBUG(258):     #03  pc 000120f3  /system/lib/libc.so
07-03 17:55:12.231: I/DEBUG(258):     #04  pc 00021a08  /system/lib/libc.so (abort+4)
07-03 17:55:12.231: I/DEBUG(258):     #05  pc 000493bf  /system/lib/libdvm.so (dvmAbort+78)
07-03 17:55:12.231: I/DEBUG(258):     #06  pc 0002af2c  /system/lib/libdvm.so (IndirectRefTable::get(void*) const+216)
07-03 17:55:12.231: I/DEBUG(258):     #07  pc 0004dcd3  /system/lib/libdvm.so (dvmDecodeIndirectRef(Thread*, _jobject*)+62)
07-03 17:55:12.231: I/DEBUG(258):     #08  pc 000519f1  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+600)
07-03 17:55:12.231: I/DEBUG(258):     #09  pc 00000214  /dev/ashmem/dalvik-jit-code-cache (deleted)
07-03 17:55:12.231: I/DEBUG(258): stack:
07-03 17:55:12.231: I/DEBUG(258):          77d44840  000000fe  
07-03 17:55:12.231: I/DEBUG(258):          77d44844  7757bfa8  
07-03 17:55:12.231: I/DEBUG(258):          77d44848  00000001  
07-03 17:55:12.231: I/DEBUG(258):          77d4484c  00000000  
07-03 17:55:12.231: I/DEBUG(258):          77d44850  42bf1850  /dev/ashmem/dalvik-heap (deleted)
07-03 17:55:12.231: I/DEBUG(258):          77d44854  737df400  
07-03 17:55:12.231: I/DEBUG(258):          77d44858  42bf3cf0  /dev/ashmem/dalvik-heap (deleted)
07-03 17:55:12.231: I/DEBUG(258):          77d4485c  400f0501  /system/lib/libc.so (snprintf+80)
07-03 17:55:12.231: I/DEBUG(258):          77d44860  61fcd7f8  /dev/ashmem/dalvik-bitmap-2 (deleted)
07-03 17:55:12.231: I/DEBUG(258):          77d44864  000155fe  
07-03 17:55:12.231: I/DEBUG(258):          77d44868  77d448dc  [stack:28784]
07-03 17:55:12.231: I/DEBUG(258):          77d4486c  00000000  
07-03 17:55:12.231: I/DEBUG(258):          77d44870  00000000  
07-03 17:55:12.231: I/DEBUG(258):          77d44874  40118394  
07-03 17:55:12.231: I/DEBUG(258):          77d44878  00004000  
07-03 17:55:12.231: I/DEBUG(258):          77d4487c  77d448ea  [stack:28784]
07-03 17:55:12.231: I/DEBUG(258):     #00  77d44880  00000006  
07-03 17:55:12.231: I/DEBUG(258):          77d44884  00000016  
07-03 17:55:12.231: I/DEBUG(258):          77d44888  00007070  
07-03 17:55:12.241: I/DEBUG(258):          77d4488c  00000001  
07-03 17:55:12.241: I/DEBUG(258):          77d44890  00000001  
07-03 17:55:12.241: I/DEBUG(258):          77d44894  400dd1ad  /system/lib/libc.so (pthread_kill+52)
07-03 17:55:12.241: I/DEBUG(258):     #01  77d44898  00000006  
07-03 17:55:12.241: I/DEBUG(258):          77d4489c  00000000  
07-03 17:55:12.241: I/DEBUG(258):          77d448a0  7757bfa8  
07-03 17:55:12.241: I/DEBUG(258):          77d448a4  400dd3c1  /system/lib/libc.so (raise+14)
07-03 17:55:12.241: I/DEBUG(258):     #02  77d448a8  77d448b4  [stack:28784]
07-03 17:55:12.241: I/DEBUG(258):          77d448ac  400dc0f7  /system/lib/libc.so
07-03 17:55:12.241: I/DEBUG(258): memory near r1:
07-03 17:55:12.241: I/DEBUG(258):     00007050 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007060 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007070 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007080 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007090 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070a0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070b0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070c0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070d0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070e0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070f0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007100 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007110 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007120 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007130 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007140 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258): memory near r6:
07-03 17:55:12.241: I/DEBUG(258):     00007050 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007060 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007070 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007080 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007090 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070a0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070b0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070c0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070d0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070e0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     000070f0 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007100 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007110 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007120 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007130 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.241: I/DEBUG(258):     00007140 ffffffff ffffffff ffffffff ffffffff  
07-03 17:55:12.251: I/DEBUG(258): memory near r9:
07-03 17:55:12.251: I/DEBUG(258):     42bf1830 00000000 00000000 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf1840 00000000 00000000 000000f8 0000001a  
07-03 17:55:12.251: I/DEBUG(258):     42bf1850 417eb538 00000000 42befd38 77562210  
07-03 17:55:12.251: I/DEBUG(258):     42bf1860 00000000 000000d9 42bef820 429ef108  
07-03 17:55:12.251: I/DEBUG(258):     42bf1870 53b56e9f 00000000 00001000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf1880 00000000 00000000 53b56e9d 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf1890 0000000b 00000000 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf18a0 0016d0ea 00000000 0000bd02 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf18b0 53b56e9f 00000000 00000001 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf18c0 000021b0 000003fa 000003e8 0000001b  
07-03 17:55:12.251: I/DEBUG(258):     42bf18d0 41779800 00000000 00000004 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf18e0 0b0a0908 0000005b 41779800 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf18f0 00000041 00000000 00000801 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf1900 00000000 00000000 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf1910 00000000 00000000 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf1920 00000000 00000000 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258): memory near sl:
07-03 17:55:12.251: I/DEBUG(258):     737df3e0 0b1afd31 00000b0a 00000000 0000045b  
07-03 17:55:12.251: I/DEBUG(258):     737df3f0 6e6ffb4a 7757bfa8 6d6fc0a8 6f3ea000  
07-03 17:55:12.251: I/DEBUG(258):     737df400 7ad003fa 77562210 77d44c40 00000000  
07-03 17:55:12.251: I/DEBUG(258):     737df410 77d44c94 0000000c 00000000 416a9d40  
07-03 17:55:12.251: I/DEBUG(258):     737df420 00000000 00000000 6c9f4170 77578300  
07-03 17:55:12.251: I/DEBUG(258):     737df430 00000000 00000000 00000001 00004000  
07-03 17:55:12.251: I/DEBUG(258):     737df440 00000000 77766e70 416a9d40 416aec80  
07-03 17:55:12.251: I/DEBUG(258):     737df450 00000000 416b2d7c 416b2df0 416b2ca0  
07-03 17:55:12.251: I/DEBUG(258):     737df460 416b2cc0 416b2d1c 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     737df470 779e9fc8 00000028 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     737df480 00000000 00000000 00000152 417554ec  
07-03 17:55:12.251: I/DEBUG(258):     737df490 4177c830 6d63fcc0 00000001 777679a8  
07-03 17:55:12.251: I/DEBUG(258):     737df4a0 00000001 00000040 00000200 00000000  
07-03 17:55:12.251: I/DEBUG(258):     737df4b0 00000001 6e6ffb4a 6e6ffb4a 00000002  
07-03 17:55:12.251: I/DEBUG(258):     737df4c0 6e6ffb5a 6d640e28 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     737df4d0 00000000 00000000 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258): memory near fp:
07-03 17:55:12.251: I/DEBUG(258):     42bf3cd0 00000005 00000004 6da39a98 ffc03c00  
07-03 17:55:12.251: I/DEBUG(258):     42bf3ce0 77414f61 00000000 00000000 0000006b  
07-03 17:55:12.251: I/DEBUG(258):     42bf3cf0 42bf3c48 00000000 429ffbf0 42bf5510  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d00 41787da0 00000000 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d10 42bf3d58 00000000 42bf4fe8 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d20 00006dd3 00000000 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d30 00000005 00000001 00000001 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d40 42bf1850 42bf5500 42bf3a30 42bf3f00  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d50 00000001 0000001b 41787aa8 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d60 00000000 41787560 00000000 00000043  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d70 41823bc0 00000000 00000000 00000000  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d80 00000000 00000000 00001000 00001000  
07-03 17:55:12.251: I/DEBUG(258):     42bf3d90 ffffffff 00000000 41825cc0 42a7aea8  
07-03 17:55:12.251: I/DEBUG(258):     42bf3da0 00000000 00000000 00310038 00000011  
07-03 17:55:12.251: I/DEBUG(258):     42bf3db0 42b5bb10 42bf14c8 00000010 0000002a  
07-03 17:55:12.251: I/DEBUG(258):     42bf3dc0 41823110 00000000 42bf3de8 0000001f  
07-03 17:55:12.251: I/DEBUG(258): memory near sp:
07-03 17:55:12.251: I/DEBUG(258):     77d44860 61fcd7f8 000155fe 77d448dc 00000000  
07-03 17:55:12.251: I/DEBUG(258):     77d44870 00000000 40118394 00004000 77d448ea  
07-03 17:55:12.251: I/DEBUG(258):     77d44880 00000006 00000016 00007070 00000001  
07-03 17:55:12.251: I/DEBUG(258):     77d44890 00000001 400dd1ad 00000006 00000000  
07-03 17:55:12.251: I/DEBUG(258):     77d448a0 7757bfa8 400dd3c1 77d448b4 400dc0f7  
07-03 17:55:12.251: I/DEBUG(258):     77d448b0 00000000 ffffffdf 401142c4 4011422c  
07-03 17:55:12.251: I/DEBUG(258):     77d448c0 00000000 400decb7 41754db0 41754db0  
07-03 17:55:12.261: I/DEBUG(258):     77d448d0 000000fe 400eba0c 00000000 416d23c3  
07-03 17:55:12.261: I/DEBUG(258):     77d448e0 00000000 6c756e28 0000296c 00000000  
07-03 17:55:12.261: I/DEBUG(258):     77d448f0 00000000 00000000 00000000 00000000  
07-03 17:55:12.261: I/DEBUG(258):     77d44900 00000000 00000000 00000000 00000000  
07-03 17:55:12.261: I/DEBUG(258):     77d44910 00000000 00000000 00000000 00000000  
07-03 17:55:12.261: I/DEBUG(258):     77d44920 00000000 00000000 00000000 00000000  
07-03 17:55:12.261: I/DEBUG(258):     77d44930 00000000 00000000 00000000 00000000  
07-03 17:55:12.261: I/DEBUG(258):     77d44940 00000000 00000000 00000000 00000000  
07-03 17:55:12.261: I/DEBUG(258):     77d44950 00000000 00000000 00000000 00000000  
07-03 17:55:12.261: I/DEBUG(258): code around pc:
07-03 17:55:12.261: I/DEBUG(258):     400ec134 e8bd00f0 e3700a01 912fff1e e2600000  
07-03 17:55:12.261: I/DEBUG(258):     400ec144 ea006e4f e92d50f0 e3a07f43 ef000000  
07-03 17:55:12.261: I/DEBUG(258):     400ec154 e8bd50f0 e3700a01 912fff1e e2600000  
07-03 17:55:12.261: I/DEBUG(258):     400ec164 ea006e47 e92d50f0 e3a070ee ef000000  
07-03 17:55:12.261: I/DEBUG(258):     400ec174 e8bd50f0 e3700a01 912fff1e e2600000  
07-03 17:55:12.261: I/DEBUG(258):     400ec184 ea006e3f f200429a bf0080b9 f040f891  
07-03 17:55:12.261: I/DEBUG(258):     400ec194 4001e92d f2c02a04 2a1080a5 8093f2c0  
07-03 17:55:12.261: I/DEBUG(258):     400ec1a4 f2c02a20 2a408088 ea4fdb7f f1bc1c92  
07-03 17:55:12.261: I/DEBUG(258):     400ec1b4 dd6c0f0a 0600e92d 0f40f1bc f500dd4a  
07-03 17:55:12.261: I/DEBUG(258):     400ec1c4 f5016e80 ebae7920 ea4f0e09 ea4f5e4e  
07-03 17:55:12.261: I/DEBUG(258):     400ec1d4 f50e5e5e ebbc7e20 dd3b1f9e f04fbfc4  
07-03 17:55:12.261: I/DEBUG(258):     400ec1e4 ebd9090a dd35199e 0a0eeb01 0a3ff02a  
07-03 17:55:12.261: I/DEBUG(258):     400ec1f4 1c9eebac bfd245e1 0c09ebac f04f46e1  
07-03 17:55:12.261: I/DEBUG(258):     400ec204 f8910c00 f891f240 f921f280 f921028d  
07-03 17:55:12.261: I/DEBUG(258):     400ec214 f8da428d f1b93000 f9000901 f900028d  
07-03 17:55:12.261: I/DEBUG(258):     400ec224 f10a428d d1ee0a40 0f00f1bc f5bcd02b  
07-03 17:55:12.261: I/DEBUG(258): code around lr:
07-03 17:55:12.261: I/DEBUG(258):     400dd18c 447b4b13 42b3e010 6a1ed10e 44784811  
07-03 17:55:12.261: I/DEBUG(258):     400dd19c ec84f7fb ea0cf00d 46224631 efcef00e  
07-03 17:55:12.261: I/DEBUG(258):     400dd1ac d00a3001 e00b2400 2b00681b 480ad1eb  
07-03 17:55:12.261: I/DEBUG(258):     400dd1bc 44782403 ec72f7fb f001e002 6804fa23  
07-03 17:55:12.261: I/DEBUG(258):     400dd1cc fa20f001 46206005 bf00bd70 0003b226  
07-03 17:55:12.261: I/DEBUG(258):     400dd1dc 0003b21a 0003b212 0003b1ee bf7ef7ff  
07-03 17:55:12.261: I/DEBUG(258):     400dd1ec 4a3e4b3d e92d447b b08b43f0 4606589c  
07-03 17:55:12.261: I/DEBUG(258):     400dd1fc 6823460d 930946a1 fa04f001 8000f8d0  
07-03 17:55:12.261: I/DEBUG(258):     400dd20c d0482d00 f0104628 280ff889 d8444604  
07-03 17:55:12.261: I/DEBUG(258):     400dd21c ffe4f7ff d1064286 4629200f e8d6f00d  
07-03 17:55:12.261: I/DEBUG(258):     400dd22c d03c2800 482ee02e f7fb4478 482debb6  
07-03 17:55:12.261: I/DEBUG(258):     400dd23c e0154478 d11342b0 482b6a06 f7fb4478  
07-03 17:55:12.261: I/DEBUG(258):     400dd24c 4a2aec2e 46332120 a801447a f92af013  
07-03 17:55:12.261: I/DEBUG(258):     400dd25c a8012101 fc48f01a 46061c42 e011d104  
07-03 17:55:12.261: I/DEBUG(258):     400dd26c 28006800 e02cd1e6 46294630 f00d4622  
07-03 17:55:12.261: I/DEBUG(258):     400dd27c 1c43e912 d11e4607 f9c4f001 29046801  
07-03 17:55:12.421: I/DEBUG(258): !@dumpstate -k -t -z -d -o /data/log/dumpstate_app_native -m 28658
07-03 17:55:12.421: I/BootReceiver(840): Copying /data/tombstones/tombstone_01 to DropBox (SYSTEM_TOMBSTONE)
07-03 17:55:12.431: W/ApplicationPackageManager(840): getCSCPackageItemText()
07-03 17:55:12.441: I/dumpstate(28888): begin
07-03 17:55:12.441: I/dumpstate(28891): begin
07-03 17:55:12.441: I/dumpstate(28891): dumpstate is still running

2 个答案:

答案 0 :(得分:4)

这是Android平台中的bug,让我在过去两周内感到头疼。 最后,我的项目唯一的解决方案就是创建补丁。

首先是问题的根源: 在课堂上UsbRequest.java:http://androidxref.com/4.4.4_r1/xref/frameworks/base/core/java/android/hardware/usb/UsbRequest.java

在第136行,他们正在确定终点的方向:

boolean out = (mEndpoint.getDirection() == UsbConstants.USB_DIR_OUT);

并将out布尔值作为参数发送到第139和141行中的本机函数。 如果我们遵循本机对应的UsbRequest.cpp中的native_queue_direct方法: http://androidxref.com/4.4.4_r1/xref/frameworks/base/core/jni/android_hardware_UsbRequest.cpp

我们可以看到函数收到的out布尔值没有被使用!

必须使用out布尔值,因为只有read(IN)端点(我们将对它执行requestWait()的端点)应该分配内存 - request->client_data = (void *)env->NewGlobalRef(thiz); - 将由requestWait()方法返回。 通过在OUT(写入)端点上排队数据时不使用out布尔值,它还将分配内存并替换IN端点分配的内存。然后当requestWait()返回时,它将尝试返回由IN端点分配的内存块,该端点现在是不同的并且它崩溃:JNI ERROR(app bug):访问陈旧的全局引用0x7ad003fa(大小为254的表中的索引254)

修复:

android.hardware.usb.UsbDeviceConnection udc = usbManager.openDevice(device);
com.fixed.usb.UsbDeviceConnection usbDeviceConnection = new com.fixed.usb.UsbDeviceConnection(device, udc.getFileDescriptor());

打开设备后,我们使用返回的UsbDeviceConnection获取设备的文件描述符,我们将构建一个新的(固定的)UsbDeviceConnection。然后我们将它用作常规的UsbDeviceConnection。

您可以从issue's page下载补丁。

答案 1 :(得分:0)

当您尝试重新打开设备并重新连接(所有步骤都已完成)时,可能会发生此问题。