问题在于在特定设备上使用Google Nearby Connections发送文件时出现问题。

huangapple go评论83阅读模式
英文:

Problem sending file using Google Nearby Connections on specific device

问题

我有2台设备:

  • 一台正在广播(在 Android 11 上运行的服务器应用)
  • 一台正在发现(在 Android 4.4.2 上运行的客户端应用)。

两者都安装了最新版本的 Google Play 服务。

在连接时,客户端应用会向服务器应用发送一些字节;根据这些字节,服务器应用会发送回一些字节或一个文件。这在我拥有的所有客户端设备上都可以正常工作,除了 Galaxy Tab 3,我不知道为什么。发送字节可以正常工作,但发送文件不行(文件大小约为25MB!我尝试过5KB,结果相同:负载失败)。在失败时,客户端会从服务器断开连接,然后重新连接,只是再次失败。尝试了一些次数后,通常会弹出一个窗口,显示 Play 服务已停止。

有人知道为什么在这个特定的设备上会发生这种情况吗?

我从服务器应用中获得了一些日志:

? I/NearbyConnections: EndpointManager failed the next Read read/write for endpoint ZPYv over its ENCRYPTED_BLUETOOTH EndpointChannel. [CONTEXT service_id=54 ]
    java.io.IOException: bt socket closed, read return: -1
        ...
? I/NearbyConnections: EndpointManager quit overall Read loop for endpoint ZPYv because the currently registered ENCRYPTED_BLUETOOTH EndpointChannel is in a failed state. [CONTEXT service_id=54 ]
? I/NearbyConnections: Failed to close write stream of ENCRYPTED_BLUETOOTH EndpointChannel BluetoothClassicSocket:C4:62:EA:38:FD:08: socket closed [CONTEXT service_id=54 ]
? I/NearbyConnections: EndpointChannelManager unregistered endpoint ZPYv [CONTEXT service_id=54 ]
? I/NearbyConnections: ClientProxy(80700159) ignoring onConnectionResult(ZPYv, ERROR) because this client has no pending connections to the endpoint [CONTEXT service_id=54 ]
? I/NearbyMediums: Closed Wifi Direct channel. [CONTEXT service_id=54 ]
? E/NearbyMediums: There's no Direct hotspot to stop when the Wi-Fi Direct channel disconnected. [CONTEXT service_id=54 ]

还有来自我的客户端应用的错误报告对话框中的异常行(对话框不是每次都出现,所以我不知道这是否是 Nearby 失败背后的原因):

java.lang.IllegalArgumentException: Requested flags 0x43, but only 0x3 are allowed
英文:

I have 2 devices:

  • one is advertising (server app running on android 11)
  • one is discovering (client app running on android 4.4.2).

Both have the latest version of the Google Play Services.

On connection, the client app is sending some bytes to the server app; depending on those, it will send back bytes or a file. It works on all client devices I have except the Galaxy Tab 3 and I have no idea why. Sending bytes works, but not sending files (file is approx. 25Mo! i've tried 5Kb, same result : Payload Failure). On failing, client disconnects from server and then reconnects to it, only to fail again. After some tries, a pop-up often appears saying Play Services have stopped.

Does anyone have an idea why this is happening on this specific device?

I have some logs from my server app :

? I/NearbyConnections: EndpointManager failed the next Read read/write for endpoint ZPYv over its ENCRYPTED_BLUETOOTH EndpointChannel. [CONTEXT service_id=54 ]
    java.io.IOException: bt socket closed, read return: -1
        at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:550)
        at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:88)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:248)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:288)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:347)
        at java.io.DataInputStream.readFully(DataInputStream.java:198)
        at java.io.DataInputStream.readInt(DataInputStream.java:389)
        at agmx.e(:com.google.android.gms@203315046@20.33.15 (150400-330018294):1)
        at agoz.a(:com.google.android.gms@203315046@20.33.15 (150400-330018294):1)
        at agow.run(:com.google.android.gms@203315046@20.33.15 (150400-330018294):4)
        at agiy.run(Unknown Source:0)
        at qzr.b(:com.google.android.gms@203315046@20.33.15 (150400-330018294):12)
        at qzr.run(:com.google.android.gms@203315046@20.33.15 (150400-330018294):7)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at rfq.run(:com.google.android.gms@203315046@20.33.15 (150400-330018294):0)
        at java.lang.Thread.run(Thread.java:923)
? I/NearbyConnections: EndpointManager quit overall Read loop for endpoint ZPYv because the currently registered ENCRYPTED_BLUETOOTH EndpointChannel is in a failed state. [CONTEXT service_id=54 ]
? I/NearbyConnections: Failed to close write stream of ENCRYPTED_BLUETOOTH EndpointChannel BluetoothClassicSocket:C4:62:EA:38:FD:08: socket closed [CONTEXT service_id=54 ]
? I/NearbyConnections: EndpointChannelManager unregistered endpoint ZPYv [CONTEXT service_id=54 ]
? I/NearbyConnections: ClientProxy(80700159) ignoring onConnectionResult(ZPYv, ERROR) because this client has no pending connections to the endpoint [CONTEXT service_id=54 ]
? I/NearbyMediums: Closed Wifi Direct channel. [CONTEXT service_id=54 ]
? E/NearbyMediums: There's no Direct hotspot to stop when the Wi-Fi Direct channel disconnected. [CONTEXT service_id=54 ]

And the exception line from the bug report dialog on my client app (dialog doesn't show up every time so I don't know if this is the reason behind the Nearby's failure) :

java.lang.IllegalArgumentException: Requested flags 0x43, but only 0x3 are allowed

答案1

得分: 0

这是在附近连接代码中的一个错误!这是 https://stackoverflow.com/questions/34740746/illegalargumentexception-in-granturipermission-on-api-level-19 的一个实例。

我刚刚提交了一个修复,但大约一个月后才会在设备上推出。

免责声明:我在Nearby团队工作。

英文:

This is a bug in Nearby Connection's code! It's an instance of https://stackoverflow.com/questions/34740746/illegalargumentexception-in-granturipermission-on-api-level-19

I've just submitted a fix, but it'll take roughly a month until it's rolled out to devices.

Disclaimer: I work on Nearby

huangapple
  • 本文由 发表于 2020年9月16日 21:45:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/63921425.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定