422 lines
18 KiB
Java
422 lines
18 KiB
Java
package qbsg.top.ble;
|
|
public final class BleManager$gattCallback$1 extends android.bluetooth.BluetoothGattCallback {
|
|
final synthetic qbsg.top.ble.BleManager this$0;
|
|
|
|
public BleManager$gattCallback$1(qbsg.top.ble.BleManager p1)
|
|
{
|
|
this.this$0 = p1;
|
|
return;
|
|
}
|
|
|
|
private static final CharSequence onCharacteristicChanged$lambda$4(byte p1)
|
|
{
|
|
return String.format("%02x", java.util.Arrays.copyOf(new Object[] {Byte.valueOf(p1)}), 1));
|
|
}
|
|
|
|
public void onCharacteristicChanged(android.bluetooth.BluetoothGatt p2, android.bluetooth.BluetoothGattCharacteristic p3)
|
|
{
|
|
kotlin.jvm.internal.s.f(p2, "gatt");
|
|
kotlin.jvm.internal.s.f(p3, "char");
|
|
byte[] v0_2 = p3.getValue();
|
|
if (v0_2 == null) {
|
|
v0_2 = new byte[0];
|
|
}
|
|
this.onCharacteristicChanged(p2, p3, v0_2);
|
|
return;
|
|
}
|
|
|
|
public void onCharacteristicChanged(android.bluetooth.BluetoothGatt p7, android.bluetooth.BluetoothGattCharacteristic p8, byte[] p9)
|
|
{
|
|
kotlin.jvm.internal.s.f(p7, "gatt");
|
|
kotlin.jvm.internal.s.f(p8, "char");
|
|
kotlin.jvm.internal.s.f(p9, "value");
|
|
String v7_2 = p7.getDevice().getAddress();
|
|
p6.g v0_4 = ((qbsg.top.ble.BleManager$AndroidGattOtaChannel) qbsg.top.ble.BleManager.access$getOtaChannels$p(this.this$0).get(v7_2));
|
|
if (v0_4 != null) {
|
|
v0_4.forwardNotify(p8, p9);
|
|
}
|
|
String v8_2 = new StringBuilder();
|
|
v8_2.append("");
|
|
int v1 = p9.length;
|
|
int v2 = 0;
|
|
int v3 = 0;
|
|
while (v2 < v1) {
|
|
CharSequence v4_0 = p9[v2];
|
|
v3++;
|
|
if (v3 > 1) {
|
|
v8_2.append("");
|
|
}
|
|
v8_2.append(qbsg.top.ble.BleManager$gattCallback$1.onCharacteristicChanged$lambda$4(v4_0));
|
|
v2++;
|
|
}
|
|
v8_2.append("");
|
|
qbsg.top.ble.BleManager.access$get_messageEvents$p(this.this$0).tryEmit(new p6.g(v7_2, v8_2.toString()));
|
|
return;
|
|
}
|
|
|
|
public void onCharacteristicRead(android.bluetooth.BluetoothGatt p4, android.bluetooth.BluetoothGattCharacteristic p5, int p6)
|
|
{
|
|
byte[] v1_1;
|
|
kotlin.jvm.internal.s.f(p4, "gatt");
|
|
kotlin.jvm.internal.s.f(p5, "char");
|
|
if (p6 != null) {
|
|
v1_1 = new byte[0];
|
|
} else {
|
|
byte[] v1_2 = p5.getValue();
|
|
if (v1_2 == null) {
|
|
} else {
|
|
v1_1 = ((byte[]) v1_2.clone());
|
|
if (v1_1 == null) {
|
|
}
|
|
}
|
|
}
|
|
qbsg.top.ble.BleManager$AndroidGattOtaChannel v0_5 = ((qbsg.top.ble.BleManager$AndroidGattOtaChannel) qbsg.top.ble.BleManager.access$getOtaChannels$p(this.this$0).get(p4.getDevice().getAddress()));
|
|
if (v0_5 != null) {
|
|
v0_5.forwardCharacteristicRead(p5, v1_1, p6);
|
|
}
|
|
Object v4_4 = ((kotlinx.coroutines.channels.Channel) qbsg.top.ble.BleManager.access$getReadChannels$p(this.this$0).get(p4.getDevice().getAddress()));
|
|
if (v4_4 != null) {
|
|
kotlinx.coroutines.channels.ChannelResult.box-impl(v4_4.trySend-JP2dKIU(new p6.g(p5.getUuid(), v1_1)));
|
|
}
|
|
return;
|
|
}
|
|
|
|
public void onCharacteristicRead(android.bluetooth.BluetoothGatt p3, android.bluetooth.BluetoothGattCharacteristic p4, byte[] p5, int p6)
|
|
{
|
|
byte[] v5_2;
|
|
kotlin.jvm.internal.s.f(p3, "gatt");
|
|
kotlin.jvm.internal.s.f(p4, "char");
|
|
kotlin.jvm.internal.s.f(p5, "value");
|
|
if (p6 != null) {
|
|
v5_2 = new byte[0];
|
|
} else {
|
|
v5_2 = ((byte[]) p5.clone());
|
|
}
|
|
qbsg.top.ble.BleManager$AndroidGattOtaChannel v0_5 = ((qbsg.top.ble.BleManager$AndroidGattOtaChannel) qbsg.top.ble.BleManager.access$getOtaChannels$p(this.this$0).get(p3.getDevice().getAddress()));
|
|
if (v0_5 != null) {
|
|
v0_5.forwardCharacteristicRead(p4, v5_2, p6);
|
|
}
|
|
Object v3_4 = ((kotlinx.coroutines.channels.Channel) qbsg.top.ble.BleManager.access$getReadChannels$p(this.this$0).get(p3.getDevice().getAddress()));
|
|
if (v3_4 != null) {
|
|
kotlinx.coroutines.channels.ChannelResult.box-impl(v3_4.trySend-JP2dKIU(new p6.g(p4.getUuid(), v5_2)));
|
|
}
|
|
return;
|
|
}
|
|
|
|
public void onCharacteristicWrite(android.bluetooth.BluetoothGatt p2, android.bluetooth.BluetoothGattCharacteristic p3, int p4)
|
|
{
|
|
kotlin.jvm.internal.s.f(p2, "gatt");
|
|
kotlin.jvm.internal.s.f(p3, "char");
|
|
int v2_8 = p2.getDevice().getAddress();
|
|
boolean v0_3 = ((qbsg.top.ble.BleManager$AndroidGattOtaChannel) qbsg.top.ble.BleManager.access$getOtaChannels$p(this.this$0).get(v2_8));
|
|
if (!v0_3) {
|
|
int v2_3;
|
|
int v2_2 = ((qbsg.top.ble.data.BleConnectionInfo) ((java.util.Map) qbsg.top.ble.BleManager.access$get_connections$p(this.this$0).getValue()).get(v2_8));
|
|
qbsg.top.ble.BleSession v3_5 = 0;
|
|
if (v2_2 == 0) {
|
|
v2_3 = 0;
|
|
} else {
|
|
v2_3 = v2_2.getState();
|
|
}
|
|
int v2_4;
|
|
if (!(v2_3 instanceof qbsg.top.ble.data.DeviceConnectionState$Connected)) {
|
|
v2_4 = 0;
|
|
} else {
|
|
v2_4 = ((qbsg.top.ble.data.DeviceConnectionState$Connected) v2_3);
|
|
}
|
|
int v2_5;
|
|
if (v2_4 == 0) {
|
|
v2_5 = 0;
|
|
} else {
|
|
v2_5 = v2_4.getSession();
|
|
}
|
|
if ((v2_5 instanceof qbsg.top.ble.BleSession)) {
|
|
v3_5 = ((qbsg.top.ble.BleSession) v2_5);
|
|
}
|
|
if (v3_5 != null) {
|
|
int v2_6;
|
|
if (p4 != 0) {
|
|
v2_6 = 0;
|
|
} else {
|
|
v2_6 = 1;
|
|
}
|
|
v3_5.onWriteComplete$composeApp_release(v2_6);
|
|
}
|
|
return;
|
|
} else {
|
|
v0_3.forwardCharacteristicWrite(p3, p4);
|
|
return;
|
|
}
|
|
}
|
|
|
|
public void onConnectionStateChange(android.bluetooth.BluetoothGatt p12, int p13, int p14)
|
|
{
|
|
qbsg.top.ble.data.BleDeviceInfo v0_5;
|
|
kotlin.jvm.internal.s.f(p12, "gatt");
|
|
String v2_1 = p12.getDevice().getAddress();
|
|
qbsg.top.ble.data.BleDeviceInfo v0_4 = ((qbsg.top.ble.data.BleConnectionInfo) ((java.util.Map) qbsg.top.ble.BleManager.access$get_connections$p(this.this$0).getValue()).get(v2_1));
|
|
if (v0_4 == null) {
|
|
qbsg.top.ble.data.BleDeviceInfo v0_7 = p12.getDevice().getName();
|
|
if (v0_7 == null) {
|
|
v0_7 = "\u672a\u77e5";
|
|
}
|
|
kotlin.jvm.internal.s.c(v2_1);
|
|
int v3_0 = v2_1;
|
|
v2_1 = v3_0;
|
|
v0_5 = new qbsg.top.ble.data.BleDeviceInfo(v0_7, v3_0, 0, 0, 0, 0, 0, 120, 0);
|
|
} else {
|
|
v0_5 = v0_4.getDevice();
|
|
if (v0_5 == null) {
|
|
}
|
|
}
|
|
if (p14 == 0) {
|
|
if (!qbsg.top.ble.BleManager.access$getUserInitiatedDisconnections$p(this.this$0).remove(v2_1)) {
|
|
qbsg.top.ble.data.DisconnectReason$GattError v12_10;
|
|
qbsg.top.ble.data.DisconnectReason$GattError v12_9 = ((qbsg.top.ble.data.BleConnectionInfo) ((java.util.Map) qbsg.top.ble.BleManager.access$get_connections$p(this.this$0).getValue()).get(v2_1));
|
|
if (v12_9 == null) {
|
|
v12_10 = 0;
|
|
} else {
|
|
v12_10 = v12_9.getState();
|
|
}
|
|
qbsg.top.ble.data.DisconnectReason$GattError v12_14;
|
|
if ((v12_10 instanceof qbsg.top.ble.data.DeviceConnectionState$Connected)) {
|
|
if (p13 != null) {
|
|
if (p13 == 8) {
|
|
v12_14 = new qbsg.top.ble.data.DisconnectReason$OutOfRange(v0_5);
|
|
int v14_4 = ((qbsg.top.ble.BleManager$AndroidGattOtaChannel) qbsg.top.ble.BleManager.access$getOtaChannels$p(this.this$0).get(v2_1));
|
|
if (v14_4 != 0) {
|
|
v14_4.notifyDisconnect(p13);
|
|
}
|
|
qbsg.top.ble.BleManager v13_1 = this.this$0;
|
|
kotlin.jvm.internal.s.c(v2_1);
|
|
qbsg.top.ble.BleManager.access$cleanupDevice(v13_1, v2_1, 1, v12_14);
|
|
return;
|
|
} else {
|
|
if (p13 != 19) {
|
|
v12_14 = new qbsg.top.ble.data.DisconnectReason$GattError(v0_5, p13);
|
|
}
|
|
}
|
|
}
|
|
v12_14 = new qbsg.top.ble.data.DisconnectReason$DeviceDisconnected(v0_5);
|
|
} else {
|
|
v12_14 = new qbsg.top.ble.data.DisconnectReason$ConnectFailed(v0_5, p13);
|
|
}
|
|
} else {
|
|
qbsg.top.ble.BleManager v1_2 = this.this$0;
|
|
kotlin.jvm.internal.s.c(v2_1);
|
|
qbsg.top.ble.BleManager.cleanupDevice$default(v1_2, v2_1, 0, 0, 4, 0);
|
|
return;
|
|
}
|
|
} else {
|
|
if (p14 == 2) {
|
|
p12.discoverServices();
|
|
return;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void onDescriptorWrite(android.bluetooth.BluetoothGatt p2, android.bluetooth.BluetoothGattDescriptor p3, int p4)
|
|
{
|
|
kotlin.jvm.internal.s.f(p2, "gatt");
|
|
kotlin.jvm.internal.s.f(p3, "descriptor");
|
|
String v2_2 = p2.getDevice().getAddress();
|
|
int v3_3 = ((qbsg.top.ble.BleManager$AndroidGattOtaChannel) qbsg.top.ble.BleManager.access$getOtaChannels$p(this.this$0).get(v2_2));
|
|
if (v3_3 != 0) {
|
|
v3_3.forwardDescriptorWrite(p4);
|
|
}
|
|
qbsg.top.ble.BleManager.access$getDescriptorWriteQueue$p(this.this$0).poll();
|
|
qbsg.top.ble.BleManager v4_1 = 0;
|
|
qbsg.top.ble.BleManager.access$setWritingDescriptor$p(this.this$0, 0);
|
|
qbsg.top.ble.BleManager.access$processDescriptorQueue(this.this$0);
|
|
int v3_11 = ((Integer) qbsg.top.ble.BleManager.access$getPendingCccdCount$p(this.this$0).get(v2_2));
|
|
if (v3_11 != 0) {
|
|
v4_1 = v3_11.intValue();
|
|
}
|
|
qbsg.top.ble.BleManager v4_2 = (v4_1 - 1);
|
|
if (v4_2 > null) {
|
|
qbsg.top.ble.BleManager.access$getPendingCccdCount$p(this.this$0).put(v2_2, Integer.valueOf(v4_2));
|
|
return;
|
|
} else {
|
|
qbsg.top.ble.BleManager.access$getPendingCccdCount$p(this.this$0).remove(v2_2);
|
|
int v3_19 = ((String) qbsg.top.ble.BleManager.access$getPendingFirmware$p(this.this$0).remove(v2_2));
|
|
if (v3_19 != 0) {
|
|
qbsg.top.ble.BleManager v4_4 = this.this$0;
|
|
kotlin.jvm.internal.s.c(v2_2);
|
|
if (v3_19.length() == 0) {
|
|
v3_19 = 0;
|
|
}
|
|
qbsg.top.ble.BleManager.access$updateDeviceInfo(v4_4, v2_2, v3_19);
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
public void onMtuChanged(android.bluetooth.BluetoothGatt p7, int p8, int p9)
|
|
{
|
|
int v1_1;
|
|
kotlin.jvm.internal.s.f(p7, "gatt");
|
|
String v0_2 = p7.getDevice().getAddress();
|
|
if (p9 != null) {
|
|
v1_1 = 23;
|
|
} else {
|
|
v1_1 = p8;
|
|
}
|
|
java.util.Iterator v2_2 = ((qbsg.top.ble.BleManager$AndroidGattOtaChannel) qbsg.top.ble.BleManager.access$getOtaChannels$p(this.this$0).get(v0_2));
|
|
if (v2_2 != null) {
|
|
v2_2.forwardMtuChanged(p8, p9);
|
|
}
|
|
qbsg.top.ble.BleManager v8_7;
|
|
qbsg.top.ble.BleManager v8_6 = ((qbsg.top.ble.data.BleConnectionInfo) ((java.util.Map) qbsg.top.ble.BleManager.access$get_connections$p(this.this$0).getValue()).get(v0_2));
|
|
java.util.concurrent.ConcurrentHashMap v9_1 = 0;
|
|
if (v8_6 == null) {
|
|
v8_7 = 0;
|
|
} else {
|
|
v8_7 = v8_6.getState();
|
|
}
|
|
qbsg.top.ble.BleManager v8_8;
|
|
if (!(v8_7 instanceof qbsg.top.ble.data.DeviceConnectionState$Connected)) {
|
|
v8_8 = 0;
|
|
} else {
|
|
v8_8 = ((qbsg.top.ble.data.DeviceConnectionState$Connected) v8_7);
|
|
}
|
|
qbsg.top.ble.BleManager v8_9;
|
|
if (v8_8 == null) {
|
|
v8_9 = 0;
|
|
} else {
|
|
v8_9 = v8_8.getSession();
|
|
}
|
|
qbsg.top.ble.BleManager v8_10;
|
|
if (!(v8_9 instanceof qbsg.top.ble.BleSession)) {
|
|
v8_10 = 0;
|
|
} else {
|
|
v8_10 = ((qbsg.top.ble.BleSession) v8_9);
|
|
}
|
|
if (v8_10 != null) {
|
|
v8_10.setNegotiatedMtu$composeApp_release(v1_1);
|
|
}
|
|
qbsg.top.ble.BleManager v8_12 = p7.getServices().iterator();
|
|
int v1_0 = 0;
|
|
while (v8_12.hasNext()) {
|
|
java.util.Iterator v2_9 = ((android.bluetooth.BluetoothGattService) v8_12.next()).getCharacteristics().iterator();
|
|
while (v2_9.hasNext()) {
|
|
boolean v3_2 = ((android.bluetooth.BluetoothGattCharacteristic) v2_9.next());
|
|
qbsg.top.ble.BleManager v4_0 = v3_2.getProperties();
|
|
if ((((v4_0 & 16) != 0) || ((v4_0 & 32) != 0)) && (qbsg.top.ble.BleManager.access$enqueueNotify(this.this$0, p7, v3_2))) {
|
|
v1_0++;
|
|
}
|
|
}
|
|
}
|
|
if (v1_0 != 0) {
|
|
qbsg.top.ble.BleManager.access$getPendingCccdCount$p(this.this$0).put(v0_2, Integer.valueOf(v1_0));
|
|
return;
|
|
} else {
|
|
java.util.concurrent.ConcurrentHashMap v7_6 = ((String) qbsg.top.ble.BleManager.access$getPendingFirmware$p(this.this$0).remove(v0_2));
|
|
if (v7_6 != null) {
|
|
qbsg.top.ble.BleManager v8_14 = this.this$0;
|
|
kotlin.jvm.internal.s.c(v0_2);
|
|
if (v7_6.length() != 0) {
|
|
v9_1 = v7_6;
|
|
}
|
|
qbsg.top.ble.BleManager.access$updateDeviceInfo(v8_14, v0_2, v9_1);
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
public void onServicesDiscovered(android.bluetooth.BluetoothGatt p19, int p20)
|
|
{
|
|
kotlin.jvm.internal.s.f(p19, "gatt");
|
|
if (p20 == 0) {
|
|
Object v2_3;
|
|
String v5 = p19.getDevice().getAddress();
|
|
Object v2_1 = p19.getService(qbsg.top.ble.BleManagerKt.access$getTX_SERVICE_UUID$p());
|
|
if (v2_1 == null) {
|
|
v2_3 = 0;
|
|
} else {
|
|
v2_3 = v2_1.getCharacteristic(qbsg.top.ble.BleManagerKt.access$getTX_CHAR_UUID$p());
|
|
}
|
|
kotlinx.coroutines.flow.MutableStateFlow v14 = qbsg.top.ble.BleManager.access$get_connections$p(this.this$0);
|
|
qbsg.top.ble.BleManager v15 = this.this$0;
|
|
while(true) {
|
|
Object v2_6;
|
|
Object v16_0;
|
|
java.util.Map v13;
|
|
kotlinx.coroutines.flow.MutableStateFlow v6_2;
|
|
qbsg.top.ble.data.BleConnectionInfo v3_8 = v14.getValue();
|
|
java.util.Map v4_7 = ((java.util.Map) v3_8);
|
|
kotlinx.coroutines.flow.MutableStateFlow v6_1 = ((qbsg.top.ble.data.BleConnectionInfo) v4_7.get(v5));
|
|
if (v6_1 == null) {
|
|
kotlinx.coroutines.flow.MutableStateFlow v6_3 = v3_8;
|
|
qbsg.top.ble.data.DeviceConnectionState$Connected v7_6 = p19.getDevice().getName();
|
|
if (v7_6 == null) {
|
|
v7_6 = "\u8bbe\u5907";
|
|
}
|
|
kotlin.jvm.internal.s.c(v5);
|
|
v13 = v4_7;
|
|
v16_0 = v2_3;
|
|
v2_6 = v6_3;
|
|
v6_2 = new qbsg.top.ble.data.BleDeviceInfo(v7_6, v5, 0, 0, 0, 0, 0, 120, 0);
|
|
} else {
|
|
v6_2 = v6_1.getDevice();
|
|
if (v6_2 != null) {
|
|
v16_0 = v2_3;
|
|
v2_6 = v3_8;
|
|
v13 = v4_7;
|
|
}
|
|
}
|
|
android.bluetooth.BluetoothGattCharacteristic v8_3;
|
|
qbsg.top.ble.BleManager.access$get_targetSessionMac$p(v15).setValue(v5);
|
|
qbsg.top.ble.BleManager.access$get_activeDevice$p(v15).setValue(v6_2);
|
|
if (v16_0 != null) {
|
|
v8_3 = v16_0;
|
|
} else {
|
|
qbsg.top.ble.data.BleConnectionInfo v3_13 = p19.getServices();
|
|
kotlin.jvm.internal.s.e(v3_13, "getServices(...)");
|
|
java.util.Map v4_11 = new java.util.ArrayList();
|
|
qbsg.top.ble.data.BleConnectionInfo v3_14 = v3_13.iterator();
|
|
while (v3_14.hasNext()) {
|
|
qbsg.top.ble.data.DeviceConnectionState$Connected v7_4 = ((android.bluetooth.BluetoothGattService) v3_14.next()).getCharacteristics();
|
|
kotlin.jvm.internal.s.e(v7_4, "getCharacteristics(...)");
|
|
q6.o.f0(v4_11, v7_4);
|
|
}
|
|
qbsg.top.ble.data.BleConnectionInfo v3_15 = v4_11.size();
|
|
qbsg.top.ble.data.DeviceConnectionState$Connected v7_9 = 0;
|
|
while (v7_9 < v3_15) {
|
|
android.bluetooth.BluetoothGattCharacteristic v8_4 = v4_11.get(v7_9);
|
|
v7_9++;
|
|
if ((((android.bluetooth.BluetoothGattCharacteristic) v8_4).getProperties() & 8) != 0) {
|
|
}
|
|
v8_3 = ((android.bluetooth.BluetoothGattCharacteristic) v8_4);
|
|
}
|
|
v8_4 = 0;
|
|
}
|
|
java.util.Map v4_5;
|
|
if (v8_3 == null) {
|
|
v4_5 = v13;
|
|
} else {
|
|
qbsg.top.ble.data.BleConnectionInfo v3_2;
|
|
qbsg.top.ble.data.BleConnectionInfo v3_1 = p19.getService(qbsg.top.ble.BleManagerKt.access$getEPD_SERVICE_UUID$p());
|
|
if (v3_1 == null) {
|
|
v3_2 = 0;
|
|
} else {
|
|
v3_2 = v3_1.getCharacteristic(qbsg.top.ble.BleManagerKt.access$getEPD_CHAR_UUID$p());
|
|
}
|
|
java.util.Map v4_2 = new qbsg.top.ble.BleSession(p19, v8_3, v3_2);
|
|
v4_2.setNegotiatedMtu$composeApp_release(23);
|
|
v4_5 = q6.y.L(v13, new p6.g(v5, new qbsg.top.ble.data.BleConnectionInfo(v6_2, new qbsg.top.ble.data.DeviceConnectionState$Connected(v4_2))));
|
|
}
|
|
if (v14.compareAndSet(v2_6, v4_5)) {
|
|
break;
|
|
}
|
|
v2_3 = v16_0;
|
|
}
|
|
qbsg.top.ble.BleManager.access$startDeviceInfoRead(this.this$0, p19);
|
|
return;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
}
|