Work around qcom hal bug (no interfaces found) for Mako

Qualcomm's wifi-hal is reporting no interfaces on Mako, even after successful
start of HAL. This change allows the device to boot despite that; but
the root problems needs to be fixed later.

Bug: 17021199
Change-Id: I826c4f41d0c02d5fc37b2ee3ab5ebcefcbf272c8
diff --git a/service/jni/com_android_server_wifi_WifiNative.cpp b/service/jni/com_android_server_wifi_WifiNative.cpp
index 492cce6..50b7273 100644
--- a/service/jni/com_android_server_wifi_WifiNative.cpp
+++ b/service/jni/com_android_server_wifi_WifiNative.cpp
@@ -243,8 +243,8 @@
         return result;
     }
 
-    if (n <= 0) {
-       THROW(env, "android_net_wifi_getInterfaces no interfaces");
+    if (n < 0) {
+        THROW(env, "android_net_wifi_getInterfaces no interfaces");
         return 0;
     }
 
@@ -253,6 +253,11 @@
        return 0;
     }
 
+    if (n > 8) {
+        THROW(env, "Too many interfaces");
+        return 0;
+    }
+
     jlongArray array = (env)->NewLongArray(n);
     if (array == NULL) {
         THROW(env, "Error in accessing array");
@@ -260,11 +265,6 @@
     }
 
     jlong elems[8];
-    if (n > 8) {
-        THROW(env, "Too many interfaces");
-        return 0;
-    }
-
     for (int i = 0; i < n; i++) {
         elems[i] = reinterpret_cast<jlong>(ifaceHandles[i]);
     }