mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-15 02:36:12 -04:00
New compatibility option for receiving BLE data (#82)
* Improve compat options: Add alternative method for receiving BLE scan results via PendingIntents * Add missing logtags * Reduce log spam * Make the linter happy
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package eu.darken.capod.common.notifications
|
||||
|
||||
import android.app.PendingIntent
|
||||
import eu.darken.capod.common.hasApiLevel
|
||||
|
||||
object PendingIntentCompat {
|
||||
val FLAG_IMMUTABLE: Int = if (hasApiLevel(31)) {
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,9 @@ class BluetoothEventReceiver : BroadcastReceiver() {
|
||||
@Inject @AppScope lateinit var appScope: CoroutineScope
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
log { "onReceive($context, $intent)" }
|
||||
log(TAG) { "onReceive($context, $intent)" }
|
||||
if (!EXPECTED_ACTIONS.contains(intent.action)) {
|
||||
log(WARN) { "Unknown action: $intent.action" }
|
||||
log(TAG, WARN) { "Unknown action: ${intent.action}" }
|
||||
return
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class BluetoothEventReceiver : BroadcastReceiver() {
|
||||
val supportedFeatures = ContinuityProtocol.BLE_FEATURE_UUIDS.filter { bluetoothDevice.hasFeature(it) }
|
||||
|
||||
if (supportedFeatures.isEmpty()) {
|
||||
log { "Device has no features we support." }
|
||||
log(TAG) { "Device has no features we support." }
|
||||
return
|
||||
} else {
|
||||
log { "Device has the following we features we support $supportedFeatures" }
|
||||
@@ -49,7 +49,7 @@ class BluetoothEventReceiver : BroadcastReceiver() {
|
||||
|
||||
val pending = goAsync()
|
||||
appScope.launch {
|
||||
log { "Starting monitor" }
|
||||
log(TAG) { "Starting monitor" }
|
||||
monitorControl.startMonitor(bluetoothDevice, forceStart = false)
|
||||
pending.finish()
|
||||
}
|
||||
|
||||
@@ -100,4 +100,6 @@
|
||||
<string name="translators_thanks_description">darken</string>
|
||||
|
||||
<string name="widget_description">A widget showing the last known device status.</string>
|
||||
<string name="settings_compat_indirectcallback_title">Indirect data delivery</string>
|
||||
<string name="settings_compat_indirectcallback_summary">Use an alternative method to receive BLE data from the system (broadcast instead of callback).</string>
|
||||
</resources>
|
||||
@@ -61,6 +61,12 @@
|
||||
android:summary="@string/settings_compat_offloaded_batching_disabled_summary"
|
||||
android:title="@string/settings_compat_offloaded_batching_disabled_title" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:icon="@drawable/ic_strategy_24"
|
||||
android:key="core.compat.indirectcallback.enabled"
|
||||
android:summary="@string/settings_compat_indirectcallback_summary"
|
||||
android:title="@string/settings_compat_indirectcallback_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_other_label">
|
||||
|
||||
Reference in New Issue
Block a user