mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-05-23 09:22:49 +00:00
android: fix crash in listening mode widget when service is null
This commit is contained in:
@@ -28,8 +28,8 @@ import android.content.Intent
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import me.kavishdevar.librepods.R
|
import me.kavishdevar.librepods.R
|
||||||
import me.kavishdevar.librepods.services.ServiceManager
|
|
||||||
import me.kavishdevar.librepods.bluetooth.AACPManager
|
import me.kavishdevar.librepods.bluetooth.AACPManager
|
||||||
|
import me.kavishdevar.librepods.services.ServiceManager
|
||||||
import kotlin.io.encoding.ExperimentalEncodingApi
|
import kotlin.io.encoding.ExperimentalEncodingApi
|
||||||
|
|
||||||
class NoiseControlWidget : AppWidgetProvider() {
|
class NoiseControlWidget : AppWidgetProvider() {
|
||||||
@@ -82,8 +82,14 @@ class NoiseControlWidget : AppWidgetProvider() {
|
|||||||
if (intent.action == "ACTION_SET_ANC_MODE") {
|
if (intent.action == "ACTION_SET_ANC_MODE") {
|
||||||
val mode = intent.getIntExtra("ANC_MODE", 1)
|
val mode = intent.getIntExtra("ANC_MODE", 1)
|
||||||
Log.d("NoiseControlWidget", "Setting ANC mode to $mode")
|
Log.d("NoiseControlWidget", "Setting ANC mode to $mode")
|
||||||
ServiceManager.getService()!!
|
val service = ServiceManager.getService()
|
||||||
.aacpManager
|
|
||||||
|
if (service == null) {
|
||||||
|
Log.w("NoiseControlWidget", "Service unavailable")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
service.aacpManager
|
||||||
.sendControlCommand(
|
.sendControlCommand(
|
||||||
AACPManager.Companion.ControlCommandIdentifiers.LISTENING_MODE.value,
|
AACPManager.Companion.ControlCommandIdentifiers.LISTENING_MODE.value,
|
||||||
mode.toByte()
|
mode.toByte()
|
||||||
|
|||||||
Reference in New Issue
Block a user