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
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 98f74ab..46d21c5 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -156,14 +156,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() {