Don't remove wifi preferences when updating AP to avoid GC.

Bug: 30870531

Removing wifi preferences every time will force update create a new set
of preferences, which leads to higher chance of GC.

Change-Id: Ifea2f63a3b54fa0d5861fb34a348d81e99bcab68
(cherry picked from commit 9d031f2fbce4cc525e4d5a5598e9c9d1813c2ce2)
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 8eb1759..a34ccab 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -42,6 +42,7 @@
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.text.Spannable;
+import android.text.TextUtils;
 import android.text.style.TextAppearanceSpan;
 import android.util.Log;
 import android.view.ContextMenu;
@@ -54,6 +55,7 @@
 import android.widget.TextView;
 import android.widget.TextView.BufferType;
 import android.widget.Toast;
+
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.settings.LinkifyUtils;
@@ -612,7 +614,6 @@
                 // AccessPoints are automatically sorted with TreeSet.
                 final Collection<AccessPoint> accessPoints =
                         mWifiTracker.getAccessPoints();
-                getPreferenceScreen().removeAll();
 
                 boolean hasAvailableAccessPoints = false;
                 int index = 0;
@@ -621,6 +622,9 @@
                     // Ignore access points that are out of range.
                     if (accessPoint.getLevel() != -1) {
                         String key = accessPoint.getBssid();
+                        if (TextUtils.isEmpty(key)) {
+                            key = accessPoint.getSsidStr();
+                        }
                         hasAvailableAccessPoints = true;
                         LongPressAccessPointPreference pref = (LongPressAccessPointPreference)
                                 getCachedPreference(key);