1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-02-17 04:46:47 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
dependency-bot
b56ed974a3 Update dependency com.android.tools:desugar_jdk_libs to v2.1.3 2024-11-19 00:15:30 +00:00
MrYoranimo
b5bd4da9b1 Xiaomi SPPv2: Catch exception thrown in onPacketReceived
When a received packet causes an exception to be thrown while
getting handled in the service's onPacketReceived method, the
message will get stuck in the queue because it is never released.
Subsequently received messages get lined up after the first message
that causes an exception, and since that message is never removed,
those newer messages are never processed.

Catching the exception thrown from within the onPacketReceived method
allows the code flow to continue and therefore remove the troubling
message from the queue.
2024-11-18 23:25:28 +01:00
2 changed files with 6 additions and 2 deletions

View File

@ -198,7 +198,7 @@ android {
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.2'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.3'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation "androidx.camera:camera-core:1.4.0"

View File

@ -105,7 +105,11 @@ public class XiaomiSppProtocolV2 extends AbstractXiaomiSppProtocol {
break;
case PACKET_TYPE_DATA:
XiaomiSppPacketV2.DataPacket dataPacket = (XiaomiSppPacketV2.DataPacket) decodedPacket;
support.onPacketReceived(dataPacket.getChannel(), dataPacket.getPayloadBytes(support.getAuthService()));
try {
support.onPacketReceived(dataPacket.getChannel(), dataPacket.getPayloadBytes(support.getAuthService()));
} catch (final Exception ex) {
LOG.error("Exception while handling received packet", ex);
}
// TODO: only directly ack protobuf packets, bulk ack others
sendAck(decodedPacket.getSequenceNumber());
break;