Merge "Correctly handle an empty list of expected modules." into nyc-dev
diff --git a/build/test_host_java_library.mk b/build/test_host_java_library.mk
index abf6829..7fdefb5 100644
--- a/build/test_host_java_library.mk
+++ b/build/test_host_java_library.mk
@@ -17,8 +17,6 @@
 # package XML needed by CTS.
 #
 
-LOCAL_STATIC_JAVA_LIBRARIES += platform-test-annotations-host
-
 include $(BUILD_HOST_JAVA_LIBRARY)
 include $(BUILD_CTS_MODULE_TEST_CONFIG)
 
diff --git a/common/util/Android.mk b/common/util/Android.mk
index d011636..c95508b 100644
--- a/common/util/Android.mk
+++ b/common/util/Android.mk
@@ -42,8 +42,8 @@
 
 LOCAL_MODULE := compatibility-common-util-hostsidelib
 
-LOCAL_STATIC_JAVA_LIBRARIES := junit kxml2-2.3.0
+LOCAL_STATIC_JAVA_LIBRARIES := junit kxml2-2.3.0 platform-test-annotations-host
 
 include $(BUILD_HOST_JAVA_LIBRARY)
 
-include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorParameterRangeTest.java b/tests/tests/hardware/src/android/hardware/cts/SensorParameterRangeTest.java
index 6197103..62e7fe4 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SensorParameterRangeTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorParameterRangeTest.java
@@ -64,13 +64,15 @@
     private static final int STEP_DETECTOR_MIN_FIFO_LENGTH = 100;
 
     private boolean mHasHifiSensors;
+    private boolean mVrModeHighPerformance;
     private SensorManager mSensorManager;
 
     @Override
     public void setUp() {
+        PackageManager pm = getContext().getPackageManager();
         mSensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
-        mHasHifiSensors = getContext().getPackageManager().hasSystemFeature(
-                PackageManager.FEATURE_HIFI_SENSORS);
+        mHasHifiSensors = pm.hasSystemFeature(PackageManager.FEATURE_HIFI_SENSORS);
+        mVrModeHighPerformance = pm.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE);
     }
 
     public void testAccelerometerRange() {
@@ -98,16 +100,18 @@
     }
 
     public void testPressureRange() {
-        checkSensorRangeAndFrequency(
-                mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE),
-                PRESSURE_MAX_RANGE,
-                PRESSURE_MIN_FREQUENCY,
-                PRESSURE_MAX_FREQUENCY);
+        if (mHasHifiSensors) {
+            checkSensorRangeAndFrequency(
+                    mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE),
+                    PRESSURE_MAX_RANGE,
+                    PRESSURE_MIN_FREQUENCY,
+                    PRESSURE_MAX_FREQUENCY);
+        }
     }
 
     private void checkSensorRangeAndFrequency(
           Sensor sensor, double maxRange, double minFrequency, double maxFrequency) {
-        if (!mHasHifiSensors) return;
+        if (!mHasHifiSensors && !mVrModeHighPerformance) return;
         assertTrue(String.format("%s Range actual=%.2f expected=%.2f %s",
                     sensor.getName(), sensor.getMaximumRange(), maxRange,
                     SensorCtsHelper.getUnitsForSensor(sensor)),
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorSupportTest.java b/tests/tests/hardware/src/android/hardware/cts/SensorSupportTest.java
index 8fa2ccd..3d1bc09 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SensorSupportTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorSupportTest.java
@@ -23,9 +23,11 @@
 import android.test.AndroidTestCase;
 
 /**
- * Checks if Hifi sensors are supported. When supported, checks individual support for
- * Accelerometer, Gyroscope, Gyroscope_uncal, GeoMagneticField, MagneticField_uncal
- * Pressure, RotationVector, SignificantMotion, StepDetector, StepCounter, TiltDetector.
+ * Checks if Hifi sensors  or VR High performance mode sensors
+ * are supported. When supported, checks individual support for
+ * Accelerometer, Gyroscope, Gyroscope_uncal, GeoMagneticField,
+ * MagneticField_uncal Pressure, RotationVector,
+ * SignificantMotion, StepDetector, StepCounter, TiltDetector.
  *
  * <p>To execute these test cases, the following command can be used:</p>
  * <pre>
@@ -36,13 +38,15 @@
 public class SensorSupportTest extends AndroidTestCase {
     private SensorManager mSensorManager;
     private boolean mAreHifiSensorsSupported;
+    private boolean mVrHighPerformanceModeSupported;
 
     @Override
     public void setUp() {
-        // Tests will only run if HIFI_SENSORS are supported.
-        mAreHifiSensorsSupported = getContext().getPackageManager().hasSystemFeature(
-                PackageManager.FEATURE_HIFI_SENSORS);
-        if (mAreHifiSensorsSupported) {
+        PackageManager pm = getContext().getPackageManager();
+        // Tests will only run if either HIFI_SENSORS or VR high performance mode is supported.
+        mAreHifiSensorsSupported = pm.hasSystemFeature(PackageManager.FEATURE_HIFI_SENSORS);
+        mVrHighPerformanceModeSupported = pm.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE);
+        if (mAreHifiSensorsSupported || mVrHighPerformanceModeSupported) {
             mSensorManager =
                     (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
         }
@@ -93,8 +97,20 @@
         checkSupportsSensor(TYPE_TILT_DETECTOR);
     }
 
+    private boolean sensorRequiredForVrHighPerformanceMode(int sensorType) {
+        if (sensorType == Sensor.TYPE_MAGNETIC_FIELD ||
+            sensorType == Sensor.TYPE_GYROSCOPE ||
+            sensorType == Sensor.TYPE_ACCELEROMETER) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
     private void checkSupportsSensor(int sensorType) {
-        if (mAreHifiSensorsSupported) {
+        if (mAreHifiSensorsSupported ||
+            (mVrHighPerformanceModeSupported &&
+             sensorRequiredForVrHighPerformanceMode(sensorType))) {
             assertTrue(mSensorManager.getDefaultSensor(sensorType) != null);
         }
     }