Qt Android蓝牙套接字在Android 5.1.1和6.0上编写问题

时间:2015-12-17 08:08:10

标签: android c++ qt bluetooth

我正在使用Qt for Android开发应用程序,它使用蓝牙。 Qt创建者中的目标API设置为16(据我记得4.1)。高达5.0,应用程序没有问题但是从5.1.1开始写入rfcom蓝牙套接字存在问题。这是我设法从日志中获得的。

在收到QBluetoothSocket :: connected信号之前,我可以看到:

D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
W/bt-btif ( 4541): new conn_srvc id:26, app_id:1
W/bt-btif ( 4541): bta_dm_pm_ssr conn_srvc id:26, app_id:1
W/bt-btif ( 4541): bta_dm_pm_ssr:2, lat:1200
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
E/BluetoothRemoteDevices( 4541): setRfcommConnected true
D/BluetoothSocket(21782): getInputStream(): myUserId = 0
D/BluetoothSocket(21782): getOutputStream(): myUserId = 0

似乎socket已连接,但我想知道那些BT_WAKE is asserted already是什么,我应该把它们视为“出错了”的第一个症状,但是我成功地从套接字获得“连接”信号并开始使用套接字。我在连接套接字后立即发送5个字节的数据。

D/IOP_DB_BT( 4541): db_query: id DisableSniff :: key KEY_BDADDR, value 00:06:66:64:fd:4a
D/IOP_DB_BT( 4541): db_query: result 1
D/IOP_DB_BT( 4541): db_query: id ExtendSniffTime :: key KEY_BDADDR, value 00:06:66:64:fd:4a
D/IOP_DB_BT( 4541): db_query: result 1
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
D/bt_upio ( 4541): ..proc_btwrite_timeout..

这是我在写完后立即在日志中看到的内容。

比我的数据发送超时时隙(5秒超时)。我正在尝试读取缓冲区内的任何内容并获取

W/bt-btif ( 4541): dm_pm_timer expires
W/bt-btif ( 4541): dm_pm_timer expires 0
W/bt-btif ( 4541): proc dm_pm_timer expires
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): proc btwrite assertion
E/bt-btif ( 4541): bta_dm_pm_btm_status  hci_status=36

当关闭超时套接字时,我得到了

