add A16QPR3 constructor for ATT

i really need to clean this up
This commit is contained in:
Kavish Devar
2026-03-29 16:22:16 +05:30
parent 45f53d5cd4
commit 555a000def
2 changed files with 6 additions and 4 deletions

View File

@@ -2419,7 +2419,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
BluetoothConnectionManager.setCurrentConnection(socket, device)
attManager = ATTManager(device)
attManager = ATTManager(adapter, device)
attManager!!.connect()
// Create AirPodsInstance from stored config if available

View File

@@ -24,6 +24,7 @@
package me.kavishdevar.librepods.utils
import android.annotation.SuppressLint
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothSocket
import android.os.ParcelUuid
@@ -49,7 +50,7 @@ enum class ATTCCCDHandles(val value: Int) {
HEARING_AID(ATTHandles.HEARING_AID.value + 1),
}
class ATTManager(private val device: BluetoothDevice) {
class ATTManager(private val adapter: BluetoothAdapter, private val device: BluetoothDevice) {
companion object {
private const val TAG = "ATTManager"
@@ -72,7 +73,7 @@ class ATTManager(private val device: BluetoothDevice) {
HiddenApiBypass.addHiddenApiExemptions("Landroid/bluetooth/BluetoothSocket;")
val uuid = ParcelUuid.fromString("00000000-0000-0000-0000-000000000000")
socket = createBluetoothSocket(device, uuid)
socket = createBluetoothSocket(adapter, device, uuid)
socket!!.connect()
input = socket!!.inputStream
output = socket!!.outputStream
@@ -195,9 +196,10 @@ class ATTManager(private val device: BluetoothDevice) {
}
}
private fun createBluetoothSocket(device: BluetoothDevice, uuid: ParcelUuid): BluetoothSocket {
private fun createBluetoothSocket(adapter: BluetoothAdapter, device: BluetoothDevice, uuid: ParcelUuid): BluetoothSocket {
val type = 3 // L2CAP
val constructorSpecs = listOf(
arrayOf(adapter, device, type, true, 31, uuid),
arrayOf(device, type, true, true, 31, uuid),
arrayOf(device, type, 1, true, true, 31, uuid),
arrayOf(type, 1, true, true, device, 31, uuid),