Bluetooth: Handle IllegalStateException during start service.
Use case:
During BT on and OFF use cases
Failure:
"Unfortunately, BATestApp has stopped" error comes.
Root cause:
Observed IllegalStateException during start service because of
app is in background(uncached).
Fix:
Add catch block to avoid FATAL exception in BA test app.
CRs-Fixed: 2454925
Change-Id: I41b8d4bd27fa1f2569aed1961387742894f9f025
diff --git a/BATestApp/src/org/codeaurora/bluetooth/batestapp/BroadcastAudioAppReceiver.java b/BATestApp/src/org/codeaurora/bluetooth/batestapp/BroadcastAudioAppReceiver.java
index 2770f7f..aaa1a47 100644
--- a/BATestApp/src/org/codeaurora/bluetooth/batestapp/BroadcastAudioAppReceiver.java
+++ b/BATestApp/src/org/codeaurora/bluetooth/batestapp/BroadcastAudioAppReceiver.java
@@ -51,7 +51,11 @@
BluetoothAdapter.ERROR);
if (state == BluetoothAdapter.STATE_ON) {
Log.d(TAG, "state == BluetoothAdapter.STATE_ON");
- context.startService(new Intent(context, GattBroadcastService.class));
+ try {
+ context.startService(new Intent(context, GattBroadcastService.class));
+ } catch (IllegalStateException e) {
+ Log.e(TAG, " GattBroadcastService start failed " + e.toString());
+ }
}
}
}