am 4053a34a: Merge "resolve merge conflicts of 6176421 to lollipop-cts-dev." into lollipop-cts-dev automerge: 6c78c8e

* commit '4053a34a54864b0cc74ba79846fcb212afbbc2a7':
  Fix for CTS fail android.hardware.cts.SensorTest#testSensorOperations
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorTest.java b/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
index d572c8a..d606b70 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
@@ -58,10 +58,8 @@
 
     private PowerManager.WakeLock mWakeLock;
     private SensorManager mSensorManager;
-    private TestSensorManager mTestSensorManager;
     private NullTriggerEventListener mNullTriggerEventListener;
     private NullSensorEventListener mNullSensorEventListener;
-    private Sensor mTriggerSensor;
     private List<Sensor> mSensorList;
 
     @Override
@@ -86,21 +84,7 @@
     }
 
     @Override
-    protected void tearDown() {
-        if (mSensorManager != null) {
-           // SensorManager will check listener and status, so just unregister listener
-           mSensorManager.unregisterListener(mNullSensorEventListener);
-           if (mTriggerSensor != null) {
-               mSensorManager.cancelTriggerSensor(mNullTriggerEventListener, mTriggerSensor);
-               mTriggerSensor = null;
-           }
-        }
-
-        if (mTestSensorManager != null) {
-            mTestSensorManager.unregisterListener();
-            mTestSensorManager = null;
-        }
-
+    protected void tearDown(){
         if (mWakeLock != null && mWakeLock.isHeld()) {
             mWakeLock.release();
         }
@@ -250,22 +234,20 @@
     }
 
     public void testRequestTriggerWithNonTriggerSensor() {
-        mTriggerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
-        if (mTriggerSensor == null) {
+        Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
+        if (sensor == null) {
             throw new SensorNotSupportedException(Sensor.TYPE_ACCELEROMETER);
         }
-        boolean  result =
-            mSensorManager.requestTriggerSensor(mNullTriggerEventListener, mTriggerSensor);
+        boolean  result = mSensorManager.requestTriggerSensor(mNullTriggerEventListener, sensor);
         assertFalse(result);
     }
 
     public void testCancelTriggerWithNonTriggerSensor() {
-        mTriggerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
-        if (mTriggerSensor == null) {
+        Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
+        if (sensor == null) {
             throw new SensorNotSupportedException(Sensor.TYPE_ACCELEROMETER);
         }
-        boolean result =
-            mSensorManager.cancelTriggerSensor(mNullTriggerEventListener, mTriggerSensor);
+        boolean result = mSensorManager.cancelTriggerSensor(mNullTriggerEventListener, sensor);
         assertFalse(result);
     }
 
@@ -341,16 +323,16 @@
                 sensor,
                 SensorManager.SENSOR_DELAY_FASTEST,
                 (int) TimeUnit.SECONDS.toMicros(5));
-        mTestSensorManager = new TestSensorManager(environment);
+        TestSensorManager sensorManager = new TestSensorManager(environment);
 
         HandlerThread handlerThread = new HandlerThread("sensorThread");
         handlerThread.start();
         Handler handler = new Handler(handlerThread.getLooper());
         TestSensorEventListener listener = new TestSensorEventListener(environment, handler);
 
-        CountDownLatch eventLatch = mTestSensorManager.registerListener(listener, 1);
+        CountDownLatch eventLatch = sensorManager.registerListener(listener, 1);
         listener.waitForEvents(eventLatch, 1);
-        CountDownLatch flushLatch = mTestSensorManager.requestFlush();
+        CountDownLatch flushLatch = sensorManager.requestFlush();
         listener.waitForFlushComplete(flushLatch);
         listener.assertEventsReceivedInHandler();
     }
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEnvironment.java b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEnvironment.java
index 143f0a1..7d10f91 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEnvironment.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEnvironment.java
@@ -248,19 +248,10 @@
     }
 
     /**
-     * @return The maximum acceptable actual sampling period of this sensor.
-     *         For continuous sensors, this is higher than {@link #getExpectedSamplingPeriodUs()}
-     *         because sensors are allowed to run up to 10% slower than requested.
-     *         For sensors with other reporting modes, this is the maximum integer
-     *         {@link Integer#MAX_VALUE} as they can report no events for long
-     *         periods of time.
+     * @return The actual sampling period at which a sensor can sample data. This value is a
+     *         fraction of {@link #getExpectedSamplingPeriodUs()}.
      */
     public int getMaximumExpectedSamplingPeriodUs() {
-        int sensorReportingMode = mSensor.getReportingMode();
-        if (sensorReportingMode != Sensor.REPORTING_MODE_CONTINUOUS) {
-            return Integer.MAX_VALUE;
-        }
-
         int expectedSamplingPeriodUs = getExpectedSamplingPeriodUs();
         return (int) (expectedSamplingPeriodUs / MAXIMUM_EXPECTED_SAMPLING_FREQUENCY_MULTIPLIER);
     }
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEventListener.java b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEventListener.java
index 6e25e86..7b1a499 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEventListener.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEventListener.java
@@ -49,7 +49,7 @@
     private static final long EVENT_TIMEOUT_US = TimeUnit.SECONDS.toMicros(5);
     private static final long FLUSH_TIMEOUT_US = TimeUnit.SECONDS.toMicros(10);
 
