Don't crash when unbinding from disconnected service.
Bug: 131853728
Test: build and run the app
Change-Id: Ie7c1666e9b96644403a2047798bf39eb9dace1ef
diff --git a/src/com/android/car/radio/service/RadioAppServiceWrapper.java b/src/com/android/car/radio/service/RadioAppServiceWrapper.java
index 90b9ac0..504c8cf 100644
--- a/src/com/android/car/radio/service/RadioAppServiceWrapper.java
+++ b/src/com/android/car/radio/service/RadioAppServiceWrapper.java
@@ -201,7 +201,9 @@
throw new IllegalStateException(
"This is not a remote service wrapper, you can't unbind it");
}
- callService(service -> service.removeCallback(mCallback));
+ try {
+ callService(service -> service.removeCallback(mCallback));
+ } catch (IllegalStateException e) { } // it's fine if the service is not connected
mClientContext.unbindService(mServiceConnection);
}