diff options
author | Rebecca Silberstein <silberst@google.com> | 2016-03-17 20:53:03 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-03-17 20:53:03 +0000 |
commit | a24cf11dc36674056efef38be297eea40cc5761f (patch) | |
tree | 822d1f279a9b380c90c53d95eccf0f387e66849a /service | |
parent | e43135bfd49a1a8d1821dffaea0d44ff36eb8b23 (diff) | |
parent | 6d8029355c62eea70a230d49493d35c4462938b4 (diff) |
Merge "Revert "Remove ill-defined WifiNative::getInterfaces()"" into nyc-dev
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiNative.java | 36 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 11 |
2 files changed, 30 insertions, 17 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 8ee0661ee..1ad492b45 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -1710,6 +1710,7 @@ public class WifiNative { private static long sWifiHalHandle = 0; /* used by JNI to save wifi_handle */ private static long[] sWifiIfaceHandles = null; /* used by JNI to save interface handles */ public static int sWlan0Index = -1; + private static int sP2p0Index = -1; private static MonitorThread sThread; private static final int STOP_HAL_TIMEOUT_MS = 1000; @@ -1734,13 +1735,7 @@ public class WifiNative { sLocalLog.log(debugLog); synchronized (sLock) { - if (startHalNative()) { - int wlan0Index = queryInterfaceIndex(mInterfaceName); - if (wlan0Index == -1) { - if (DBG) sLocalLog.log("Could not find interface with name: " + mInterfaceName); - return false; - } - sWlan0Index = wlan0Index; + if (startHalNative() && (getInterfaces() != 0) && (sWlan0Index != -1)) { sThread = new MonitorThread(); sThread.start(); return true; @@ -1766,6 +1761,7 @@ public class WifiNative { sWifiHalHandle = 0; sWifiIfaceHandles = null; sWlan0Index = -1; + sP2p0Index = -1; } } } @@ -1775,19 +1771,31 @@ public class WifiNative { } private static native int getInterfacesNative(); - private int queryInterfaceIndex(String if_name) { + public int getInterfaces() { synchronized (sLock) { if (isHalStarted()) { - int num = getInterfacesNative(); - for (int i = 0; i < num; i++) { - String name = getInterfaceNameNative(i); - if (name.equals(if_name)) { - return i; + if (sWifiIfaceHandles == null) { + int num = getInterfacesNative(); + int wifi_num = 0; + for (int i = 0; i < num; i++) { + String name = getInterfaceNameNative(i); + Log.i(TAG, "interface[" + i + "] = " + name); + if (name.equals("wlan0")) { + sWlan0Index = i; + wifi_num++; + } else if (name.equals("p2p0")) { + sP2p0Index = i; + wifi_num++; + } } + return wifi_num; + } else { + return sWifiIfaceHandles.length; } + } else { + return 0; } } - return -1; } private static native String getInterfaceNameNative(int index); diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index fe534546d..2a506dba6 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4602,9 +4602,14 @@ public class WifiStateMachine extends StateMachine implements WifiNative.PnoEven Log.e(TAG, "Failed to load driver for softap"); return false; } - if (!mWifiNative.toggleInterface(0)) { - Log.e(TAG, "toggleInterface failed"); - return false; + + if (mWifiNative.getInterfaces() != 0) { + if (!mWifiNative.toggleInterface(0)) { + Log.e(TAG, "toggleInterface failed"); + return false; + } + } else { + if (DBG) Log.d(TAG, "No interfaces to toggle"); } try { |