Handle a condition when the result of getting configured networks returns null am: 3abc7f0561 am: 3b17189719 am: 1e779938f2
am: fb9027f897

Change-Id: I81eac90617d6f838536aeed4e91577269e7c6cf8
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..1ad5831
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,11 @@
+etancohen@google.com
+kuh@google.com
+mett@google.com
+mplass@google.com
+nywang@google.com
+quiche@google.com
+rpius@google.com
+satk@google.com
+silberst@google.com
+sohanirao@google.com
+zqiu@google.com
diff --git a/service/Android.mk b/service/Android.mk
index 27ecf21..155f5b2 100644
--- a/service/Android.mk
+++ b/service/Android.mk
@@ -70,12 +70,6 @@
 LOCAL_MODULE := wifi-service
 LOCAL_INIT_RC := wifi-events.rc
 
-ifeq ($(EMMA_INSTRUMENT_FRAMEWORK),true)
-LOCAL_EMMA_INSTRUMENT := true
-endif
-
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.server.wifi.*
-
 include $(BUILD_JAVA_LIBRARY)
 
 endif  # !TARGET_BUILD_PDK
diff --git a/service/jni/com_android_server_wifi_WifiNative.cpp b/service/jni/com_android_server_wifi_WifiNative.cpp
index cf35028..09a5ebf 100644
--- a/service/jni/com_android_server_wifi_WifiNative.cpp
+++ b/service/jni/com_android_server_wifi_WifiNative.cpp
@@ -24,7 +24,7 @@
 #include <nativehelper/JniConstants.h>
 #include <nativehelper/ScopedBytes.h>
 #include <nativehelper/ScopedUtfChars.h>
-#include <nativehelper/jni.h>
+#include <jni.h>
 
 #include "jni_helper.h"
 
diff --git a/service/jni/jni_helper.cpp b/service/jni/jni_helper.cpp
index 150f694..60110c9 100644
--- a/service/jni/jni_helper.cpp
+++ b/service/jni/jni_helper.cpp
@@ -18,7 +18,6 @@
 
 #include <hardware_legacy/wifi_hal.h>
 #include <nativehelper/ScopedUtfChars.h>
-#include <nativehelper/jni.h>
 #include <utils/Log.h>
 #include <utils/String16.h>
 #include <utils/misc.h>
diff --git a/service/jni/jni_helper.h b/service/jni/jni_helper.h
index febb901..82b5c70 100644
--- a/service/jni/jni_helper.h
+++ b/service/jni/jni_helper.h
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include <jni.h>
+
 namespace android {
 
 /* JNI Helpers for wifi_hal to WifiNative bridge implementation */
diff --git a/tests/wifitests/coverage.sh b/tests/wifitests/coverage.sh
index 43c97c6..3ed71ad 100755
--- a/tests/wifitests/coverage.sh
+++ b/tests/wifitests/coverage.sh
@@ -1,8 +1,7 @@
 #!/usr/bin/env bash
 
-if [[ ! ( ($# == 1) || ($# == 2 && ($2 == "HTML" || $2 == "XML" || $2 == "CSV"))) ]]; then
-  echo "$0: usage: coverage.sh OUTPUT_DIR [REPORT_TYPE]"
-  echo "REPORT_TYPE [HTML | XML | CSV] : the type of the report (default is HTML)"
+if [[ ! ($# == 1) ]]; then
+  echo "$0: usage: coverage.sh OUTPUT_DIR"
   exit 1
 fi
 
@@ -11,32 +10,38 @@
   exit 1
 fi
 
-REPORTER_JAR=$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jack-jacoco-reporter.jar
+cd "$(dirname $0)" #cd to directory containing this script
+
+
+REPORTER_JAR=$ANDROID_HOST_OUT/framework/jacoco-cli.jar
 
 OUTPUT_DIR=$1
-if [[ $# == 2 ]]; then
-  REPORT_TYPE=$2
-else
-  REPORT_TYPE="HTML"
-fi
 
 echo "Running tests and generating coverage report"
 echo "Output dir: $OUTPUT_DIR"
-echo "Report type: $REPORT_TYPE"
 
 REMOTE_COVERAGE_OUTPUT_FILE=/data/data/com.android.server.wifi.test/files/coverage.ec
 COVERAGE_OUTPUT_FILE=$OUTPUT_DIR/wifi_coverage.ec
-COVERAGE_METADATA_FILE=$ANDROID_BUILD_TOP/out/target/common/obj/APPS/FrameworksWifiTests_intermediates/coverage.em
 
 set -e # fail early
-
-echo "+ EMMA_INSTRUMENT_STATIC=true mmma -j32 $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/tests"
-# NOTE Don't actually run the command above since this shell doesn't inherit functions from the
-#      caller.
-EMMA_INSTRUMENT_STATIC=true make -j32 -C $ANDROID_BUILD_TOP -f build/core/main.mk MODULES-IN-frameworks-opt-net-wifi-tests
-
 set -x # print commands
 
+# build this module so we can run its tests, and
+# build system/core so we can invoke `adb`, and
+# build jacoco-report-classes.jar so we can generate the report
+make \
+  EMMA_INSTRUMENT=true \
+  EMMA_INSTRUMENT_FRAMEWORK=false \
+  EMMA_INSTRUMENT_STATIC=true \
+  ANDROID_COMPILE_WITH_JACK=false \
+  SKIP_BOOT_JARS_CHECK=true \
+  -j32 \
+  -C $ANDROID_BUILD_TOP \
+  -f build/core/main.mk \
+  MODULES-IN-frameworks-opt-net-wifi-tests \
+  MODULES-IN-system-core \
+  FrameworksWifiTests
+
 adb root
 adb wait-for-device
 
@@ -51,9 +56,12 @@
 adb pull $REMOTE_COVERAGE_OUTPUT_FILE $COVERAGE_OUTPUT_FILE
 
 java -jar $REPORTER_JAR \
-  --report-dir $OUTPUT_DIR \
-  --metadata-file $COVERAGE_METADATA_FILE \
-  --coverage-file $COVERAGE_OUTPUT_FILE \
-  --report-type $REPORT_TYPE \
-  --source-dir $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/tests/wifitests/src \
-  --source-dir $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/service/java
+  report \
+  -classfiles $ANDROID_PRODUCT_OUT/../../common/obj/APPS/FrameworksWifiTests_intermediates/jacoco/report-resources/jacoco-report-classes.jar \
+  -html $OUTPUT_DIR \
+  -sourcefiles $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/tests/wifitests/src -sourcefiles $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/service/java \
+  -name wifi-coverage \
+  $COVERAGE_OUTPUT_FILE
+
+echo Created report at $OUTPUT_DIR/index.html
+