Merge "Fix media stress tests." into lmp-sprout-dev
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index d6d655a..222cafa 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -1445,6 +1445,9 @@
<service android:name=".jobscheduler.MockJobService"
android:permission="android.permission.BIND_JOB_SERVICE"/>
+ <!-- Used by the SensorTestScreenManipulator to reset the screen timeout after turn off. -->
+ <activity android:name=".os.TimeoutResetActivity"/>
+
</application>
</manifest>
diff --git a/apps/CtsVerifier/res/layout/js_charging.xml b/apps/CtsVerifier/res/layout/js_charging.xml
index 4c0e552..5552111 100644
--- a/apps/CtsVerifier/res/layout/js_charging.xml
+++ b/apps/CtsVerifier/res/layout/js_charging.xml
@@ -1,67 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
android:layout_height="match_parent">
- <TextView
+ <LinearLayout
+ android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/js_test_description"
- android:layout_margin="@dimen/js_padding"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="@dimen/js_padding"
- android:text="@string/js_charging_description_1"
- android:textStyle="bold"/>
- <Button
- android:id="@+id/js_charging_start_test_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="@string/js_start_test_text"
- android:onClick="startTest"
- android:enabled="false"/>
+ android:layout_height="match_parent">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/js_test_description"
+ android:layout_margin="@dimen/js_padding"/>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/js_padding"
+ android:text="@string/js_charging_description_1"
+ android:textStyle="bold"/>
+ <Button
+ android:id="@+id/js_charging_start_test_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/js_start_test_text"
+ android:onClick="startTest"
+ android:enabled="false"/>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/js_padding"
- android:layout_marginBottom="@dimen/js_padding">
- <ImageView
- android:id="@+id/charging_off_test_image"
+ <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:src="@drawable/fs_indeterminate"
- android:layout_marginRight="@dimen/js_padding"/>
+ android:layout_marginTop="@dimen/js_padding"
+ android:layout_marginBottom="@dimen/js_padding">
+ <ImageView
+ android:id="@+id/charging_off_test_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/fs_indeterminate"
+ android:layout_marginRight="@dimen/js_padding"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/js_charging_off_test"
+ android:textSize="16dp"/>
+ </LinearLayout>
<TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/js_padding"
+ android:text="@string/js_charging_description_2"
+ android:textStyle="bold"/>
+ <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/js_charging_off_test"
- android:textSize="16dp"/>
+ android:layout_marginTop="@dimen/js_padding"
+ android:layout_marginBottom="@dimen/js_padding">
+ <ImageView
+ android:id="@+id/charging_on_test_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/fs_indeterminate"
+ android:layout_marginRight="@dimen/js_padding"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/js_charging_on_test"
+ android:textSize="16dp"/>
+ </LinearLayout>
+ <include layout="@layout/pass_fail_buttons" />
</LinearLayout>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="@dimen/js_padding"
- android:text="@string/js_charging_description_2"
- android:textStyle="bold"/>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/js_padding"
- android:layout_marginBottom="@dimen/js_padding">
- <ImageView
- android:id="@+id/charging_on_test_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/fs_indeterminate"
- android:layout_marginRight="@dimen/js_padding"/>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/js_charging_on_test"
- android:textSize="16dp"/>
- </LinearLayout>
- <include layout="@layout/pass_fail_buttons" />
-</LinearLayout>
\ No newline at end of file
+</ScrollView>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/js_connectivity.xml b/apps/CtsVerifier/res/layout/js_connectivity.xml
index 5208c18..e0fc740 100644
--- a/apps/CtsVerifier/res/layout/js_connectivity.xml
+++ b/apps/CtsVerifier/res/layout/js_connectivity.xml
@@ -1,83 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
android:layout_height="match_parent">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/js_test_description"
- android:layout_margin="@dimen/js_padding"/>
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/js_connectivity_description_1"
- android:layout_margin="@dimen/js_padding"
- android:textStyle="bold"/>
-
- <Button
- android:id="@+id/js_connectivity_start_test_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="@string/js_start_test_text"
- android:onClick="startTest"
- android:enabled="false"/>
-
<LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/js_padding"
- android:layout_marginBottom="@dimen/js_padding">
- <ImageView
- android:id="@+id/connectivity_off_test_unmetered_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/fs_indeterminate"
- android:layout_marginRight="@dimen/js_padding"/>
+ android:orientation="vertical" android:layout_width="match_parent"
+ android:layout_height="match_parent">
<TextView
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/js_unmetered_connectivity_test"
- android:textSize="16dp"/>
- </LinearLayout>
+ android:text="@string/js_test_description"
+ android:layout_margin="@dimen/js_padding"/>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/js_padding"
- android:layout_marginBottom="@dimen/js_padding">
- <ImageView
- android:id="@+id/connectivity_off_test_any_connectivity_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/fs_indeterminate"
- android:layout_marginRight="@dimen/js_padding"/>
<TextView
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/js_any_connectivity_test"
- android:textSize="16dp"/>
- </LinearLayout>
+ android:text="@string/js_connectivity_description_1"
+ android:layout_margin="@dimen/js_padding"
+ android:textStyle="bold"/>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/js_padding"
- android:layout_marginBottom="@dimen/js_padding">
- <ImageView
- android:id="@+id/connectivity_off_test_no_connectivity_image"
+ <Button
+ android:id="@+id/js_connectivity_start_test_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:src="@drawable/fs_indeterminate"
- android:layout_marginRight="@dimen/js_padding"/>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/js_no_connectivity_test"
- android:textSize="16dp"/>
- </LinearLayout>
+ android:layout_gravity="center"
+ android:text="@string/js_start_test_text"
+ android:onClick="startTest"
+ android:enabled="false"/>
- <include layout="@layout/pass_fail_buttons" />
-</LinearLayout>
\ No newline at end of file
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/js_padding"
+ android:layout_marginBottom="@dimen/js_padding">
+ <ImageView
+ android:id="@+id/connectivity_off_test_unmetered_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/fs_indeterminate"
+ android:layout_marginRight="@dimen/js_padding"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/js_unmetered_connectivity_test"
+ android:textSize="16dp"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/js_padding"
+ android:layout_marginBottom="@dimen/js_padding">
+ <ImageView
+ android:id="@+id/connectivity_off_test_any_connectivity_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/fs_indeterminate"
+ android:layout_marginRight="@dimen/js_padding"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/js_any_connectivity_test"
+ android:textSize="16dp"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/js_padding"
+ android:layout_marginBottom="@dimen/js_padding">
+ <ImageView
+ android:id="@+id/connectivity_off_test_no_connectivity_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/fs_indeterminate"
+ android:layout_marginRight="@dimen/js_padding"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/js_no_connectivity_test"
+ android:textSize="16dp"/>
+ </LinearLayout>
+
+ <include layout="@layout/pass_fail_buttons" />
+ </LinearLayout>
+</ScrollView>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/js_idle.xml b/apps/CtsVerifier/res/layout/js_idle.xml
index 90e55ec..453b638 100644
--- a/apps/CtsVerifier/res/layout/js_idle.xml
+++ b/apps/CtsVerifier/res/layout/js_idle.xml
@@ -1,63 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
android:layout_height="match_parent">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/js_test_description"
- android:layout_margin="@dimen/js_padding"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/js_idle_description_1"
- android:layout_margin="@dimen/js_padding"
- android:textStyle="bold"/>
-
- <Button
- android:id="@+id/js_idle_start_test_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="@string/js_start_test_text"
- android:onClick="startTest"
- android:enabled="false"/>
-
<LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/js_padding"
- android:layout_marginBottom="@dimen/js_padding">
- <ImageView
- android:id="@+id/idle_off_test_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/fs_indeterminate"
- android:layout_marginRight="@dimen/js_padding"/>
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
<TextView
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/js_idle_item_idle_off"
- android:textSize="16dp"/>
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/js_padding"
- android:layout_marginBottom="@dimen/js_padding">
- <ImageView
- android:id="@+id/idle_on_test_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/fs_indeterminate"
- android:layout_marginRight="@dimen/js_padding"/>
+ android:text="@string/js_test_description"
+ android:layout_margin="@dimen/js_padding"/>
<TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/js_idle_description_1"
+ android:layout_margin="@dimen/js_padding"
+ android:textStyle="bold"/>
+
+ <Button
+ android:id="@+id/js_idle_start_test_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/js_idle_item_idle_on"
- android:textSize="16dp"/>
+ android:layout_gravity="center"
+ android:text="@string/js_start_test_text"
+ android:onClick="startTest"
+ android:enabled="false"/>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/js_padding"
+ android:layout_marginBottom="@dimen/js_padding">
+ <ImageView
+ android:id="@+id/idle_off_test_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/fs_indeterminate"
+ android:layout_marginRight="@dimen/js_padding"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/js_idle_item_idle_off"
+ android:textSize="16dp"/>
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/js_padding"
+ android:layout_marginBottom="@dimen/js_padding">
+ <ImageView
+ android:id="@+id/idle_on_test_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/fs_indeterminate"
+ android:layout_marginRight="@dimen/js_padding"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/js_idle_item_idle_on"
+ android:textSize="16dp"/>
+ </LinearLayout>
+ <include layout="@layout/pass_fail_buttons" />
</LinearLayout>
- <include layout="@layout/pass_fail_buttons" />
-</LinearLayout>
\ No newline at end of file
+</ScrollView>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 014191b..2f3d62f 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1306,7 +1306,7 @@
<string name="js_charging_test">Charging Constraints</string>
<string name="js_charging_instructions">Verify the behaviour of the JobScheduler API for when the device is on power and unplugged from power. Simply follow the on-screen instructions.</string>
- <string name="js_charging_description_1">Unplug the phone in order to begin.</string>
+ <string name="js_charging_description_1">Unplug the device in order to begin.</string>
<string name="js_charging_off_test">Device not charging will not execute a job with a charging constraint.</string>
<string name="js_charging_on_test">Device when charging will execute a job with a charging constraint.</string>
<string name="js_charging_description_2">After the above test has passed, plug the device back in to continue. If the above failed, you can simply fail this test.</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
index 43d300a..1cc3547 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestListActivity.java
@@ -35,6 +35,11 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ if (!isTaskRoot()) {
+ finish();
+ }
+
setTitle(getString(R.string.title_version, Version.getVersionName(this)));
setTestListAdapter(new ManifestTestListAdapter(this, null));
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/os/TimeoutResetActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/os/TimeoutResetActivity.java
new file mode 100644
index 0000000..be78556
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/os/TimeoutResetActivity.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2014 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 com.android.cts.verifier.os;
+
+import android.app.Activity;
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.WindowManager;
+
+import java.lang.reflect.Field;
+
+/**
+ * Activity resets the screen timeout to its original timeout. Used devices without Device Admin.
+ */
+public class TimeoutResetActivity extends Activity {
+ public static final String EXTRA_OLD_TIMEOUT = "com.android.cts.verifier.extra.OLD_TIMEOUT";
+ /** Set the timeout to the default to reset the activity to if not specified. */
+ public static final long FALLBACK_TIMEOUT = -1L;
+ /**
+ * Empirically determined buffer time in milliseconds between setting short timeout time and
+ * resetting the timeout.
+ */
+ public static final long RESET_BUFFER_TIME = 2000L;
+ /** Short timeout to trigger screen off. */
+ public static final long SCREEN_OFF_TIMEOUT = 0L;
+ public static final String TAG = TimeoutResetActivity.class.getSimpleName();
+
+ private static long getUserActivityTimeout(WindowManager.LayoutParams params) {
+ try {
+ return getUserActivityTimeoutField(params).getLong(params);
+ } catch (Exception e) {
+ Log.e(TAG, "error loading the userActivityTimeout field", e);
+ return -1;
+ }
+ }
+
+ private static Field getUserActivityTimeoutField(WindowManager.LayoutParams params)
+ throws NoSuchFieldException {
+ return params.getClass().getField("userActivityTimeout");
+ }
+
+ private static void setUserActivityTimeout(WindowManager.LayoutParams params, long timeout) {
+ try {
+ getUserActivityTimeoutField(params).setLong(params, timeout);
+ Log.d(TAG, "UserActivityTimeout set to " + timeout);
+ } catch (Exception e) {
+ Log.e(TAG, "error setting the userActivityTimeout field", e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void turnOffScreen(final Activity activity) {
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ WindowManager.LayoutParams params = activity.getWindow().getAttributes();
+
+ // to restore timeout after shutoff
+ final long oldTimeout = getUserActivityTimeout(params);
+
+ final long timeout = SCREEN_OFF_TIMEOUT;
+ setUserActivityTimeout(params, timeout);
+
+ // upon setting this, timeout will be reduced
+ activity.getWindow().setAttributes(params);
+
+ ((AlarmManager) activity.getSystemService(ALARM_SERVICE)).setExact(
+ AlarmManager.RTC,
+ System.currentTimeMillis() + RESET_BUFFER_TIME,
+ PendingIntent.getActivity(
+ activity.getApplicationContext(),
+ 0,
+ new Intent(activity, TimeoutResetActivity.class)
+ .putExtra(EXTRA_OLD_TIMEOUT, oldTimeout),
+ 0));
+ }
+ });
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ long timeout = getIntent().getLongExtra(EXTRA_OLD_TIMEOUT, FALLBACK_TIMEOUT);
+ if (timeout < 1000) { // in case the old timeout was super low by accident
+ timeout = FALLBACK_TIMEOUT;
+ }
+
+ WindowManager.LayoutParams params = getWindow().getAttributes();
+ setUserActivityTimeout(params, timeout);
+ getWindow().setAttributes(params);
+
+ finish();
+ }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorPowerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorPowerTestActivity.java
index 8370d3e..74d51e4 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorPowerTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorPowerTestActivity.java
@@ -63,7 +63,7 @@
@Override
protected void activitySetUp() throws InterruptedException {
- mScreenManipulator = new SensorTestScreenManipulator(getApplicationContext());
+ mScreenManipulator = new SensorTestScreenManipulator(this);
mScreenManipulator.initialize(this);
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestActivity.java
index 16c5fcd..6512fd3 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestActivity.java
@@ -69,7 +69,7 @@
protected void activitySetUp() throws InterruptedException {
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SensorCtsTests");
- mScreenManipulator = new SensorTestScreenManipulator(getApplicationContext());
+ mScreenManipulator = new SensorTestScreenManipulator(this);
mScreenManipulator.initialize(this);
SensorTestLogger logger = getTestLogger();
@@ -80,6 +80,7 @@
// automated CTS tests run with the USB connected, so the AP doesn't go to sleep
// here we are not connected to USB, so we need to hold a wake-lock to avoid going to sleep
mWakeLock.acquire();
+
mScreenManipulator.turnScreenOff();
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/helpers/SensorTestScreenManipulator.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/helpers/SensorTestScreenManipulator.java
index 835ff56..2956ed7 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/helpers/SensorTestScreenManipulator.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/helpers/SensorTestScreenManipulator.java
@@ -16,6 +16,7 @@
package com.android.cts.verifier.sensors.helpers;
+import com.android.cts.verifier.os.TimeoutResetActivity;
import com.android.cts.verifier.sensors.base.BaseSensorTestActivity;
import com.android.cts.verifier.sensors.base.ISensorTestStateContainer;
@@ -27,8 +28,12 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.os.PowerManager;
import android.text.TextUtils;
+import android.util.Log;
+
+import java.util.concurrent.CountDownLatch;
/**
* A class that provides functionality to manipulate the state of the device's screen.
@@ -52,8 +57,9 @@
* - in a single-threaded environment
*/
public class SensorTestScreenManipulator {
+ private static final String TAG = SensorTestScreenManipulator.class.getSimpleName();
- private final Context mContext;
+ private final Activity mActivity;
private final DevicePolicyManager mDevicePolicyManager;
private final ComponentName mComponentName;
private final PowerManager.WakeLock mWakeUpScreenWakeLock;
@@ -62,16 +68,17 @@
private InternalBroadcastReceiver mBroadcastReceiver;
private boolean mTurnOffScreenOnPowerDisconnected;
- public SensorTestScreenManipulator(Context context) {
- mContext = context;
- mComponentName = SensorDeviceAdminReceiver.getComponentName(context);
+
+ public SensorTestScreenManipulator(Activity activity) {
+ mActivity = activity;
+ mComponentName = SensorDeviceAdminReceiver.getComponentName(activity);
mDevicePolicyManager =
- (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
int levelAndFlags = PowerManager.FULL_WAKE_LOCK
| PowerManager.ON_AFTER_RELEASE
| PowerManager.ACQUIRE_CAUSES_WAKEUP;
- PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
+ PowerManager powerManager = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
mWakeUpScreenWakeLock = powerManager.newWakeLock(levelAndFlags, "SensorTestWakeUpScreen");
mWakeUpScreenWakeLock.setReferenceCounted(false);
mKeepScreenOnWakeLock = powerManager.newWakeLock(levelAndFlags, "SensorTestKeepScreenOn");
@@ -87,7 +94,7 @@
*/
public synchronized void initialize(ISensorTestStateContainer stateContainer)
throws InterruptedException {
- if (!isDeviceAdminInitialized()) {
+ if (hasDeviceAdminFeature() && !isDeviceAdminInitialized()) {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mComponentName);
int resultCode = stateContainer.executeActivity(intent);
@@ -101,7 +108,7 @@
mBroadcastReceiver = new InternalBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
- mContext.registerReceiver(mBroadcastReceiver, intentFilter);
+ mActivity.registerReceiver(mBroadcastReceiver, intentFilter);
}
}
@@ -111,7 +118,7 @@
*/
public synchronized void close() {
if (mBroadcastReceiver != null) {
- mContext.unregisterReceiver(mBroadcastReceiver);
+ mActivity.unregisterReceiver(mBroadcastReceiver);
mBroadcastReceiver = null;
}
}
@@ -121,8 +128,30 @@
*/
public synchronized void turnScreenOff() {
ensureDeviceAdminInitialized();
+
+ final CountDownLatch screenOffSignal = new CountDownLatch(1);
+ BroadcastReceiver screenOffBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mActivity.unregisterReceiver(this);
+ screenOffSignal.countDown();
+ }
+ };
+ mActivity.registerReceiver(
+ screenOffBroadcastReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
+
releaseScreenOn();
- mDevicePolicyManager.lockNow();
+ if (hasDeviceAdminFeature()) {
+ mDevicePolicyManager.lockNow();
+ } else {
+ TimeoutResetActivity.turnOffScreen(mActivity);
+ }
+
+ try {
+ screenOffSignal.await();
+ } catch (InterruptedException e) {
+ Log.wtf(TAG, "error waiting for screen off signal", e);
+ }
}
/**
@@ -175,7 +204,7 @@
}
private void ensureDeviceAdminInitialized() throws IllegalStateException {
- if (!isDeviceAdminInitialized()) {
+ if (hasDeviceAdminFeature() && !isDeviceAdminInitialized()) {
throw new IllegalStateException("Component must be initialized before it can be used.");
}
}
@@ -188,6 +217,10 @@
.hasGrantedPolicy(mComponentName, DeviceAdminInfo.USES_POLICY_FORCE_LOCK);
}
+ private boolean hasDeviceAdminFeature() {
+ return mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN);
+ }
+
private class InternalBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java
index 5346ae1..ec2f95b 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java
@@ -326,7 +326,13 @@
flashTestByAeMode(listener, CaptureRequest.CONTROL_AE_MODE_ON);
// LEGACY won't support AE mode OFF
- if (mStaticInfo.isHardwareLevelLimitedOrBetter()) {
+ boolean aeOffModeSupported = false;
+ for (int aeMode : mStaticInfo.getAeAvailableModesChecked()) {
+ if (aeMode == CaptureRequest.CONTROL_AE_MODE_OFF) {
+ aeOffModeSupported = true;
+ }
+ }
+ if (aeOffModeSupported) {
flashTestByAeMode(listener, CaptureRequest.CONTROL_AE_MODE_OFF);
}
diff --git a/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java b/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java
index ee1b027..66054f9 100644
--- a/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java
+++ b/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java
@@ -199,7 +199,7 @@
/* drm server is always present */
public void testDrmServerDomain() throws FileNotFoundException {
- assertDomainOne("u:r:drmserver:s0", "/system/bin/drmserver");
+ assertDomainZeroOrOne("u:r:drmserver:s0", "/system/bin/drmserver");
}
/* Media server is always running */