remove bleonly mode, use CAPod instead

This commit is contained in:
Kavish Devar
2025-09-28 12:30:09 +05:30
parent 3f582b8fcf
commit 1152f45a6c
3 changed files with 3 additions and 30 deletions

View File

@@ -131,7 +131,6 @@ import kotlin.io.encoding.ExperimentalEncodingApi
lateinit var serviceConnection: ServiceConnection
lateinit var connectionStatusReceiver: BroadcastReceiver
@ExperimentalHazeMaterialsApi
@ExperimentalMaterial3Api
class MainActivity : ComponentActivity() {
companion object {
@@ -427,7 +426,6 @@ fun Main() {
}
}
@ExperimentalHazeMaterialsApi
@OptIn(ExperimentalPermissionsApi::class, ExperimentalMaterial3Api::class)
@Composable
fun PermissionsScreen(

View File

@@ -173,16 +173,6 @@ fun AppSettingsScreen(navController: NavController) {
mutableStateOf(sharedPreferences.getBoolean("use_alternate_head_tracking_packets", false))
}
val bleOnlyMode = remember {
mutableStateOf(sharedPreferences.getBoolean("ble_only_mode", false))
}
LaunchedEffect(Unit) {
if (!sharedPreferences.contains("ble_only_mode")) {
sharedPreferences.edit { putBoolean("ble_only_mode", false) }
}
}
fun validateHexInput(input: String): Boolean {
val hexPattern = Regex("^[0-9a-fA-F]{32}$")
return hexPattern.matches(input)

View File

@@ -427,7 +427,6 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
if (!contains("qs_click_behavior")) putString("qs_click_behavior", "cycle")
if (!contains("name")) putString("name", "AirPods")
if (!contains("ble_only_mode")) putBoolean("ble_only_mode", false)
if (!contains("left_single_press_action")) putString(
"left_single_press_action",
@@ -612,7 +611,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
}
Log.d("AirPodsCrossDevice", CrossDevice.isAvailable.toString())
if (!CrossDevice.isAvailable && !config.bleOnlyMode) {
if (!CrossDevice.isAvailable) {
Log.d("AirPodsService", "${config.deviceName} connected")
CoroutineScope(Dispatchers.IO).launch {
connectToSocket(device!!)
@@ -624,12 +623,6 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
sharedPreferences.edit {
putString("mac_address", macAddress)
}
} else if (config.bleOnlyMode) {
Log.d("AirPodsService", "BLE-only mode: skipping L2CAP connection")
macAddress = device!!.address
sharedPreferences.edit {
putString("mac_address", macAddress)
}
}
} else if (intent?.action == AirPodsNotifications.AIRPODS_DISCONNECTED) {
device = null
@@ -695,7 +688,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
if (profile == BluetoothProfile.A2DP) {
val connectedDevices = proxy.connectedDevices
if (connectedDevices.isNotEmpty()) {
if (!CrossDevice.isAvailable && !config.bleOnlyMode) {
if (!CrossDevice.isAvailable) {
CoroutineScope(Dispatchers.IO).launch {
connectToSocket(device)
}
@@ -704,12 +697,6 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
sharedPreferences.edit {
putString("mac_address", macAddress)
}
} else if (config.bleOnlyMode) {
Log.d("AirPodsService", "BLE-only mode: skipping L2CAP connection")
macAddress = device.address
sharedPreferences.edit {
putString("mac_address", macAddress)
}
}
this@AirPodsService.sendBroadcast(
Intent(AirPodsNotifications.AIRPODS_CONNECTED)
@@ -1143,7 +1130,6 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
conversationalAwarenessVolume = sharedPreferences.getInt("conversational_awareness_volume", 43),
textColor = sharedPreferences.getLong("textColor", -1L),
qsClickBehavior = sharedPreferences.getString("qs_click_behavior", "cycle") ?: "cycle",
bleOnlyMode = sharedPreferences.getBoolean("ble_only_mode", false),
// AirPods state-based takeover
takeoverWhenDisconnected = sharedPreferences.getBoolean("takeover_when_disconnected", true),
@@ -1188,7 +1174,6 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
"conversational_awareness_volume" -> config.conversationalAwarenessVolume = preferences.getInt(key, 43)
"textColor" -> config.textColor = preferences.getLong(key, -1L)
"qs_click_behavior" -> config.qsClickBehavior = preferences.getString(key, "cycle") ?: "cycle"
"ble_only_mode" -> config.bleOnlyMode = preferences.getBoolean(key, false)
// AirPods state-based takeover
"takeover_when_disconnected" -> config.takeoverWhenDisconnected = preferences.getBoolean(key, true)
@@ -1686,7 +1671,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
if (!::socket.isInitialized && !config.bleOnlyMode) {
if (!::socket.isInitialized) {
return
}
if (connected && (config.bleOnlyMode || socket.isConnected)) {