D/BluetoothSocket(21782): close() in, this: android.bluetooth.BluetoothSocket@21e99957, channel: 1, state: CONNECTED
D/BluetoothSocket(21782): close() this: android.bluetooth.BluetoothSocket@21e99957, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@d78fc44, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@39f8512dmSocket: android.net.LocalSocket@d447662 impl:android.net.LocalSocketImpl@340473f3 fd:FileDescriptor[52]
D/BluetoothSocket(21782): Closing mSocket: android.net.LocalSocket@d447662 impl:android.net.LocalSocketImpl@340473f3 fd:FileDescriptor[52]
W/System.err(21782): java.io.IOException: bt socket closed, read return: -1
W/System.err(21782):    at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:651)
D/bt_vendor( 4541): op for 7
W/System.err(21782):    at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:96)
D/bt_upio ( 4541): BT_WAKE is asserted already
W/System.err(21782):    at java.io.InputStream.read(InputStream.java:162)
W/System.err(21782):    at org.qtproject.qt5.android.bluetooth.QtBluetoothInputStreamThread.run(QtBluetoothInputStreamThread.java:77)
W/bt-btif ( 4541): bta_jv_rfc_port_to_cb(port_handle:0xc):jv handle:0x0 not FOUND
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): BT_WAKE is asserted already
E/bt-btm  ( 4541): Reset sec_bd_name and name flag. (BR/EDR link)
E/bt-btm  ( 4541): btm_sec_disconnected - Clearing Pending flag
W/bt-btif ( 4541): bta_dm_acl_change(), event : 1
W/bt-btif ( 4541): bta_dm_acl_change(), event : 2
E/BluetoothRemoteDevices( 4541): aclStateChangeCallback:  State:DisConnected to Device:00:06:66:64:FD:XX
D/KeyguardViewMediator( 1352): Received android.bluetooth.device.action.ACL_DISCONNECTED
D/BluetoothUtils( 4541): getBtEnabledContainers(): btContainers = []
D/KnoxKeyguardUpdateMonitor( 1015): BroadcastReceiver onReceive
D/KnoxKeyguardUpdateMonitor( 1015): BroadcastReceiver onReceive action: android.bluetooth.device.action.ACL_DISCONNECTED
D/KnoxKeyguardUpdateMonitor( 1015): BroadcastReceiver ACTION_ACL_DISCONNECTED
I/TrustAgent.Tracker( 2416): [BluetoothConnectionTracker] Bluetooth disconnect broadast for DeviceName 00:06:66:64:FD:4A
V/BroadcastQueue( 1015): [background] Process cur broadcast BroadcastRecord{11c4d283 u0 android.bluetooth.device.action.ACL_DISCONNECTED} DELIVERED for app ProcessRecord{3da73a96 4541:com.android.bluetooth/1002}
D/KeyguardViewMediator( 1352): isGear1: device is not B1!
D/ActivityManager( 1015): startService callerProcessName:com.sec.android.automotive.drivelink, calleePkgName: com.sec.android.automotive.drivelink
V/[CarModeFW](21435): BTEventsHandlerService-onHandleIntent: Action = android.bluetooth.device.action.ACL_DISCONNECTED State = -2147483648 Previous = -2147483648
D/BluetoothAdapterService( 4541): getAdapterService() - returning com.android.bluetooth.btservice.AdapterService@11578ddd
D/BtConfig.SecureMode( 4541): isSecureModeOn:false
D/SecContentProvider( 1015): query(), uri = 4 selection = isProfileAuthorizedBySecurityPolicy
D/[CarModeFW](21435): ConnectivityManager-handleMessage BLUETOOTH_ACL_DISCONNECTED
D/[CarModeFW](21435): ConnectivityManager-handleMessage BLUETOOTH_ACL_DISCONNECTED onNotifyBluetoothDeviceDisconnected
D/ActivityManager( 1015): startService callerProcessName:com.android.bluetooth, calleePkgName: com.android.bluetooth
I/BluetoothPbapService( 4541): action: android.bluetooth.device.action.ACL_DISCONNECTED, state: -2147483648
D/StatusBar.NetworkController( 1352): onDataActivity: direction=0
D/StatusBar.NetworkController( 1352): updateDataIcon, mDataDirectionIconId = com.android.systemui:drawable/stat_sys_data_fully_connected_lte mDataConnected = true
V/BroadcastQueue( 1015): [background] Process cur broadcast BroadcastRecord{11c4d283 u0 android.bluetooth.device.action.ACL_DISCONNECTED} DELIVERED for app ProcessRecord{eac93e8 7760:com.sec.android.app.shealth:remote/u0a70}
V/BroadcastQueue( 1015): [background] Process cur broadcast BroadcastRecord{11c4d283 u0 android.bluetooth.device.action.ACL_DISCONNECTED} DELIVERED for app ProcessRecord{34817d39 1995:com.google.android.googlequicksearchbox:search/u0a62}
I/BTConnectionReceiver( 1995): onReceive(context, Intent { act=android.bluetooth.device.action.ACL_DISCONNECTED flg=0x4000010 cmp=com.google.android.googlequicksearchbox/com.google.android.apps.gsa.search.core.BluetoothConnectionReceiver (has extras) }, [BluetoothDevice: address=00:06:66:64:FD:4A, alias=null, name=BeSteadyOne010347, majorDeviceClass=7936, deviceClass=7936]
I/BluetoothClassifier( 1995): Bluetooth Device Name: BeSteadyOne010347
V/BroadcastQueue( 1015): [background] Process cur broadcast BroadcastRecord{11c4d283 u0 android.bluetooth.device.action.ACL_DISCONNECTED} DELIVERED for app ProcessRecord{1ab7ce01 22089:com.skype.raider/u0a300}
W/[CarMode](21435): [BluetoothConnectivityListener]-Device BeSteadyOne010347 not registered as Car (Not found in Settings)
D/StatusBar.NetworkController( 1352): refreshViews connected={ data } level=1 combinedSignalIconId=0x7f020598/com.android.systemui:drawable/stat_sys_signal_1_auto_rotate mobileLabel=Plus wifiLabel= emergencyOnly=false combinedLabel=Plus mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f020598/com.android.systemui:drawable/stat_sys_signal_1_auto_rotate mQSPhoneSignalIconId=0x7f0201ac/com.android.systemui:drawable/ic_qs_signal_1 mDataDirectionIconId=0x7f020494/com.android.systemui:drawable/stat_sys_data_fully_connected_lte mDataSignalIconId=0x7f020598/com.android.systemui:drawable/stat_sys_signal_1_auto_rotate mDataTypeIconId=0x7f02047a/com.android.systemui:drawable/stat_sys_data_connected_lte mQSDataTypeIconId=0x7f0201b2/com.android.systemui:drawable/ic_qs_signal_4g mNoSimIconId=0x0/(null) mWifiIconId=0x0/(null) mQSWifiIconId=0x0/(null) mWifiActivityIconId=0x7f02064b/com.android.systemui:drawable/stat_sys_signal_inout mBluetoothTetherIconId=0x7f02065e/com.android.systemui:drawable/stat_sys_tether_bluetooth
D/STATUSBAR-WifiTile( 1352): onWifiSignalChanged enabled=false enabledDesc:null
E/Watchdog( 1015): !@Sync 711 [12-14 16:06:15.605]
D/bt_vendor( 4541): op for 7
D/bt_upio ( 4541): ..proc_btwrite_timeout..

我不再知道为什么这不起作用,我还能尝试使其工作。也许我错过了一些使蓝牙工作的新权限。

我在清单中拥有的权限(由Qt生成的权限)

<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

0 个答案:

没有答案