prevent false wifi roaming signal
Bug:21617059

Change-Id: I3ed85339d177c2c15831c59662f693ba4882919b
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 683a00c..2b12e4c 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -4745,20 +4745,31 @@
 
         mWifiInfo.setBSSID(stateChangeResult.BSSID);
 
-        if (stateChangeResult.wifiSsid != null) {
+        if (mWhiteListedSsids != null
+                && mWhiteListedSsids.length > 0
+                && stateChangeResult.wifiSsid != null) {
             String SSID = stateChangeResult.wifiSsid.toString();
             String currentSSID = mWifiInfo.getSSID();
             if (SSID != null
                     && currentSSID != null
-                    && !SSID.equals(WifiSsid.NONE)
-                    && !SSID.equals(currentSSID)) {
-                if (getCurrentState() == mConnectedState) {
-                    lastConnectAttempt = System.currentTimeMillis();
-                    targetWificonfiguration
+                    && !SSID.equals(WifiSsid.NONE)) {
+                    // Remove quote before comparing
+                    if (SSID.length() >= 2 && SSID.charAt(0) == '"'
+                            && SSID.charAt(SSID.length() - 1) == '"')
+                    {
+                        SSID = SSID.substring(1, SSID.length() - 1);
+                    }
+                    if (currentSSID.length() >= 2 && currentSSID.charAt(0) == '"'
+                            && currentSSID.charAt(currentSSID.length() - 1) == '"') {
+                        currentSSID = currentSSID.substring(1, currentSSID.length() - 1);
+                    }
+                    if ((!SSID.equals(currentSSID)) && (getCurrentState() == mConnectedState)) {
+                        lastConnectAttempt = System.currentTimeMillis();
+                        targetWificonfiguration
                             = mWifiConfigStore.getWifiConfiguration(mWifiInfo.getNetworkId());
-                    transitionTo(mRoamingState);
-                }
-            }
+                        transitionTo(mRoamingState);
+                    }
+             }
         }
 
         mWifiInfo.setSSID(stateChangeResult.wifiSsid);