-    private final ArrayList<TestSensorEvent> mCollectedEvents = new ArrayList<>();
+    private final List<TestSensorEvent> mCollectedEvents = new ArrayList<>();
     private final List<CountDownLatch> mEventLatches = new ArrayList<>();
     private final List<CountDownLatch> mFlushLatches = new ArrayList<>();
     private final AtomicInteger mEventsReceivedOutsideHandler = new AtomicInteger();
@@ -155,7 +155,7 @@
      */
     public List<TestSensorEvent> getCollectedEvents() {
         synchronized (mCollectedEvents){
-            return Collections.unmodifiableList((List<TestSensorEvent>) mCollectedEvents.clone());
+            return Collections.unmodifiableList(mCollectedEvents);
         }
     }
 
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/EventTimestampSynchronizationVerification.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/EventTimestampSynchronizationVerification.java
index 2c1f196..d4a1f38 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/EventTimestampSynchronizationVerification.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/EventTimestampSynchronizationVerification.java
@@ -67,12 +67,13 @@
      */
     public static EventTimestampSynchronizationVerification getDefault(
             TestSensorEnvironment environment) {
-        long reportLatencyUs = environment.getMaxReportLatencyUs();
-        long fifoMaxEventCount = environment.getSensor().getFifoMaxEventCount();
-        int maximumExpectedSamplingPeriodUs = environment.getMaximumExpectedSamplingPeriodUs();
-        if (fifoMaxEventCount > 0 && maximumExpectedSamplingPeriodUs != Integer.MAX_VALUE) {
-            long fifoBasedReportLatencyUs = fifoMaxEventCount * maximumExpectedSamplingPeriodUs;
+        int reportLatencyUs = environment.getMaxReportLatencyUs();
+        int fifoMaxEventCount = environment.getSensor().getFifoMaxEventCount();
+        if (fifoMaxEventCount > 0) {
+            int fifoBasedReportLatencyUs =
+                    fifoMaxEventCount * environment.getMaximumExpectedSamplingPeriodUs();
             reportLatencyUs = Math.min(reportLatencyUs, fifoBasedReportLatencyUs);
+
         }
         long reportLatencyNs = TimeUnit.MICROSECONDS.toNanos(reportLatencyUs);
         return new EventTimestampSynchronizationVerification(DEFAULT_THRESHOLD_NS, reportLatencyNs);
diff --git a/tests/tests/uirendering/res/layout/simple_shadow_layout.xml b/tests/tests/uirendering/res/layout/simple_shadow_layout.xml
deleted file mode 100644
index 2f21df0..0000000
--- a/tests/tests/uirendering/res/layout/simple_shadow_layout.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2015 The Android Open Source Project
-
-       Licensed under the Apache License, Version 2.0 (the "License");
-       you may not use this file except in compliance with the License.
-       You may obtain a copy of the License at
-
-            http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing, software
-       distributed under the License is distributed on an "AS IS" BASIS,
-       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-       See the License for the specific language governing permissions and
-       limitations under the License.
--->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="@dimen/test_width"
-    android:layout_height="@dimen/test_height">
-    <View android:layout_width="40px"
-        android:layout_height="40px"
-        android:translationX="25px"
-        android:translationY="25px"
-        android:elevation="10dp"
-        android:background="#fff" />
-</FrameLayout>
\ No newline at end of file
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ShadowTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ShadowTests.java
deleted file mode 100644
index fce6c94..0000000
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ShadowTests.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.uirendering.cts.testclasses;
-
-import android.graphics.Color;
-import android.graphics.Point;
-import android.uirendering.cts.bitmapverifiers.SamplePointVerifier;
-
-import com.android.cts.uirendering.R;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import android.uirendering.cts.testinfrastructure.ActivityTestBase;
-
-public class ShadowTests extends ActivityTestBase {
-    @SmallTest
-    public void testShadowLayout() {
-        createTest()
-                .addLayout(R.layout.simple_shadow_layout, null, true/* HW only */)
-                .runWithVerifier(
-                new SamplePointVerifier(
-                        new Point[] {
-                                // view area
-                                new Point(25, 64),
-                                new Point(64, 64),
-                                // shadow area
-                                new Point(25, 65),
-                                new Point(64, 65)
-                        },
-                        new int[] {
-                                Color.WHITE,
-                                Color.WHITE,
-                                Color.rgb(215, 215, 215),
-                                Color.rgb(215, 215, 215),
-                        }));
-    }
-}