From d4cebee1e4b68e8b6c1e2ad8b82da6e2414f2e5b Mon Sep 17 00:00:00 2001 From: thigobr Date: Wed, 21 Jul 2010 13:10:04 -0300 Subject: [PATCH] Fix Bluetooth Settings activity memory leak. There were two leaks in Bluetooth Settings: one when rotating the phone and other when scanning for bluetooth devices. --- src/com/android/settings/ProgressCategory.java | 10 +++++++++- .../android/settings/bluetooth/BluetoothSettings.java | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/ProgressCategory.java b/src/com/android/settings/ProgressCategory.java index 15810b33824..f611137a528 100644 --- a/src/com/android/settings/ProgressCategory.java +++ b/src/com/android/settings/ProgressCategory.java @@ -26,7 +26,8 @@ import java.util.Map; public class ProgressCategory extends PreferenceCategory { private boolean mProgress = false; - + private View oldView = null; + public ProgressCategory(Context context, AttributeSet attrs) { super(context, attrs); setLayoutResource(R.layout.preference_progress_category); @@ -41,6 +42,13 @@ public class ProgressCategory extends PreferenceCategory { int visibility = mProgress ? View.VISIBLE : View.INVISIBLE; textView.setVisibility(visibility); progressBar.setVisibility(visibility); + + if (oldView != null) { + oldView.findViewById(R.id.scanning_progress).setVisibility(View.GONE); + oldView.findViewById(R.id.scanning_text).setVisibility(View.GONE); + oldView.setVisibility(View.GONE); + } + oldView = view; } /** diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index 1e73b2d433e..78c531ce333 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -188,7 +188,8 @@ public class BluetoothSettings extends PreferenceActivity super.onPause(); mLocalManager.setForegroundActivity(null); - + mDevicePreferenceMap.clear(); + mDeviceList.removeAll(); unregisterReceiver(mReceiver); mLocalManager.unregisterCallback(this);