Fix a race in WifiNative objects

disconnectFromSupplicant doesn't have any synchronization;
so it can cause problems when WifiStateMachine is disconnecting
and P2p statemachine is sending commands.

Bug: 22667667
Change-Id: I92e6ee44618813341e171f84442791a6403a5010
(cherry picked from commit b577f391af2c484e443c19b3df1d62cc0924692a)
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index eb81229..e5b6af3 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -141,14 +141,17 @@
     }
 
     public boolean connectToSupplicant() {
-        // No synchronization necessary .. it is implemented in WifiMonitor
-        localLog(mInterfacePrefix + "connectToSupplicant");
-        return connectToSupplicantNative();
+        synchronized(mLock) {
+            localLog(mInterfacePrefix + "connectToSupplicant");
+            return connectToSupplicantNative();
+        }
     }
 
     public void closeSupplicantConnection() {
-        localLog(mInterfacePrefix + "closeSupplicantConnection");
-        closeSupplicantConnectionNative();
+        synchronized(mLock) {
+            localLog(mInterfacePrefix + "closeSupplicantConnection");
+            closeSupplicantConnectionNative();
+        }
     }
 
     public String waitForEvent() {