package qbsg.top.ble; final class BleManager$AndroidGattOtaChannel implements qbsg.top.ble.GattOtaChannel { private final kotlinx.coroutines.channels.Channel descResult; private a7.c disconnectCb; private final android.bluetooth.BluetoothGatt gatt; private final kotlinx.coroutines.channels.Channel mtuResult; private final kotlinx.coroutines.channels.Channel notifyEvents; private final kotlinx.coroutines.channels.Channel readResult; final synthetic qbsg.top.ble.BleManager this$0; private final kotlinx.coroutines.channels.Channel writeResult; public BleManager$AndroidGattOtaChannel(qbsg.top.ble.BleManager p4, android.bluetooth.BluetoothGatt p5) { kotlin.jvm.internal.s.f(p5, "gatt"); this.this$0 = p4; this.gatt = p5; this.writeResult = kotlinx.coroutines.channels.ChannelKt.Channel$default(1, 0, 0, 6, 0); this.readResult = kotlinx.coroutines.channels.ChannelKt.Channel$default(2147483647, 0, 0, 6, 0); this.mtuResult = kotlinx.coroutines.channels.ChannelKt.Channel$default(1, 0, 0, 6, 0); this.descResult = kotlinx.coroutines.channels.ChannelKt.Channel$default(1, 0, 0, 6, 0); this.notifyEvents = kotlinx.coroutines.channels.ChannelKt.Channel$default(2147483647, 0, 0, 6, 0); return; } public void enableNotification(String p2, String p3) { kotlin.jvm.internal.s.f(p2, "serviceUuid"); kotlin.jvm.internal.s.f(p3, "charUuid"); android.bluetooth.BluetoothGattCharacteristic v2_3 = this.gatt.getService(java.util.UUID.fromString(p2)); if (v2_3 != null) { android.bluetooth.BluetoothGattCharacteristic v2_1 = v2_3.getCharacteristic(java.util.UUID.fromString(p3)); if (v2_1 != null) { this.gatt.setCharacteristicNotification(v2_1, 1); } } return; } public final void forwardCharacteristicRead(android.bluetooth.BluetoothGattCharacteristic p2, byte[] p3, int p4) { kotlin.jvm.internal.s.f(p2, "c"); kotlin.jvm.internal.s.f(p3, "data"); kotlinx.coroutines.channels.Channel v4_2 = this.getReadResult(); String v2_3 = p2.getUuid().toString(); kotlin.jvm.internal.s.e(v2_3, "toString(...)"); String v2_1 = v2_3.toLowerCase(java.util.Locale.ROOT); kotlin.jvm.internal.s.e(v2_1, "toLowerCase(...)"); v4_2.trySend-JP2dKIU(new p6.g(v2_1, p3)); return; } public final void forwardCharacteristicWrite(android.bluetooth.BluetoothGattCharacteristic p2, int p3) { Boolean v3_1; kotlin.jvm.internal.s.f(p2, "c"); kotlinx.coroutines.channels.Channel v2_1 = this.getWriteResult(); if (p3 != null) { v3_1 = 0; } else { v3_1 = 1; } v2_1.trySend-JP2dKIU(Boolean.valueOf(v3_1)); return; } public final void forwardDescriptorWrite(int p2) { Boolean v2_1; kotlinx.coroutines.channels.Channel v0 = this.getDescResult(); if (p2 != null) { v2_1 = 0; } else { v2_1 = 1; } v0.trySend-JP2dKIU(Boolean.valueOf(v2_1)); return; } public final void forwardMtuChanged(int p2, int p3) { kotlinx.coroutines.channels.Channel v0 = this.getMtuResult(); if (p3 != 0) { p2 = 23; } v0.trySend-JP2dKIU(Integer.valueOf(p2)); return; } public final void forwardNotify(android.bluetooth.BluetoothGattCharacteristic p3, byte[] p4) { kotlin.jvm.internal.s.f(p3, "c"); kotlin.jvm.internal.s.f(p4, "value"); kotlinx.coroutines.channels.Channel v0_2 = this.getNotifyEvents(); String v3_3 = p3.getUuid().toString(); kotlin.jvm.internal.s.e(v3_3, "toString(...)"); String v3_1 = v3_3.toLowerCase(java.util.Locale.ROOT); kotlin.jvm.internal.s.e(v3_1, "toLowerCase(...)"); v0_2.trySend-JP2dKIU(new p6.g(v3_1, p4)); return; } public kotlinx.coroutines.channels.Channel getDescResult() { return this.descResult; } public kotlinx.coroutines.channels.Channel getMtuResult() { return this.mtuResult; } public kotlinx.coroutines.channels.Channel getNotifyEvents() { return this.notifyEvents; } public kotlinx.coroutines.channels.Channel getReadResult() { return this.readResult; } public kotlinx.coroutines.channels.Channel getWriteResult() { return this.writeResult; } public boolean hasCharacteristic(String p2, String p3) { int v2_1; kotlin.jvm.internal.s.f(p2, "serviceUuid"); kotlin.jvm.internal.s.f(p3, "charUuid"); int v2_5 = this.gatt.getService(java.util.UUID.fromString(p2)); if (v2_5 == 0) { v2_1 = 0; } else { v2_1 = v2_5.getCharacteristic(java.util.UUID.fromString(p3)); } if (v2_1 == 0) { return 0; } else { return 1; } } public boolean hasService(String p2) { kotlin.jvm.internal.s.f(p2, "serviceUuid"); if (this.gatt.getService(java.util.UUID.fromString(p2)) == null) { return 0; } else { return 1; } } public final void notifyDisconnect(int p2) { a7.c v0 = this.disconnectCb; if (v0 != null) { v0.invoke(Integer.valueOf(p2)); } return; } public void readCharacteristic(String p2, String p3) { kotlin.jvm.internal.s.f(p2, "serviceUuid"); kotlin.jvm.internal.s.f(p3, "charUuid"); android.bluetooth.BluetoothGattCharacteristic v2_3 = this.gatt.getService(java.util.UUID.fromString(p2)); if (v2_3 != null) { android.bluetooth.BluetoothGattCharacteristic v2_1 = v2_3.getCharacteristic(java.util.UUID.fromString(p3)); if (v2_1 != null) { this.gatt.readCharacteristic(v2_1); } } return; } public void requestBalancedPriority() { this.gatt.requestConnectionPriority(0); return; } public void requestHighPriority() { this.gatt.requestConnectionPriority(1); return; } public void requestMtu(int p2) { this.gatt.requestMtu(p2); return; } public void setDisconnectCallback(a7.c p2) { kotlin.jvm.internal.s.f(p2, "cb"); this.disconnectCb = p2; return; } public void writeCharacteristic(String p2, String p3, byte[] p4, boolean p5) { kotlin.jvm.internal.s.f(p2, "serviceUuid"); kotlin.jvm.internal.s.f(p3, "charUuid"); kotlin.jvm.internal.s.f(p4, "data"); android.bluetooth.BluetoothGattCharacteristic v2_1 = this.gatt.getService(java.util.UUID.fromString(p2)); if (v2_1 != null) { android.bluetooth.BluetoothGattCharacteristic v2_2 = v2_1.getCharacteristic(java.util.UUID.fromString(p3)); if (v2_2 != null) { android.bluetooth.BluetoothGatt v3_2; if (p5 == null) { v3_2 = 1; } else { v3_2 = 2; } if (android.os.Build$VERSION.SDK_INT < 33) { v2_2.setValue(p4); v2_2.setWriteType(v3_2); this.gatt.writeCharacteristic(v2_2); } else { b.b.q(this.gatt, v2_2, p4, v3_2); return; } } } return; } public void writeDescriptor(String p2, String p3, String p4, byte[] p5) { kotlin.jvm.internal.s.f(p2, "serviceUuid"); kotlin.jvm.internal.s.f(p3, "charUuid"); kotlin.jvm.internal.s.f(p4, "descUuid"); kotlin.jvm.internal.s.f(p5, "data"); android.bluetooth.BluetoothGattDescriptor v2_2 = this.gatt.getService(java.util.UUID.fromString(p2)); if (v2_2 != null) { android.bluetooth.BluetoothGattDescriptor v2_3 = v2_2.getCharacteristic(java.util.UUID.fromString(p3)); if (v2_3 != null) { android.bluetooth.BluetoothGattDescriptor v2_4 = v2_3.getDescriptor(java.util.UUID.fromString(p4)); if (v2_4 != null) { if (android.os.Build$VERSION.SDK_INT < 33) { v2_4.setValue(p5); this.gatt.writeDescriptor(v2_4); } else { b.b.r(this.gatt, v2_4, p5); return; } } } } return; } }