Merge "Cleanup stacks before performing drag and drop tests" into nyc-dev
diff --git a/apps/CameraITS/tests/scene1/test_param_shading_mode.py b/apps/CameraITS/tests/scene1/test_param_shading_mode.py
index 8538675..c945791 100644
--- a/apps/CameraITS/tests/scene1/test_param_shading_mode.py
+++ b/apps/CameraITS/tests/scene1/test_param_shading_mode.py
@@ -14,6 +14,7 @@
import its.caps
import its.device
+import its.image
import its.objects
import matplotlib
import numpy
diff --git a/apps/CameraITS/tests/scene1/test_tonemap_sequence.py b/apps/CameraITS/tests/scene1/test_tonemap_sequence.py
index 7c87ca2..54d3d65 100644
--- a/apps/CameraITS/tests/scene1/test_tonemap_sequence.py
+++ b/apps/CameraITS/tests/scene1/test_tonemap_sequence.py
@@ -26,7 +26,7 @@
# There should be 3 identical frames followed by a different set of
# 3 identical frames.
- MAX_SAME_DELTA = 0.01
+ MAX_SAME_DELTA = 0.015
MIN_DIFF_DELTA = 0.10
with its.device.ItsSession() as cam:
diff --git a/apps/CtsVerifier/jni/audio_loopback/jni_sles.c b/apps/CtsVerifier/jni/audio_loopback/jni_sles.c
index a865078..e8a837e 100644
--- a/apps/CtsVerifier/jni/audio_loopback/jni_sles.c
+++ b/apps/CtsVerifier/jni/audio_loopback/jni_sles.c
@@ -22,11 +22,12 @@
/////
JNIEXPORT jlong JNICALL Java_com_android_cts_verifier_audio_NativeAudioThread_slesInit
- (JNIEnv *env __unused, jobject obj __unused, jint samplingRate, jint frameCount, jint micSource) {
+ (JNIEnv *env __unused, jobject obj __unused, jint samplingRate, jint frameCount,
+ jint micSource, jint numFramesToIgnore) {
sles_data * pSles = NULL;
- if (slesInit(&pSles, samplingRate, frameCount, micSource) != SLES_FAIL) {
+ if (slesInit(&pSles, samplingRate, frameCount, micSource, numFramesToIgnore) != SLES_FAIL) {
return (long)pSles;
}
diff --git a/apps/CtsVerifier/jni/audio_loopback/jni_sles.h b/apps/CtsVerifier/jni/audio_loopback/jni_sles.h
index 7bff040..d7aa625 100644
--- a/apps/CtsVerifier/jni/audio_loopback/jni_sles.h
+++ b/apps/CtsVerifier/jni/audio_loopback/jni_sles.h
@@ -25,7 +25,7 @@
////////////////////////
JNIEXPORT jlong JNICALL Java_com_android_cts_verifier_audio_NativeAudioThread_slesInit
- (JNIEnv *, jobject, jint, jint, jint );
+ (JNIEnv *, jobject, jint, jint, jint, jint );
JNIEXPORT jint JNICALL Java_com_android_cts_verifier_audio_NativeAudioThread_slesProcessNext
(JNIEnv *, jobject , jlong, jdoubleArray, jlong );
diff --git a/apps/CtsVerifier/jni/audio_loopback/sles.cpp b/apps/CtsVerifier/jni/audio_loopback/sles.cpp
index b0b683b..586c60f 100644
--- a/apps/CtsVerifier/jni/audio_loopback/sles.cpp
+++ b/apps/CtsVerifier/jni/audio_loopback/sles.cpp
@@ -35,7 +35,8 @@
#include <string.h>
#include <unistd.h>
-int slesInit(sles_data ** ppSles, int samplingRate, int frameCount, int micSource) {
+int slesInit(sles_data ** ppSles, int samplingRate, int frameCount, int micSource,
+ int numFramesToIgnore) {
int status = SLES_FAIL;
if (ppSles != NULL) {
sles_data * pSles = (sles_data*) calloc(1, sizeof (sles_data));
@@ -46,7 +47,8 @@
{
SLES_PRINTF("creating server. Sampling rate =%d, frame count = %d",samplingRate,
frameCount);
- status = slesCreateServer(pSles, samplingRate, frameCount, micSource);
+ status = slesCreateServer(pSles, samplingRate, frameCount, micSource,
+ numFramesToIgnore);
SLES_PRINTF("slesCreateServer =%d", status);
}
}
@@ -94,6 +96,17 @@
pSles->rxFront = 0;
}
+ // Throw out first frames
+ if (pSles->numFramesToIgnore) {
+ SLuint32 framesToErase = pSles->numFramesToIgnore;
+ if (framesToErase > pSles->bufSizeInFrames) {
+ framesToErase = pSles->bufSizeInFrames;
+ }
+ pSles->numFramesToIgnore -= framesToErase;
+ // FIXME: this assumes each sample is a short
+ memset(buffer, 0, framesToErase * pSles->channels * sizeof(short));
+ }
+
ssize_t actual = audio_utils_fifo_write(&(pSles->fifo), buffer,
(size_t) pSles->bufSizeInFrames);
if (actual != (ssize_t) pSles->bufSizeInFrames) {
@@ -199,7 +212,8 @@
} //pSles not null
}
-int slesCreateServer(sles_data *pSles, int samplingRate, int frameCount, int micSource) {
+int slesCreateServer(sles_data *pSles, int samplingRate, int frameCount,
+ int micSource, int numFramesToIgnore) {
int status = SLES_FAIL;
if (pSles == NULL) {
@@ -254,6 +268,12 @@
pSles->bufSizeInBytes = 0; // calculated
pSles->injectImpulse = 300; // -i#i
+ if (numFramesToIgnore > 0) {
+ pSles->numFramesToIgnore = numFramesToIgnore;
+ } else {
+ pSles->numFramesToIgnore = 0;
+ }
+
// Storage area for the buffer queues
// char **rxBuffers;
// char **txBuffers;
diff --git a/apps/CtsVerifier/jni/audio_loopback/sles.h b/apps/CtsVerifier/jni/audio_loopback/sles.h
index 2550b81..607f724 100644
--- a/apps/CtsVerifier/jni/audio_loopback/sles.h
+++ b/apps/CtsVerifier/jni/audio_loopback/sles.h
@@ -41,6 +41,7 @@
SLuint32 freeBufCount; // calculated
SLuint32 bufSizeInBytes; // calculated
int injectImpulse; // -i#i
+ SLuint32 numFramesToIgnore;
// Storage area for the buffer queues
char **rxBuffers;
@@ -76,7 +77,8 @@
SLES_FAIL = 1,
} SLES_STATUS_ENUM;
-int slesInit(sles_data ** ppSles, int samplingRate, int frameCount, int micSource);
+int slesInit(sles_data ** ppSles, int samplingRate, int frameCount,
+ int micSource, int numFramesToIgnore);
//note the double pointer to properly free the memory of the structure
int slesDestroy(sles_data ** ppSles);
@@ -84,7 +86,7 @@
///full
int slesFull(sles_data *pSles);
-int slesCreateServer(sles_data *pSles, int samplingRate, int frameCount, int micSource);
+int slesCreateServer(sles_data *pSles, int samplingRate, int frameCount, int micSource, int numFramesToIgnore);
int slesProcessNext(sles_data *pSles, double *pSamples, long maxSamples);
int slesDestroyServer(sles_data *pSles);
diff --git a/apps/CtsVerifier/res/layout/list_item.xml b/apps/CtsVerifier/res/layout/list_item.xml
index 7fd9002..efa1483 100644
--- a/apps/CtsVerifier/res/layout/list_item.xml
+++ b/apps/CtsVerifier/res/layout/list_item.xml
@@ -22,4 +22,4 @@
android:fontFamily="sans-serif-light"
android:textSize="14dp"
android:freezesText="true"
- android:background="#ff1f1f1f" />
\ No newline at end of file
+ android:background="#fff" />
diff --git a/apps/CtsVerifier/res/layout/widget_layout.xml b/apps/CtsVerifier/res/layout/widget_layout.xml
index 4e2a6b6..b0cce17 100644
--- a/apps/CtsVerifier/res/layout/widget_layout.xml
+++ b/apps/CtsVerifier/res/layout/widget_layout.xml
@@ -21,7 +21,7 @@
android:layout_marginLeft="@dimen/widget_margin_left"
android:layout_marginRight="@dimen/widget_margin_right"
android:padding="1dp"
- android:background="#2f2f2f">
+ android:background="#fff">
<LinearLayout
android:orientation="vertical"
@@ -32,7 +32,7 @@
android:paddingBottom="12dp"
android:paddingRight="12dp"
android:layout_gravity="center"
- android:background="#222">
+ android:background="#fff">
<TextView
android:id="@+id/title"
@@ -70,7 +70,7 @@
android:layout_weight="1"
android:layout_marginBottom="12dp"
android:padding="1dp"
- android:background="#333"
+ android:background="#fff"
android:visibility="gone"/>
<LinearLayout
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioLoopbackActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioLoopbackActivity.java
index fbec57a..9e52d95 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioLoopbackActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioLoopbackActivity.java
@@ -58,6 +58,9 @@
private static final double CONFIDENCE_THRESHOLD = 0.6;
private Correlation mCorrelation = new Correlation();
+ // TODO: remove this when no longer necessary
+ private int mNumFramesToIgnore = mSamplingRate / 10; // ignore first 100 ms
+
OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
Context mContext;
@@ -221,7 +224,8 @@
nativeAudioThread.setParams(mSamplingRate,
minBufferSizeInBytes,
minBufferSizeInBytes,
- 0x03 /*voice recognition*/);
+ 0x03 /*voice recognition*/,
+ mNumFramesToIgnore);
nativeAudioThread.start();
try {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/NativeAudioThread.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/NativeAudioThread.java
index 224d4c8..0bb1298 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/NativeAudioThread.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/NativeAudioThread.java
@@ -53,6 +53,8 @@
int mMicSource = 0;
+ int mNumFramesToIgnore;
+
// private double [] samples = new double[50000];
boolean isPlaying = false;
@@ -66,11 +68,12 @@
static final int NATIVE_AUDIO_THREAD_MESSAGE_REC_COMPLETE_ERRORS = 895;
public void setParams(int samplingRate, int playBufferInBytes, int recBufferInBytes,
- int micSource) {
+ int micSource, int numFramesToIgnore) {
mSamplingRate = samplingRate;
mMinPlayBufferSizeInBytes = playBufferInBytes;
mMinRecordBuffSizeInBytes = recBufferInBytes;
mMicSource = micSource;
+ mNumFramesToIgnore = numFramesToIgnore;
}
//JNI load
@@ -86,7 +89,8 @@
}
//jni calls
- public native long slesInit(int samplingRate, int frameCount, int micSource);
+ public native long slesInit(int samplingRate, int frameCount, int micSource,
+ int numFramesToIgnore);
public native int slesProcessNext(long sles_data, double[] samples, long offset);
public native int slesDestroy(long sles_data);
@@ -124,7 +128,8 @@
log(String.format("about to init, sampling rate: %d, buffer:%d", mSamplingRate,
mMinPlayBufferSizeInBytes/2 ));
- long sles_data = slesInit(mSamplingRate, mMinPlayBufferSizeInBytes/2, mMicSource);
+ long sles_data = slesInit(mSamplingRate, mMinPlayBufferSizeInBytes/2, mMicSource,
+ mNumFramesToIgnore);
log(String.format("sles_data = 0x%X",sles_data));
if (sles_data == 0 ) {
diff --git a/common/host-side/tradefed/res/report/compatibility_result.xsl b/common/host-side/tradefed/res/report/compatibility_result.xsl
index ac5c282..7bd650d 100644
--- a/common/host-side/tradefed/res/report/compatibility_result.xsl
+++ b/common/host-side/tradefed/res/report/compatibility_result.xsl
@@ -45,7 +45,7 @@
<tr>
<td class="rowtitle">Suite / Plan</td>
<td>
- <xsl:value-of select="Result/@suite_name"/> / <xsl:value-of select="Result/@plan"/>
+ <xsl:value-of select="Result/@suite_name"/> / <xsl:value-of select="Result/@suite_plan"/>
</td>
</tr>
<tr>
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
index ad1158e..2a8a4e5 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
@@ -263,8 +263,6 @@
synchronized (mModuleRepo) {
if (!mModuleRepo.isInitialized()) {
setupFilters();
- // Set retry mode for module repo
- mModuleRepo.setRetryMode(mRetrySessionId != null);
// Initialize the repository, {@link CompatibilityBuildHelper#getTestsDir} can
// throw a {@link FileNotFoundException}
mModuleRepo.initialize(mTotalShards, mBuildHelper.getTestsDir(), getAbis(),
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java
index e1d5eb2..cf52f35 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java
@@ -41,11 +41,6 @@
List<String> mExcludeFilters, IBuildInfo buildInfo);
/**
- * Set the retry mode of the module repo.
- */
- void setRetryMode(boolean isRetry);
-
- /**
* @return a {@link Map} of all modules to run on the device referenced by the given serial.
*/
List<IModuleDef> getModules(String serial);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
index a2cef9e..de509c8 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
@@ -68,7 +68,6 @@
private int mMediumModulesPerShard;
private int mLargeModulesPerShard;
private int mModuleCount = 0;
- private boolean mIsRetry = false;
private Set<String> mSerials = new HashSet<>();
private Map<String, Set<String>> mDeviceTokens = new HashMap<>();
private Map<String, Map<String, String>> mTestArgs = new HashMap<>();
@@ -202,11 +201,6 @@
return mInitialized;
}
- @Override
- public void setRetryMode(boolean isRetry) {
- mIsRetry = isRetry;
- }
-
/**
* {@inheritDoc}
*/
@@ -409,7 +403,7 @@
private void addTestIncludes(ITestFilterReceiver test, List<TestFilter> includes,
String name) {
- if (mIsRetry && test instanceof ITestFileFilterReceiver) {
+ if (test instanceof ITestFileFilterReceiver) {
File includeFile = createFilterFile(name, ".include", includes);
((ITestFileFilterReceiver)test).setIncludeTestFile(includeFile);
} else {
@@ -425,7 +419,7 @@
private void addTestExcludes(ITestFilterReceiver test, List<TestFilter> excludes,
String name) {
- if (mIsRetry && test instanceof ITestFileFilterReceiver) {
+ if (test instanceof ITestFileFilterReceiver) {
File excludeFile = createFilterFile(name, ".exclude", excludes);
((ITestFileFilterReceiver)test).setExcludeTestFile(excludeFile);
} else {
diff --git a/hostsidetests/services/activitymanager/app/AndroidManifest.xml b/hostsidetests/services/activitymanager/app/AndroidManifest.xml
index 7ab6e33..d835517 100755
--- a/hostsidetests/services/activitymanager/app/AndroidManifest.xml
+++ b/hostsidetests/services/activitymanager/app/AndroidManifest.xml
@@ -143,6 +143,9 @@
android:minHeight="80dp"
/>
</activity>
+ <activity android:name=".TurnScreenOnActivity"
+ android:exported="true"
+ />
</application>
</manifest>
diff --git a/hostsidetests/services/activitymanager/app/src/android/server/app/LaunchToSideActivity.java b/hostsidetests/services/activitymanager/app/src/android/server/app/LaunchToSideActivity.java
index 9714393..1fef1a5 100644
--- a/hostsidetests/services/activitymanager/app/src/android/server/app/LaunchToSideActivity.java
+++ b/hostsidetests/services/activitymanager/app/src/android/server/app/LaunchToSideActivity.java
@@ -1,10 +1,12 @@
package android.server.app;
import static android.content.Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT;
+import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import android.app.Activity;
import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
public class LaunchToSideActivity extends Activity {
@@ -12,9 +14,18 @@
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
final Bundle extras = intent.getExtras();
- if (extras != null && extras.getBoolean("launch_to_the_side")) {
+ if (extras != null && extras.getBoolean("launch_to_the_side")) {
Intent newIntent = new Intent(this, TestActivity.class);
newIntent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_LAUNCH_ADJACENT);
+ if (extras.getBoolean("multiple_task")) {
+ newIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
+ }
+ if (extras.getBoolean("random_data")) {
+ Uri data = new Uri.Builder()
+ .path(String.valueOf(System.currentTimeMillis()))
+ .build();
+ newIntent.setData(data);
+ }
startActivity(newIntent);
}
}
diff --git a/hostsidetests/services/activitymanager/app/src/android/server/app/TurnScreenOnActivity.java b/hostsidetests/services/activitymanager/app/src/android/server/app/TurnScreenOnActivity.java
new file mode 100644
index 0000000..838a1d6
--- /dev/null
+++ b/hostsidetests/services/activitymanager/app/src/android/server/app/TurnScreenOnActivity.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 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.server.app;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.WindowManager;
+
+public class TurnScreenOnActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
+ | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
+ | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
+ super.onCreate(savedInstanceState);
+ }
+}
diff --git a/hostsidetests/services/activitymanager/appDisplaySize/AndroidManifest.xml b/hostsidetests/services/activitymanager/appDisplaySize/AndroidManifest.xml
index 49649b6..7727759 100644
--- a/hostsidetests/services/activitymanager/appDisplaySize/AndroidManifest.xml
+++ b/hostsidetests/services/activitymanager/appDisplaySize/AndroidManifest.xml
@@ -25,7 +25,8 @@
<supports-screens android:requiresSmallestWidthDp="100000" />
<application>
- <activity android:name=".SmallestWidthActivity" />
+ <activity android:name=".SmallestWidthActivity"
+ android:exported="true" />
</application>
</manifest>
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerActivityVisiblityTests.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerActivityVisiblityTests.java
index 140b684..b485377 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerActivityVisiblityTests.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerActivityVisiblityTests.java
@@ -28,6 +28,7 @@
private static final String TEST_ACTIVITY_NAME = "TestActivity";
private static final String TRANSLUCENT_ACTIVITY_NAME = "TranslucentActivity";
private static final String DOCKED_ACTIVITY_NAME = "DockedActivity";
+ private static final String TURN_SCREEN_ON_ACTIVITY_NAME = "TurnScreenOnActivity";
public void testVisibleBehindHomeActivity() throws Exception {
executeShellCommand(getAmStartCmd(VISIBLE_BEHIND_ACTIVITY));
@@ -133,4 +134,12 @@
mAmWmState.assertVisibility(TEST_ACTIVITY_NAME, true);
mAmWmState.assertVisibility(TRANSLUCENT_ACTIVITY_NAME, true);
}
+
+ public void testTurnScreenOnActivity() throws Exception {
+ lockDevice();
+ executeShellCommand(getAmStartCmd(TURN_SCREEN_ON_ACTIVITY_NAME));
+ mAmWmState.computeState(mDevice, new String[] { TURN_SCREEN_ON_ACTIVITY_NAME });
+ mAmWmState.assertSanity();
+ mAmWmState.assertVisibility(TURN_SCREEN_ON_ACTIVITY_NAME, true);
+ }
}
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
index 65b02d0..9957a61 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
@@ -128,6 +128,75 @@
.getTaskByActivityName(TEST_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID));
}
+ public void testLaunchToSideMultipleWithDifferentIntent() throws Exception {
+ launchActivityInDockStack(LAUNCH_TO_SIDE_ACTIVITY_NAME);
+ printStacksAndTasks();
+ final String[] waitForActivitiesVisible = new String[] {TEST_ACTIVITY_NAME};
+
+ // Launch activity to side with data.
+ launchActivityToSide(LAUNCH_TO_SIDE_ACTIVITY_NAME, true, false);
+ mAmWmState.computeState(mDevice, waitForActivitiesVisible);
+ int taskNumberInitial = mAmWmState.getAmState().getStackById(FULLSCREEN_WORKSPACE_STACK_ID)
+ .getTasks().size();
+ mAmWmState.assertNotNull("Launched to side activity must be in fullscreen stack.",
+ mAmWmState.getAmState()
+ .getTaskByActivityName(TEST_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID));
+
+ // Try to launch to side same activity again with different data.
+ launchActivityToSide(LAUNCH_TO_SIDE_ACTIVITY_NAME, true, false);
+ mAmWmState.computeState(mDevice, waitForActivitiesVisible);
+ int taskNumberSecondLaunch = mAmWmState.getAmState()
+ .getStackById(FULLSCREEN_WORKSPACE_STACK_ID).getTasks().size();
+ mAmWmState.assertEquals("Task number must be incremented.", taskNumberInitial + 1,
+ taskNumberSecondLaunch);
+ mAmWmState.assertFocusedActivity("Launched to side activity must be in front.",
+ TEST_ACTIVITY_NAME);
+ mAmWmState.assertNotNull("Launched to side activity must be launched in fullscreen stack.",
+ mAmWmState.getAmState()
+ .getTaskByActivityName(TEST_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID));
+
+ // Try to launch to side same activity again with no data.
+ launchActivityToSide(LAUNCH_TO_SIDE_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, waitForActivitiesVisible);
+ int taskNumberFinal = mAmWmState.getAmState().getStackById(FULLSCREEN_WORKSPACE_STACK_ID)
+ .getTasks().size();
+ mAmWmState.assertEquals("Task number must be incremented.", taskNumberSecondLaunch + 1,
+ taskNumberFinal);
+ mAmWmState.assertFocusedActivity("Launched to side activity must be in front.",
+ TEST_ACTIVITY_NAME);
+ mAmWmState.assertNotNull("Launched to side activity must be launched in fullscreen stack.",
+ mAmWmState.getAmState()
+ .getTaskByActivityName(TEST_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID));
+ }
+
+ public void testLaunchToSideMultipleWithFlag() throws Exception {
+ launchActivityInDockStack(LAUNCH_TO_SIDE_ACTIVITY_NAME);
+ printStacksAndTasks();
+ final String[] waitForActivitiesVisible = new String[] {TEST_ACTIVITY_NAME};
+
+ // Launch activity to side.
+ launchActivityToSide(LAUNCH_TO_SIDE_ACTIVITY_NAME);
+ mAmWmState.computeState(mDevice, waitForActivitiesVisible);
+ int taskNumberInitial = mAmWmState.getAmState().getStackById(FULLSCREEN_WORKSPACE_STACK_ID)
+ .getTasks().size();
+ mAmWmState.assertNotNull("Launched to side activity must be in fullscreen stack.",
+ mAmWmState.getAmState()
+ .getTaskByActivityName(TEST_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID));
+
+ // Try to launch to side same activity again, but with Intent#FLAG_ACTIVITY_MULTIPLE_TASK.
+ launchActivityToSide(LAUNCH_TO_SIDE_ACTIVITY_NAME, false, true);
+ mAmWmState.computeState(mDevice, waitForActivitiesVisible);
+ int taskNumberFinal = mAmWmState.getAmState().getStackById(FULLSCREEN_WORKSPACE_STACK_ID)
+ .getTasks().size();
+ mAmWmState.assertEquals("Task number must be incremented.", taskNumberInitial + 1,
+ taskNumberFinal);
+ mAmWmState.assertFocusedActivity("Launched to side activity must be in front.",
+ TEST_ACTIVITY_NAME);
+ mAmWmState.assertNotNull("Launched to side activity must remain in fullscreen stack.",
+ mAmWmState.getAmState()
+ .getTaskByActivityName(TEST_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID));
+ }
+
public void testRotationWhenDocked() throws Exception {
launchActivityInDockStack(LAUNCH_TO_SIDE_ACTIVITY_NAME);
launchActivityToSide(LAUNCH_TO_SIDE_ACTIVITY_NAME);
@@ -257,7 +326,19 @@
}
private void launchActivityToSide(String activityName) throws Exception {
- executeShellCommand(
- getAmStartCmd(activityName) + " -f 0x20000000 --ez launch_to_the_side true");
+ launchActivityToSide(activityName, false, false);
+ }
+
+ private void launchActivityToSide(String activityName, boolean randomData,
+ boolean multipleTaskFlag) throws Exception {
+ StringBuilder commandBuilder = new StringBuilder(getAmStartCmd(activityName));
+ commandBuilder.append(" -f 0x20000000 --ez launch_to_the_side true");
+ if (randomData) {
+ commandBuilder.append(" --ez random_data true");
+ }
+ if (multipleTaskFlag) {
+ commandBuilder.append(" --ez multiple_task true");
+ }
+ executeShellCommand(commandBuilder.toString());
}
}
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java
index 3d053e3..22e2738 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java
@@ -116,6 +116,7 @@
protected void tearDown() throws Exception {
super.tearDown();
try {
+ unlockDevice();
executeShellCommand(AM_FORCE_STOP_TEST_PACKAGE);
setAccelerometerRotation(mInitialAccelerometerRotation);
setUserRotation(mUserRotation);
@@ -231,8 +232,43 @@
return result;
}
+ private boolean isDisplayOn() throws DeviceNotAvailableException {
+ final Pattern displayStatePattern = Pattern.compile("Display Power: state=(.+)");
+ final CollectingOutputReceiver outputReceiver = new CollectingOutputReceiver();
+ mDevice.executeShellCommand("dumpsys power", outputReceiver);
+ final LinkedList<String> dumpLines = new LinkedList();
+ Collections.addAll(dumpLines, outputReceiver.getOutput().split("\\n"));
+
+ while (!dumpLines.isEmpty()) {
+ final String line = dumpLines.pop().trim();
+
+ Matcher matcher = displayStatePattern.matcher(line);
+ if (matcher.matches()) {
+ final String state = matcher.group(1);
+ log("power state=" + state);
+ return "ON".equals(state);
+ }
+ }
+ log("power state :(");
+ return false;
+ }
+
protected void lockDevice() throws DeviceNotAvailableException {
+ int retriesLeft = 5;
runCommandAndPrintOutput("input keyevent 26");
+ do {
+ if (isDisplayOn()) {
+ log("***Waiting for display to turn off...");
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ log(e.toString());
+ // Well I guess we are not waiting...
+ }
+ } else {
+ break;
+ }
+ } while (retriesLeft-- > 0);
}
protected void unlockDevice() throws DeviceNotAvailableException {
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/DisplaySizeTest.java b/hostsidetests/services/activitymanager/src/android/server/cts/DisplaySizeTest.java
index a6a6b5c..9813b00 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/DisplaySizeTest.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/DisplaySizeTest.java
@@ -31,6 +31,7 @@
private static final String AM_START_COMMAND = "am start -n %s/%s.%s";
private static final String AM_FORCE_STOP = "am force-stop %s";
+ private static final int ACTIVITY_TIMEOUT_MILLIS = 1000;
private static final int WINDOW_TIMEOUT_MILLIS = 1000;
private ITestDevice mDevice;
@@ -45,7 +46,7 @@
// since the feature verifies that we're in a non-default density.
final int stableDensity = getStableDensity();
final int targetDensity = (int) (stableDensity * 0.85);
- mDevice.executeShellCommand("wm density " + targetDensity);
+ setDensity(targetDensity);
}
@Override
@@ -65,6 +66,7 @@
public void testCompatibilityDialog() throws Exception {
startActivity("android.displaysize.app", "SmallestWidthActivity");
+ verifyWindowDisplayed("SmallestWidthActivity", ACTIVITY_TIMEOUT_MILLIS);
verifyWindowDisplayed("UnsupportedDisplaySizeDialog", WINDOW_TIMEOUT_MILLIS);
}
@@ -83,6 +85,16 @@
}
}
+ private void setDensity(int targetDensity) throws DeviceNotAvailableException {
+ mDevice.executeShellCommand("wm density " + targetDensity);
+
+ // Verify that the density is changed.
+ final String output = mDevice.executeShellCommand("wm density");
+ final boolean success = output.contains("Override density: " + targetDensity);
+
+ assertTrue("Failed to set density to " + targetDensity, success);
+ }
+
private void forceStopPackage(String packageName) throws DeviceNotAvailableException {
final String forceStopCmd = String.format(AM_FORCE_STOP, packageName);
mDevice.executeShellCommand(forceStopCmd);
diff --git a/libs/deviceutil/src/android/cts/util/MediaPerfUtils.java b/libs/deviceutil/src/android/cts/util/MediaPerfUtils.java
index 7690895..f691150 100644
--- a/libs/deviceutil/src/android/cts/util/MediaPerfUtils.java
+++ b/libs/deviceutil/src/android/cts/util/MediaPerfUtils.java
@@ -31,7 +31,10 @@
private static final int MOVING_AVERAGE_NUM_FRAMES = 10;
private static final int MOVING_AVERAGE_WINDOW_MS = 1000;
- private static final double FRAMERATE_TOLERANCE = Math.sqrt(4);
+ // allow a variance of 2x for measured frame rates (e.g. half of lower-limit to double of
+ // upper-limit of the published values). Also allow an extra 10% margin. This also acts as
+ // a limit for the size of the published rates (e.g. upper-limit / lower-limit <= tolerance).
+ private static final double FRAMERATE_TOLERANCE = 2.0 * 1.1;
/*
* ------------------ HELPER METHODS FOR ACHIEVABLE FRAME RATES ------------------
diff --git a/libs/deviceutil/src/android/cts/util/MediaUtils.java b/libs/deviceutil/src/android/cts/util/MediaUtils.java
index bee2732..46b6769 100644
--- a/libs/deviceutil/src/android/cts/util/MediaUtils.java
+++ b/libs/deviceutil/src/android/cts/util/MediaUtils.java
@@ -60,6 +60,20 @@
* tests. This centralizes the way to signal errors during a test.
*/
public static String getTestName() {
+ return getTestName(false /* withClass */);
+ }
+
+ /**
+ * Returns the test name with the full class (heuristically).
+ *
+ * Since it uses heuristics, this method has only been verified for media
+ * tests. This centralizes the way to signal errors during a test.
+ */
+ public static String getTestNameWithClass() {
+ return getTestName(true /* withClass */);
+ }
+
+ private static String getTestName(boolean withClass) {
int bestScore = -1;
String testName = "test???";
Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
@@ -122,6 +136,9 @@
if (score > bestScore) {
bestScore = score;
testName = methodName;
+ if (withClass) {
+ testName = stack[index].getClassName() + "." + testName;
+ }
}
}
}
@@ -136,6 +153,14 @@
*/
public static void skipTest(String tag, String reason) {
Log.i(tag, "SKIPPING " + getTestName() + "(): " + reason);
+ DeviceReportLog log = new DeviceReportLog("CtsMediaSkippedTests", "test_skipped");
+ log.addValue("reason", reason, ResultType.NEUTRAL, ResultUnit.NONE);
+ log.addValue(
+ "test", getTestNameWithClass(), ResultType.NEUTRAL, ResultUnit.NONE);
+ // TODO: replace with submit() when it is added to DeviceReportLog
+ try {
+ log.submit(null);
+ } catch (NullPointerException e) { }
}
/**
diff --git a/tests/libcore/luni/Android.mk b/tests/libcore/luni/Android.mk
index 02caf32..22a975d 100644
--- a/tests/libcore/luni/Android.mk
+++ b/tests/libcore/luni/Android.mk
@@ -20,14 +20,11 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
apache-harmony-tests \
- bouncycastle-nojarjar \
conscrypt-tests \
core-tests \
cts-core-test-runner \
jsr166-tests \
mockito-target \
- okhttp-nojarjar \
- okhttp-tests-nojarjar \
tzdata_update-tests
# Don't include this package in any target
diff --git a/tests/libcore/okhttp/Android.mk b/tests/libcore/okhttp/Android.mk
new file mode 100644
index 0000000..ad78841
--- /dev/null
+++ b/tests/libcore/okhttp/Android.mk
@@ -0,0 +1,53 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := CtsLibcoreOkHttpTestCases
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ bouncycastle-nojarjar \
+ cts-core-test-runner \
+ okhttp-nojarjar \
+ okhttp-tests-nojarjar
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+LOCAL_JACK_FLAGS := --multi-dex native
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+# Include both the 32 and 64 bit versions of libjavacoretests,
+# where applicable.
+LOCAL_MULTILIB := both
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+LOCAL_JAVA_RESOURCE_FILES := \
+ libcore/expectations/brokentests.txt \
+ libcore/expectations/icebox.txt \
+ libcore/expectations/knownfailures.txt \
+ libcore/expectations/taggedtests.txt
+
+LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/okhttp/AndroidManifest.xml b/tests/libcore/okhttp/AndroidManifest.xml
new file mode 100644
index 0000000..d11d0be
--- /dev/null
+++ b/tests/libcore/okhttp/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2016 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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.libcore.cts.okhttp">
+ <uses-permission android:name="android.permission.INTERNET" />
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="com.android.cts.core.runner.CoreTestRunner"
+ android:targetPackage="android.libcore.cts.okhttp"
+ android:label="CTS Libcore OkHttp test cases" />
+
+</manifest>
diff --git a/tests/libcore/okhttp/AndroidTest.xml b/tests/libcore/okhttp/AndroidTest.xml
new file mode 100644
index 0000000..00c390d
--- /dev/null
+++ b/tests/libcore/okhttp/AndroidTest.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+<configuration description="Config for CTS Libcore OkHttp test cases">
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="mkdir -p /data/local/tmp/ctslibcore/java.io.tmpdir" />
+ <option name="run-command" value="mkdir -p /data/local/tmp/ctslibcore/user.home" />
+ <option name="teardown-command" value="rm -rf /data/local/tmp/ctslibcore" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <!-- this has the CoreTestRunner which needs to be in a separate APK -->
+ <option name="test-file-name" value="CtsLibcoreTestRunner.apk" />
+ <!-- this has just the instrumentation which acts as the tests we want to run -->
+ <option name="test-file-name" value="CtsLibcoreOkHttpTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <!-- override AJUR -->
+ <option name="runner" value="com.android.cts.core.runner.CoreTestRunner" />
+ <option name="package" value="android.libcore.cts.okhttp" />
+ <option name="instrumentation-arg" key="core-listener"
+ value="com.android.cts.runner.CtsTestRunListener"/>
+ <option name="instrumentation-arg" key="core-expectations"
+ value="/knownfailures.txt,/brokentests.txt,/icebox.txt,/taggedtests.txt" />
+ <option name="runtime-hint" value="10m"/>
+ <!-- 20x default timeout of 600sec -->
+ <option name="shell-timeout" value="12000000"/>
+ </test>
+</configuration>
diff --git a/tests/tests/media/res/raw/video_176x144_mp4_mpeg4_300kbps_25fps_aac_stereo_128kbps_44100hz.mp4 b/tests/tests/media/res/raw/video_176x144_mp4_mpeg4_300kbps_25fps_aac_stereo_128kbps_44100hz.mp4
index 6b6040f..044d5f8 100644
--- a/tests/tests/media/res/raw/video_176x144_mp4_mpeg4_300kbps_25fps_aac_stereo_128kbps_44100hz.mp4
+++ b/tests/tests/media/res/raw/video_176x144_mp4_mpeg4_300kbps_25fps_aac_stereo_128kbps_44100hz.mp4
Binary files differ
diff --git a/tests/tests/media/src/android/media/cts/AudioTrackSurroundTest.java b/tests/tests/media/src/android/media/cts/AudioTrackSurroundTest.java
index 0bb6230..70d74a0 100644
--- a/tests/tests/media/src/android/media/cts/AudioTrackSurroundTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioTrackSurroundTest.java
@@ -501,39 +501,56 @@
}
}
+ public void testPcmSupport() throws Exception {
+ // There should always be a dummy PCM device available.
+ assertTrue("testPcmSupport: PCM should be supported."
+ + " On ATV device please check HDMI connection.",
+ mInfoPCM16 != null);
+ }
+
public void testPlaySineSweepShorts() throws Exception {
- SamplePlayerShorts player = new SamplePlayerShorts(
- 44100, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_OUT_STEREO,
- R.raw.sinesweepraw);
- player.playAndMeasureRate();
+ if (mInfoPCM16 != null) {
+ SamplePlayerShorts player = new SamplePlayerShorts(
+ 44100, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_OUT_STEREO,
+ R.raw.sinesweepraw);
+ player.playAndMeasureRate();
+ }
}
public void testPlaySineSweepBytes() throws Exception {
- SamplePlayerBytes player = new SamplePlayerBytes(
- 44100, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_OUT_STEREO,
- R.raw.sinesweepraw);
- player.playAndMeasureRate();
+ if (mInfoPCM16 != null) {
+ SamplePlayerBytes player = new SamplePlayerBytes(
+ 44100, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_OUT_STEREO,
+ R.raw.sinesweepraw);
+ player.playAndMeasureRate();
+ }
}
public void testPlaySineSweepBytes48000() throws Exception {
- SamplePlayerBytes player = new SamplePlayerBytes(
- 48000, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_OUT_STEREO,
- R.raw.sinesweepraw);
- player.playAndMeasureRate();
+ if (mInfoPCM16 != null) {
+ SamplePlayerBytes player = new SamplePlayerBytes(
+ 48000, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_OUT_STEREO,
+ R.raw.sinesweepraw);
+ player.playAndMeasureRate();
+ }
}
public void testPlaySineSweepShortsMono() throws Exception {
- SamplePlayerShorts player = new SamplePlayerShorts(44100, AudioFormat.ENCODING_PCM_16BIT,
- AudioFormat.CHANNEL_OUT_MONO,
- R.raw.sinesweepraw);
- player.playAndMeasureRate();
+ if (mInfoPCM16 != null) {
+ SamplePlayerShorts player = new SamplePlayerShorts(44100, AudioFormat.ENCODING_PCM_16BIT,
+ AudioFormat.CHANNEL_OUT_MONO,
+ R.raw.sinesweepraw);
+ player.playAndMeasureRate();
+ }
}
public void testPlaySineSweepBytesMono()
throws Exception {
- SamplePlayerBytes player = new SamplePlayerBytes(44100,
- AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_OUT_MONO, R.raw.sinesweepraw);
- player.playAndMeasureRate();
+ if (mInfoPCM16 != null) {
+ SamplePlayerBytes player = new SamplePlayerBytes(44100,
+ AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_OUT_MONO, R.raw.sinesweepraw);
+ player.playAndMeasureRate();
+ }
}
}
diff --git a/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java b/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java
index 92aed2d..3f4dde0 100644
--- a/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java
+++ b/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java
@@ -55,6 +55,24 @@
getLargerWidthVideoFormat(new VideoFormat(H264_VIDEO_FILE_NAME)));
}
+ public void testH264SurfaceViewVideoDecode() throws Exception {
+ runDecodeAccuracyTest(
+ new SurfaceViewFactory(),
+ new VideoFormat(H264_VIDEO_FILE_NAME));
+ }
+
+ public void testH264SurfaceViewLargerHeightVideoDecode() throws Exception {
+ runDecodeAccuracyTest(
+ new SurfaceViewFactory(),
+ getLargerHeightVideoFormat(new VideoFormat(H264_VIDEO_FILE_NAME)));
+ }
+
+ public void testH264SurfaceViewLargerWidthVideoDecode() throws Exception {
+ runDecodeAccuracyTest(
+ new SurfaceViewFactory(),
+ getLargerWidthVideoFormat(new VideoFormat(H264_VIDEO_FILE_NAME)));
+ }
+
/* <------------- Tests Using VP9 -------------> */
public void testVP9GLViewVideoDecode() throws Exception {
runDecodeAccuracyTest(
@@ -74,6 +92,24 @@
getLargerWidthVideoFormat(new VideoFormat(VP9_VIDEO_FILE_NAME)));
}
+ public void testVP9SurfaceViewVideoDecode() throws Exception {
+ runDecodeAccuracyTest(
+ new SurfaceViewFactory(),
+ new VideoFormat(VP9_VIDEO_FILE_NAME));
+ }
+
+ public void testVP9SurfaceViewLargerHeightVideoDecode() throws Exception {
+ runDecodeAccuracyTest(
+ new SurfaceViewFactory(),
+ getLargerHeightVideoFormat(new VideoFormat(VP9_VIDEO_FILE_NAME)));
+ }
+
+ public void testVP9SurfaceViewLargerWidthVideoDecode() throws Exception {
+ runDecodeAccuracyTest(
+ new SurfaceViewFactory(),
+ getLargerWidthVideoFormat(new VideoFormat(VP9_VIDEO_FILE_NAME)));
+ }
+
private void runDecodeAccuracyTest(VideoViewFactory videoViewFactory, VideoFormat videoFormat) {
checkNotNull(videoViewFactory);
checkNotNull(videoFormat);
@@ -83,15 +119,16 @@
getHelper().generateView(videoView);
}
videoViewFactory.waitForViewIsAvailable();
-
+ // In the case of SurfaceView, VideoViewSnapshot can only capture incoming frames,
+ // so it needs to be created before start decoding.
+ final VideoViewSnapshot videoViewSnapshot = videoViewFactory.getVideoViewSnapshot();
decodeVideo(videoFormat, videoViewFactory);
- validateResult(videoFormat, videoViewFactory);
+ validateResult(videoFormat, videoViewSnapshot);
if (videoView != null) {
getHelper().cleanUpView(videoView);
}
videoViewFactory.release();
- getHelper().unsetOrientation();
}
private void decodeVideo(VideoFormat videoFormat, VideoViewFactory videoViewFactory) {
@@ -103,9 +140,8 @@
assertTrue("Failed to decode the video.", playerResult.isSuccess());
}
- private void validateResult(VideoFormat videoFormat, VideoViewFactory videoViewFactory) {
- final Bitmap result = getHelper().generateBitmapFromVideoViewSnapshot(
- videoViewFactory.getVideoViewSnapshot());
+ private void validateResult(VideoFormat videoFormat, VideoViewSnapshot videoViewSnapshot) {
+ final Bitmap result = getHelper().generateBitmapFromVideoViewSnapshot(videoViewSnapshot);
final Bitmap golden;
final String mime = videoFormat.getMimeType();
if (mime.equals(MimeTypes.VIDEO_H264)) {
diff --git a/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java b/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
index 2d5fc6f..3e3c866f 100644
--- a/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
+++ b/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
@@ -24,6 +24,7 @@
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.SurfaceTexture;
@@ -39,13 +40,18 @@
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.Handler;
+import android.os.HandlerThread;
import android.os.Looper;
import android.os.SystemClock;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
+import android.view.PixelCopy;
+import android.view.PixelCopy.OnPixelCopyFinishedListener;
import android.view.Surface;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
@@ -539,7 +545,9 @@
@TargetApi(16)
class TextureViewFactory extends VideoViewFactory implements TextureView.SurfaceTextureListener {
- private final String TAG = TextureViewFactory.class.getSimpleName();
+ private static final String TAG = TextureViewFactory.class.getSimpleName();
+ private static final String NAME = "TextureView";
+
private final Object syncToken = new Object();
private TextureView textureView;
@@ -559,7 +567,7 @@
@Override
public String getName() {
- return "TextureView";
+ return NAME;
}
@Override
@@ -579,7 +587,7 @@
try {
syncToken.wait(VIEW_AVAILABLE_TIMEOUT_MS);
} catch (InterruptedException exception) {
- Log.e(TAG, "InterruptedException in waitForViewIsAvailable", exception);
+ Log.e(TAG, "Taking too long to attach a TextureView to a window.", exception);
}
}
}
@@ -607,18 +615,96 @@
}
/**
+ * Factory for building a {@link SurfaceView}
+ */
+class SurfaceViewFactory extends VideoViewFactory implements SurfaceHolder.Callback {
+
+ private static final String TAG = SurfaceViewFactory.class.getSimpleName();
+ private static final String NAME = "SurfaceView";
+
+ private final Object syncToken = new Object();
+ private SurfaceViewSnapshot surfaceViewSnapshot;
+ private SurfaceView surfaceView;
+ private SurfaceHolder surfaceHolder;
+
+ public SurfaceViewFactory() {}
+
+ @Override
+ public void release() {
+ if (surfaceViewSnapshot != null) {
+ surfaceViewSnapshot.release();
+ }
+ surfaceView = null;
+ surfaceHolder = null;
+ }
+
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ @Override
+ public View createView(Context context) {
+ Looper.prepare();
+ surfaceView = new SurfaceView(context);
+ surfaceHolder = surfaceView.getHolder();
+ surfaceHolder.addCallback(this);
+ return surfaceView;
+ }
+
+ @Override
+ public void waitForViewIsAvailable() {
+ while (!getSurface().isValid()) {
+ synchronized (syncToken) {
+ try {
+ syncToken.wait(VIEW_AVAILABLE_TIMEOUT_MS);
+ } catch (InterruptedException exception) {
+ Log.e(TAG, "Taking too long to attach a SurfaceView to a window.", exception);
+ }
+ }
+ }
+ }
+
+ @Override
+ public Surface getSurface() {
+ return surfaceHolder.getSurface();
+ }
+
+ @Override
+ public VideoViewSnapshot getVideoViewSnapshot() {
+ surfaceViewSnapshot = new SurfaceViewSnapshot(surfaceView, VIEW_WIDTH, VIEW_HEIGHT);
+ return surfaceViewSnapshot;
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ synchronized (syncToken) {
+ syncToken.notify();
+ }
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {}
+
+}
+
+/**
* Factory for building EGL and GLES that could render to GLSurfaceView.
* {@link GLSurfaceView} {@link EGL10} {@link GLES20}.
*/
@TargetApi(16)
class GLSurfaceViewFactory extends VideoViewFactory {
- private final String TAG = GLSurfaceViewFactory.class.getSimpleName();
+ private static final String TAG = GLSurfaceViewFactory.class.getSimpleName();
+ private static final String NAME = "GLSurfaceView";
+
private final Object surfaceSyncToken = new Object();
- private final Object snapshotSyncToken = new Object();
private GLSurfaceViewThread glSurfaceViewThread;
- private boolean snapshotIsReady = false;
+ private boolean byteBufferIsReady = false;
public GLSurfaceViewFactory() {}
@@ -630,7 +716,7 @@
@Override
public String getName() {
- return "GLSurfaceView";
+ return NAME;
}
@Override
@@ -649,7 +735,7 @@
try {
surfaceSyncToken.wait(VIEW_AVAILABLE_TIMEOUT_MS);
} catch (InterruptedException exception) {
- Log.e(TAG, "InterruptedException in waitForViewIsAvailable", exception);
+ Log.e(TAG, "Taking too long for the surface to become available.", exception);
}
}
}
@@ -662,17 +748,15 @@
@Override
public VideoViewSnapshot getVideoViewSnapshot() {
- while (!snapshotIsReady) {
- synchronized (snapshotSyncToken) {
- try {
- snapshotSyncToken.wait(VIEW_AVAILABLE_TIMEOUT_MS);
- } catch (InterruptedException exception) {
- Log.e(TAG, "InterruptedException in getVideoViewSnapshot", exception);
- }
- }
- }
- return new GLSurfaceViewSnapshot(
- glSurfaceViewThread.getByteBuffer(), VIEW_WIDTH, VIEW_HEIGHT);
+ return new GLSurfaceViewSnapshot(this, VIEW_WIDTH, VIEW_HEIGHT);
+ }
+
+ public boolean byteBufferIsReady() {
+ return byteBufferIsReady;
+ }
+
+ public ByteBuffer getByteBuffer() {
+ return glSurfaceViewThread.getByteBuffer();
}
/* Does all GL operations. */
@@ -749,7 +833,6 @@
synchronized (surfaceSyncToken) {
surfaceSyncToken.notify();
}
-
// Store pixels from surface
byteBuffer = ByteBuffer.allocateDirect(VIEW_WIDTH * VIEW_HEIGHT * 4);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
@@ -761,13 +844,8 @@
checkGlError("before updateTexImage");
surfaceTexture.updateTexImage();
st.getTransformMatrix(textureTransform);
-
drawFrame();
saveFrame();
- snapshotIsReady = true;
- synchronized(snapshotSyncToken) {
- snapshotSyncToken.notify();
- }
}
/* Prepares EGL to use GLES 2.0 context and a surface that supports pbuffer. */
@@ -909,9 +987,11 @@
/* Reads the pixels to a ByteBuffer. */
public void saveFrame() {
+ byteBufferIsReady = false;
byteBuffer.clear();
GLES20.glReadPixels(0, 0, VIEW_WIDTH, VIEW_HEIGHT, GLES20.GL_RGBA,
GLES20.GL_UNSIGNED_BYTE, byteBuffer);
+ byteBufferIsReady = true;
}
public int getTextureId() {
@@ -1034,26 +1114,140 @@
}
/**
+ * Method to get bitmap of a {@link SurfaceView}.
+ */
+class SurfaceViewSnapshot extends VideoViewSnapshot {
+
+ private static final String TAG = SurfaceViewSnapshot.class.getSimpleName();
+ private static final int PIXELCOPY_REQUEST_SLEEP_MS = 30;
+ private static final int PIXELCOPY_REQUEST_MAX_ATTEMPTS = 20;
+ private static final int PIXELCOPY_TIMEOUT_MS = 1000;
+
+ private final Thread copyThread;
+ private Bitmap bitmap;
+ private int copyResult;
+
+ public SurfaceViewSnapshot(final SurfaceView surfaceView, final int width, final int height) {
+ this.copyResult = -1;
+ this.copyThread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ SynchronousPixelCopy copyHelper = new SynchronousPixelCopy();
+ bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+ try {
+ // Wait for SurfaceView to be available.
+ for (int i = 0; i < PIXELCOPY_REQUEST_MAX_ATTEMPTS; i++) {
+ copyResult = copyHelper.request(surfaceView, bitmap);
+ if (copyResult == PixelCopy.SUCCESS) {
+ break;
+ }
+ Thread.sleep(PIXELCOPY_REQUEST_SLEEP_MS);
+ }
+ } catch (InterruptedException ex) {
+ Log.w(TAG, "Pixel Copy is stopped/interrupted before it finishes", ex);
+ }
+ copyHelper.release();
+ }
+ });
+ copyThread.start();
+ }
+
+ @Override
+ public synchronized void run() {}
+
+ @Override
+ public Bitmap getBitmap() {
+ return bitmap;
+ }
+
+ @Override
+ public boolean isBitmapReady() {
+ return copyResult == PixelCopy.SUCCESS;
+ }
+
+ public void release() {
+ if (copyThread.isAlive()) {
+ copyThread.interrupt();
+ }
+ }
+
+ private static class SynchronousPixelCopy implements OnPixelCopyFinishedListener {
+
+ private final Handler handler;
+ private final HandlerThread thread;
+
+ private int status = -1;
+
+ public SynchronousPixelCopy() {
+ this.thread = new HandlerThread("PixelCopyHelper");
+ thread.start();
+ this.handler = new Handler(thread.getLooper());
+ }
+
+ public void release() {
+ thread.quit();
+ }
+
+ public int request(SurfaceView source, Bitmap dest) {
+ synchronized (this) {
+ PixelCopy.request(source, dest, this, handler);
+ return getResultLocked();
+ }
+ }
+
+ private int getResultLocked() {
+ try {
+ this.wait(PIXELCOPY_TIMEOUT_MS);
+ } catch (InterruptedException e) { /* PixelCopy request didn't complete within 1s */ }
+ return status;
+ }
+
+ @Override
+ public void onPixelCopyFinished(int copyResult) {
+ synchronized (this) {
+ status = copyResult;
+ this.notify();
+ }
+ }
+
+ }
+
+}
+
+/**
* Runnable to get a bitmap from a GLSurfaceView on the UI thread via a handler.
* Note, because of how the bitmap is captured in GLSurfaceView,
* this method does not have to be a runnable.
*/
class GLSurfaceViewSnapshot extends VideoViewSnapshot {
- private Bitmap bitmap = null;
- private ByteBuffer byteBuffer;
+ private static final String TAG = GLSurfaceViewSnapshot.class.getSimpleName();
+ private static final int GET_BYTEBUFFER_SLEEP_MS = 30;
+ private static final int GET_BYTEBUFFER_MAX_ATTEMPTS = 20;
+
+ private final GLSurfaceViewFactory glSurfaceViewFactory;
private final int width;
private final int height;
+
+ private Bitmap bitmap = null;
private boolean bitmapIsReady = false;
- public GLSurfaceViewSnapshot(ByteBuffer byteBuffer, int width, int height) {
- this.byteBuffer = DecodeAccuracyTestBase.checkNotNull(byteBuffer);
+ public GLSurfaceViewSnapshot(GLSurfaceViewFactory glSurfaceViewFactory, int width, int height) {
+ this.glSurfaceViewFactory = DecodeAccuracyTestBase.checkNotNull(glSurfaceViewFactory);
this.width = width;
this.height = height;
}
@Override
public synchronized void run() {
+ try {
+ waitForByteBuffer();
+ } catch (InterruptedException exception) {
+ Log.w(TAG, exception.getMessage());
+ Log.w(TAG, "ByteBuffer may contain incorrect pixels.");
+ }
+ // Get ByteBuffer anyway. Let the test fail if ByteBuffer contains incorrect pixels.
+ ByteBuffer byteBuffer = glSurfaceViewFactory.getByteBuffer();
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
byteBuffer.rewind();
bitmap.copyPixelsFromBuffer(byteBuffer);
@@ -1070,6 +1264,17 @@
return bitmapIsReady;
}
+ public void waitForByteBuffer() throws InterruptedException {
+ // Wait for byte buffer to be ready.
+ for (int i = 0; i < GET_BYTEBUFFER_MAX_ATTEMPTS; i++) {
+ if (glSurfaceViewFactory.byteBufferIsReady()) {
+ return;
+ }
+ Thread.sleep(GET_BYTEBUFFER_SLEEP_MS);
+ }
+ throw new InterruptedException("Taking too long to read pixels into a ByteBuffer.");
+ }
+
}
/* Stores information of a video. */
diff --git a/tests/tests/net/src/android/net/cts/DnsTest.java b/tests/tests/net/src/android/net/cts/DnsTest.java
index c6a8962..8575c33 100644
--- a/tests/tests/net/src/android/net/cts/DnsTest.java
+++ b/tests/tests/net/src/android/net/cts/DnsTest.java
@@ -62,8 +62,8 @@
try {
addrs = InetAddress.getAllByName("www.google.com");
} catch (UnknownHostException e) {}
- assertTrue("[RERUN] DNS could not resolve www.gooogle.com. Check internet connection",
- addrs.length != 0);
+ assertTrue("[RERUN] DNS could not resolve www.google.com. Check internet connection",
+ addrs.length != 0);
boolean foundV4 = false, foundV6 = false;
for (InetAddress addr : addrs) {
if (addr instanceof Inet4Address) foundV4 = true;
@@ -71,11 +71,8 @@
if (DBG) Log.e(TAG, "www.google.com gave " + addr.toString());
}
- // assertTrue(foundV4);
- // assertTrue(foundV6);
-
// We should have at least one of the addresses to connect!
- assertTrue(foundV4 || foundV6);
+ assertTrue("www.google.com must have IPv4 and/or IPv6 address", foundV4 || foundV6);
// Skip the rest of the test if the active network for watch is PROXY.
// TODO: Check NetworkInfo type in addition to type name once ag/601257 is merged.
@@ -85,14 +82,17 @@
return;
}
+ // Clear test state so we don't get confused with the previous results.
+ addrs = new InetAddress[0];
+ foundV4 = foundV6 = false;
try {
addrs = InetAddress.getAllByName("ipv6.google.com");
} catch (UnknownHostException e) {}
- assertTrue(addrs.length != 0);
- foundV6 = false;
+ assertTrue("[RERUN] DNS could not resolve ipv6.google.com, check the network supports IPv6",
+ addrs.length != 0);
for (InetAddress addr : addrs) {
assertFalse ("[RERUN] ipv6.google.com returned IPv4 address: " + addr.getHostAddress() +
- ", check your network's DNS connection", addr instanceof Inet4Address);
+ ", check your network's DNS server", addr instanceof Inet4Address);
foundV6 |= (addr instanceof Inet6Address);
if (DBG) Log.e(TAG, "ipv6.google.com gave " + addr.toString());
}
diff --git a/tests/tests/security/Android.mk b/tests/tests/security/Android.mk
index 6d728da..1f7b601 100644
--- a/tests/tests/security/Android.mk
+++ b/tests/tests/security/Android.mk
@@ -59,7 +59,7 @@
LOCAL_PACKAGE_NAME := CtsSecurityTestCases
-LOCAL_SDK_VERSION := current
+#LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
LOCAL_COMPATIBILITY_SUITE := cts
diff --git a/tests/tests/security/src/android/security/cts/EncryptionTest.java b/tests/tests/security/src/android/security/cts/EncryptionTest.java
index b2e3991..1d37ec6 100644
--- a/tests/tests/security/src/android/security/cts/EncryptionTest.java
+++ b/tests/tests/security/src/android/security/cts/EncryptionTest.java
@@ -21,6 +21,7 @@
import android.app.ActivityManager;
import android.content.Context;
+import android.os.SystemProperties;
import android.util.Log;
import java.io.BufferedReader;
import java.io.FileReader;
@@ -33,6 +34,8 @@
System.loadLibrary("ctssecurity_jni");
}
+ private static final int min_api_level = 23;
+
private static final String TAG = "EncryptionTest";
private static final String crypto = "/proc/crypto";
@@ -73,7 +76,23 @@
return activityManager.isLowRamDevice();
}
+ private boolean isRequired() {
+ int first_api_level =
+ SystemProperties.getInt("ro.product.first_api_level", 0);
+
+ // Optional before min_api_level or if the device has low RAM
+ if (first_api_level > 0 && first_api_level < min_api_level) {
+ return false;
+ } else {
+ return !hasLowRAM();
+ }
+ }
+
public void testConfig() throws Exception {
+ if (!isRequired()) {
+ return;
+ }
+
if (cpuHasAes()) {
// If CPU has AES CE, it must be enabled in kernel
assertTrue(crypto + " is missing xts-aes-ce or xts-aes-aesni",
@@ -93,13 +112,7 @@
}
public void testEncryption() throws Exception {
- if (deviceIsEncrypted()) {
- return;
- }
-
- // Optional for low RAM devices
- if (hasLowRAM()) {
- Log.i(TAG, "hasLowRAM: true");
+ if (!isRequired() || deviceIsEncrypted()) {
return;
}