From c6e1b293a7cca6804a0a3ea4923beea16bd6dc0e Mon Sep 17 00:00:00 2001 From: Jake Hamby Date: Tue, 11 Jan 2011 13:27:50 -0800 Subject: [PATCH] Don't throw exception on unexpected BT device addition. Fix for reported bug where settings app crashes while trying to share a picture. Bug report showed IllegalStateException thrown with message "Got onDeviceAdded, but cachedDevice already exists." Changed code to print an error message to the log and ignore the unexpected event, rather than throwing an uncaught exception that crashes the app. Bug: 2192884 Change-Id: I016be6a1616b317b2289768d18ae9f069a49445e --- src/com/android/settings/bluetooth/BluetoothSettings.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index aa5decbf4b6..54f9fb1a6cd 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -286,7 +286,8 @@ public class BluetoothSettings extends SettingsPreferenceFragment public void onDeviceAdded(CachedBluetoothDevice cachedDevice) { if (mDevicePreferenceMap.get(cachedDevice) != null) { - throw new IllegalStateException("Got onDeviceAdded, but cachedDevice already exists"); + Log.e(TAG, "Got onDeviceAdded, but cachedDevice already exists"); + return; } if (mScreenType != SCREEN_TYPE_SETTINGS