Merge "Add READ_EXTERNAL_STORAGE permission to android.content.cts" into oc-mr1-dev
diff --git a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
index cc3ef05..e8a5b81 100644
--- a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
+++ b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
@@ -59,15 +59,16 @@
                  criteria=(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT,
                            10, 0.03))
 
-# Constants to convert between different time units (for clarity).
+# Constants to convert between different units (for clarity).
 SEC_TO_NSEC = 1000*1000*1000.0
 SEC_TO_MSEC = 1000.0
 MSEC_TO_NSEC = 1000*1000.0
 MSEC_TO_SEC = 1/1000.0
 NSEC_TO_SEC = 1/(1000*1000*1000.0)
 NSEC_TO_MSEC = 1/(1000*1000.0)
+CM_TO_M = 1/100.0
 
-# Pass/fail thresholds.
+# PASS/FAIL thresholds.
 THRESH_MAX_CORR_DIST = 0.005
 THRESH_MAX_SHIFT_MS = 1
 THRESH_MIN_ROT = 0.001
@@ -77,6 +78,9 @@
 FACING_BACK = 1
 FACING_EXTERNAL = 2
 
+# Chart distance
+CHART_DISTANCE = 25  # cm
+
 
 def main():
     """Test if image and motion sensor events are well synchronized.
@@ -337,11 +341,14 @@
         # p0's shape is N * 1 * 2
         mask = (p0[:, 0, 1] >= ymin) & (p0[:, 0, 1] <= ymax)
         p0_filtered = p0[mask]
-        if len(p0_filtered) < MIN_FEATURE_PTS:
+        num_features = len(p0_filtered)
+        if num_features < MIN_FEATURE_PTS:
             print "Not enough feature points in frame", i
             print "Need at least %d features, got %d" % (
-                MIN_FEATURE_PTS, len(p0_filtered))
+                    MIN_FEATURE_PTS, num_features)
             assert 0
+        else:
+            print "Number of features in frame %d is %d" % (i, num_features)
         p1, st, _ = cv2.calcOpticalFlowPyrLK(gframe0, gframe1, p0_filtered,
                                              None, **LK_PARAMS)
         tform = procrustes_rotation(p0_filtered[st == 1], p1[st == 1])
@@ -440,8 +447,10 @@
         fmt = {"format": "yuv", "width": w, "height": h}
         s, e, _, _, _ = cam.do_3a(get_results=True, do_af=False)
         req = its.objects.manual_capture_request(s, e)
+        fps = 30
+        req["android.lens.focusDistance"] = 1 / (CHART_DISTANCE * CM_TO_M)
         req["android.control.aeTargetFpsRange"] = [fps, fps]
-        req["android.sensor.frameDuration"] = int(1000.0/fps * MSEC_TO_NSEC);
+        req["android.sensor.frameDuration"] = int(1000.0/fps * MSEC_TO_NSEC)
         print "Capturing %dx%d with sens. %d, exp. time %.1fms" % (
             w, h, s, e*NSEC_TO_MSEC)
         caps = cam.do_capture([req]*fps*test_length, fmt)
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
index 96fe234..f51be93 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
@@ -259,6 +259,13 @@
         moduleFinisher.finish();
 
         // Tear down
+        runPreparerTeardowns();
+    }
+
+    /**
+     * Run preparers' teardown functions.
+     */
+    protected void runPreparerTeardowns() throws DeviceNotAvailableException {
         for (ITargetCleaner cleaner : mCleaners) {
             CLog.d("Cleaner: %s", cleaner.getClass().getSimpleName());
             cleaner.tearDown(mDevice, mBuild, null);
@@ -266,7 +273,7 @@
     }
 
     /**
-     * Run preparer setup functions.
+     * Run preparers' setup functions.
      *
      * @throws DeviceNotAvailableException
      */
diff --git a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
index bd524d2..f63e76a 100644
--- a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
+++ b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
@@ -50,6 +50,7 @@
         "libmediandk.so",
         "libm.so",
         "libnativewindow.so",
+        "libneuralnetworks.so",
         "libOpenMAXAL.so",
         "libOpenSLES.so",
         "libRS.so",
diff --git a/tools/cts-tradefed/res/config/cts-reference-aosp.xml b/tools/cts-tradefed/res/config/cts-reference-aosp.xml
index ed74a4c..e68fd1d 100644
--- a/tools/cts-tradefed/res/config/cts-reference-aosp.xml
+++ b/tools/cts-tradefed/res/config/cts-reference-aosp.xml
@@ -31,8 +31,8 @@
     <!-- Radio system of a reference AOSP system image is not checked -->
     <option name="compatibility:exclude-filter" value="CtsTelephonyTestCases" />
     <option name="compatibility:exclude-filter" value="CtsTelephony2TestCases" />
-    <option name="compatibility:exclude-filter" value="CtsIncidentHostTestCases com.android.server.cts.PackageIncidentTest#testPackageServiceDump" />
     <option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.SystemFeaturesTest#testLocationFeatures" />
+    <option name="compatibility:exclude-filter" value="CtsIncidentHostTestCases com.android.server.cts.PackageIncidentTest#testPackageServiceDump" />
 
     <!-- Exclude telephony related testcases -->
     <option name="compatibility:exclude-filter" value="CtsCarrierApiTestCases android.carrierapi.cts.CarrierApiTest#testGetIccAuthentication" />
@@ -54,6 +54,10 @@
     <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testUidDetails" />
     <option name="compatibility:exclude-filter" value="CtsUsageStatsTestCases android.app.usage.cts.NetworkUsageStatsTest#testUserSummary" />
 
+    <!-- Exclude not applicable testcases-->
+    <option name="compatibility:exclude-filter" value="CtsSignatureTestCases" />
+    <option name="compatibility:exclude-filter" value="CtsOsTestCases android.os.cts.UsbDebuggingTest#testUsbDebugging" />
+
     <!--
         Exclude Webkit related testcases
         TODO(jaekyun@): b/63600240, Webkit related testcases will be revived when the RRO packaging logic is revised so that we can selectively compose a RRO from overlays.
@@ -85,7 +89,6 @@
     <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testVoiceCommand" />
     <option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testVoiceSearchHandsFree" />
     <option name="compatibility:exclude-filter" value="CtsPermission2TestCases android.permission2.cts.PrivappPermissionsTest#testPrivappPermissionsEnforcement" />
-    <option name="compatibility:exclude-filter" value="CtsSignatureTestCases android.signature.cts.IntentTest#shouldNotFindUnexpectedIntents" />
     <option name="compatibility:exclude-filter" value="CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testVp8Other0Qual1920x1080" />
 
 </configuration>