fix: Pre-release cleanup of manifest, resource leaks, and dependencies

- Fix BleScanResultReceiver package name in manifest (.bluetooth → .common.bluetooth)
- Fix HandlerThread leak in BluetoothManager2 when registerReceiver() throws
- Cache battery values in MonitorNotifications to match hardening pattern
- Remove duplicate fragment-ktx dependency and align fragment-testing version
- Remove deprecated lifecycle-extensions dependency
This commit is contained in:
darken
2026-02-09 15:50:39 +01:00
committed by Matthias Urhahn
parent cfed733fa7
commit 12d2c4dd06
4 changed files with 13 additions and 9 deletions
+1 -1
View File
@@ -59,7 +59,7 @@
</activity> </activity>
<receiver <receiver
android:name=".bluetooth.BleScanResultReceiver" android:name=".common.bluetooth.BleScanResultReceiver"
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
<action android:name="eu.darken.capod.bluetooth.DELIVER_SCAN_RESULTS" /> <action android:name="eu.darken.capod.bluetooth.DELIVER_SCAN_RESULTS" />
@@ -212,6 +212,7 @@ class BluetoothManager2 @Inject constructor(
context.registerReceiver(receiver, filter, null, handler) context.registerReceiver(receiver, filter, null, handler)
} catch (e: Exception) { } catch (e: Exception) {
log(TAG, ERROR) { "monitorProfile(): Failed to register receiver: $e" } log(TAG, ERROR) { "monitorProfile(): Failed to register receiver: $e" }
handlerThread.quitSafely()
close(e) close(e)
return@callbackFlow return@callbackFlow
} }
@@ -105,11 +105,14 @@ class MonitorNotifications @Inject constructor(
val batteryText = when (device) { val batteryText = when (device) {
is DualPodDevice -> { is DualPodDevice -> {
val left = formatBatteryPercent(context, device.batteryLeftPodPercent) val leftPercent = device.batteryLeftPodPercent
val right = formatBatteryPercent(context, device.batteryRightPodPercent) val rightPercent = device.batteryRightPodPercent
val left = formatBatteryPercent(context, leftPercent)
val right = formatBatteryPercent(context, rightPercent)
when { when {
device is HasCase -> { device is HasCase -> {
val case = formatBatteryPercent(context, device.batteryCasePercent) val casePercent = device.batteryCasePercent
val case = formatBatteryPercent(context, casePercent)
"$left $case $right" "$left $case $right"
} }
@@ -118,10 +121,12 @@ class MonitorNotifications @Inject constructor(
} }
is SinglePodDevice -> { is SinglePodDevice -> {
val headset = formatBatteryPercent(context, device.batteryHeadsetPercent) val headsetPercent = device.batteryHeadsetPercent
val headset = formatBatteryPercent(context, headsetPercent)
when { when {
device is HasCase -> { device is HasCase -> {
val case = formatBatteryPercent(context, device.batteryCasePercent) val casePercent = device.batteryCasePercent
val case = formatBatteryPercent(context, casePercent)
"$headset $case" "$headset $case"
} }
+1 -3
View File
@@ -86,7 +86,6 @@ fun DependencyHandlerScope.addBaseAndroid() {
fun DependencyHandlerScope.addBaseAndroidUi() { fun DependencyHandlerScope.addBaseAndroidUi() {
implementation("androidx.appcompat:appcompat:1.6.1") implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.3") implementation("androidx.constraintlayout:constraintlayout:2.1.3")
implementation("androidx.fragment:fragment-ktx:1.4.1")
implementation("androidx.activity:activity-ktx:1.8.0") implementation("androidx.activity:activity-ktx:1.8.0")
implementation("androidx.fragment:fragment-ktx:1.6.1") implementation("androidx.fragment:fragment-ktx:1.6.1")
@@ -94,7 +93,6 @@ fun DependencyHandlerScope.addBaseAndroidUi() {
implementation("com.google.android.material:material:1.12.0") implementation("com.google.android.material:material:1.12.0")
val lifecycleVers = "2.6.2" val lifecycleVers = "2.6.2"
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVers") implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVers")
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycleVers") implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycleVers")
implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycleVers") implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycleVers")
@@ -123,5 +121,5 @@ fun DependencyHandlerScope.addTesting() {
androidTestImplementation("io.kotest:kotest-assertions-core-jvm:4.6.4") androidTestImplementation("io.kotest:kotest-assertions-core-jvm:4.6.4")
androidTestImplementation("io.kotest:kotest-property-jvm:4.6.4") androidTestImplementation("io.kotest:kotest-property-jvm:4.6.4")
debugImplementation("androidx.fragment:fragment-testing:1.4.1") debugImplementation("androidx.fragment:fragment-testing:1.6.1")
} }