mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-04-29 09:33:04 +00:00
remove bleonly mode, use CAPod instead
This commit is contained in:
@@ -131,7 +131,6 @@ import kotlin.io.encoding.ExperimentalEncodingApi
|
|||||||
lateinit var serviceConnection: ServiceConnection
|
lateinit var serviceConnection: ServiceConnection
|
||||||
lateinit var connectionStatusReceiver: BroadcastReceiver
|
lateinit var connectionStatusReceiver: BroadcastReceiver
|
||||||
|
|
||||||
@ExperimentalHazeMaterialsApi
|
|
||||||
@ExperimentalMaterial3Api
|
@ExperimentalMaterial3Api
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -427,7 +426,6 @@ fun Main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExperimentalHazeMaterialsApi
|
|
||||||
@OptIn(ExperimentalPermissionsApi::class, ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalPermissionsApi::class, ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun PermissionsScreen(
|
fun PermissionsScreen(
|
||||||
|
|||||||
@@ -173,16 +173,6 @@ fun AppSettingsScreen(navController: NavController) {
|
|||||||
mutableStateOf(sharedPreferences.getBoolean("use_alternate_head_tracking_packets", false))
|
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 {
|
fun validateHexInput(input: String): Boolean {
|
||||||
val hexPattern = Regex("^[0-9a-fA-F]{32}$")
|
val hexPattern = Regex("^[0-9a-fA-F]{32}$")
|
||||||
return hexPattern.matches(input)
|
return hexPattern.matches(input)
|
||||||
|
|||||||
@@ -427,7 +427,6 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
|
|
||||||
if (!contains("qs_click_behavior")) putString("qs_click_behavior", "cycle")
|
if (!contains("qs_click_behavior")) putString("qs_click_behavior", "cycle")
|
||||||
if (!contains("name")) putString("name", "AirPods")
|
if (!contains("name")) putString("name", "AirPods")
|
||||||
if (!contains("ble_only_mode")) putBoolean("ble_only_mode", false)
|
|
||||||
|
|
||||||
if (!contains("left_single_press_action")) putString(
|
if (!contains("left_single_press_action")) putString(
|
||||||
"left_single_press_action",
|
"left_single_press_action",
|
||||||
@@ -612,7 +611,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log.d("AirPodsCrossDevice", CrossDevice.isAvailable.toString())
|
Log.d("AirPodsCrossDevice", CrossDevice.isAvailable.toString())
|
||||||
if (!CrossDevice.isAvailable && !config.bleOnlyMode) {
|
if (!CrossDevice.isAvailable) {
|
||||||
Log.d("AirPodsService", "${config.deviceName} connected")
|
Log.d("AirPodsService", "${config.deviceName} connected")
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
connectToSocket(device!!)
|
connectToSocket(device!!)
|
||||||
@@ -624,12 +623,6 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
sharedPreferences.edit {
|
sharedPreferences.edit {
|
||||||
putString("mac_address", macAddress)
|
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) {
|
} else if (intent?.action == AirPodsNotifications.AIRPODS_DISCONNECTED) {
|
||||||
device = null
|
device = null
|
||||||
@@ -695,7 +688,7 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
if (profile == BluetoothProfile.A2DP) {
|
if (profile == BluetoothProfile.A2DP) {
|
||||||
val connectedDevices = proxy.connectedDevices
|
val connectedDevices = proxy.connectedDevices
|
||||||
if (connectedDevices.isNotEmpty()) {
|
if (connectedDevices.isNotEmpty()) {
|
||||||
if (!CrossDevice.isAvailable && !config.bleOnlyMode) {
|
if (!CrossDevice.isAvailable) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
connectToSocket(device)
|
connectToSocket(device)
|
||||||
}
|
}
|
||||||
@@ -704,12 +697,6 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
sharedPreferences.edit {
|
sharedPreferences.edit {
|
||||||
putString("mac_address", macAddress)
|
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(
|
this@AirPodsService.sendBroadcast(
|
||||||
Intent(AirPodsNotifications.AIRPODS_CONNECTED)
|
Intent(AirPodsNotifications.AIRPODS_CONNECTED)
|
||||||
@@ -1143,7 +1130,6 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
|
|||||||
conversationalAwarenessVolume = sharedPreferences.getInt("conversational_awareness_volume", 43),
|
conversationalAwarenessVolume = sharedPreferences.getInt("conversational_awareness_volume", 43),
|
||||||
textColor = sharedPreferences.getLong("textColor", -1L),
|
textColor = sharedPreferences.getLong("textColor", -1L),
|
||||||
qsClickBehavior = sharedPreferences.getString("qs_click_behavior", "cycle") ?: "cycle",
|
qsClickBehavior = sharedPreferences.getString("qs_click_behavior", "cycle") ?: "cycle",
|
||||||
bleOnlyMode = sharedPreferences.getBoolean("ble_only_mode", false),
|
|
||||||
|
|
||||||
// AirPods state-based takeover
|
// AirPods state-based takeover
|
||||||
takeoverWhenDisconnected = sharedPreferences.getBoolean("takeover_when_disconnected", true),
|
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)
|
"conversational_awareness_volume" -> config.conversationalAwarenessVolume = preferences.getInt(key, 43)
|
||||||
"textColor" -> config.textColor = preferences.getLong(key, -1L)
|
"textColor" -> config.textColor = preferences.getLong(key, -1L)
|
||||||
"qs_click_behavior" -> config.qsClickBehavior = preferences.getString(key, "cycle") ?: "cycle"
|
"qs_click_behavior" -> config.qsClickBehavior = preferences.getString(key, "cycle") ?: "cycle"
|
||||||
"ble_only_mode" -> config.bleOnlyMode = preferences.getBoolean(key, false)
|
|
||||||
|
|
||||||
// AirPods state-based takeover
|
// AirPods state-based takeover
|
||||||
"takeover_when_disconnected" -> config.takeoverWhenDisconnected = preferences.getBoolean(key, true)
|
"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
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!::socket.isInitialized && !config.bleOnlyMode) {
|
if (!::socket.isInitialized) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (connected && (config.bleOnlyMode || socket.isConnected)) {
|
if (connected && (config.bleOnlyMode || socket.isConnected)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user