am ca8e81d0: Merge "Remove duplicate CTS tests from libcore cts packages." into lollipop-cts-dev automerge: 653f0cd

* commit 'ca8e81d005460ec2cc77e7de7ac35191f9477cae':
  Remove duplicate CTS tests from libcore cts packages.
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index c5903d1..5cbc6ea 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.cts.verifier"
       android:versionCode="5"
-      android:versionName="5.1_r2">
+      android:versionName="5.1_r1">
 
     <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="21"/>
 
diff --git a/tests/tests/app/src/android/app/cts/ActivityManagerTest.java b/tests/tests/app/src/android/app/cts/ActivityManagerTest.java
index 998a005..e633f1f 100644
--- a/tests/tests/app/src/android/app/cts/ActivityManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/ActivityManagerTest.java
@@ -219,8 +219,7 @@
                 hasTestProcess = true;
             }
         }
-        // For security reasons the system process is not exposed.
-        assertTrue(!hasSystemProcess && hasTestProcess);
+        assertTrue(hasSystemProcess && hasTestProcess);
 
         for (RunningAppProcessInfo ra : list) {
             if (ra.processName.equals("com.android.cts.app.stub:remote")) {
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java
old mode 100755
new mode 100644
index 6c8557d..bcc4061
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java
@@ -95,7 +95,6 @@
     protected CameraCaptureSession mSession;
     protected ImageReader mReader;
     protected Surface mReaderSurface;
-    protected Surface mOldReaderSurface;
     protected Surface mPreviewSurface;
     protected Size mPreviewSize;
     protected List<Size> mOrderedPreviewSizes; // In descending order.
@@ -546,8 +545,6 @@
     protected void closeImageReader() {
         CameraTestUtils.closeImageReader(mReader);
         mReader = null;
-        Log.i(TAG,"mReaderSurface = " + mReaderSurface);
-        mOldReaderSurface = mReaderSurface;
         mReaderSurface = null;
     }
 
@@ -652,11 +649,7 @@
         outputSurfaces.add(mReaderSurface);
         mSessionListener = new BlockingSessionCallback();
         mSession = configureCameraSession(mCamera, outputSurfaces, mSessionListener, mHandler);
-        if (mOldReaderSurface != null) {
-            Log.i(TAG,"release mOldReaderSurface = " + mOldReaderSurface);
-            mOldReaderSurface.release();
-            mOldReaderSurface = null;
-        }
+
         // Configure the requests.
         previewRequest.addTarget(mPreviewSurface);
         stillRequest.addTarget(mPreviewSurface);
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorTest.java b/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
index d572c8a..a16f16f 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,23 +323,23 @@
                 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();
     }
 
     // TODO: after L release move to SensorBatchingTests and run in all sensors with default
     //       verifications enabled
-    public void testBatchAndFlushWithMutipleSensors() throws Exception {
+    public void testBatchAndFlushWithMultipleSensors() throws Exception {
         final int maxSensors = 3;
         final int maxReportLatencyUs = (int) TimeUnit.SECONDS.toMicros(10);
         List<Sensor> sensorsToTest = new ArrayList<Sensor>();
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 6fe5801..0000000
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ShadowTests.java
+++ /dev/null
@@ -1,54 +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() {
-        int shadowColorValue = 0xD7;
-        // Android TV theme overrides shadow opacity to be darker.
-        if (getActivity().getOnTv()) {
-            shadowColorValue = 0xB7;
-        }
-        SamplePointVerifier verifier = 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(shadowColorValue, shadowColorValue, shadowColorValue),
-                        Color.rgb(shadowColorValue, shadowColorValue, shadowColorValue),
-                });
-        createTest()
-                .addLayout(R.layout.simple_shadow_layout, null, true/* HW only */)
-                .runWithVerifier(verifier);
-    }
-}
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java
index 041fcdd..4bd513a 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java
@@ -17,7 +17,6 @@
 
 import android.annotation.Nullable;
 import android.app.Activity;
-import android.content.res.Configuration;
 import android.graphics.Point;
 import android.os.Bundle;
 import android.os.Handler;
@@ -39,19 +38,12 @@
 
     private Handler mHandler;
     private View mView;
-    private boolean mOnTv;
 
     public void onCreate(Bundle bundle){
         super.onCreate(bundle);
         getWindow().getDecorView().setSystemUiVisibility(
                 View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
         mHandler = new RenderSpecHandler();
-        int uiMode = getResources().getConfiguration().uiMode;
-        mOnTv = (uiMode & Configuration.UI_MODE_TYPE_TELEVISION) == Configuration.UI_MODE_TYPE_TELEVISION;
-    }
-
-    public boolean getOnTv() {
-        return mOnTv;
     }
 
     public Point enqueueRenderSpecAndWait(int layoutId, CanvasClient canvasClient, String webViewUrl,
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
index d2815e1..16860d5 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
@@ -31,7 +31,7 @@
     @Option(name="cts-install-path", description="the path to the cts installation to use")
     private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
 
-    public static final String CTS_BUILD_VERSION = "5.1_r2";
+    public static final String CTS_BUILD_VERSION = "5.1_r1";
 
     /**
      * {@inheritDoc}