Merge "CtsMediaMiscTestCases: Remove unused files from res/raw"
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/bokeh/CameraBokehActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/bokeh/CameraBokehActivity.java
index 336a923..3f27a2d 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/bokeh/CameraBokehActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/bokeh/CameraBokehActivity.java
@@ -592,7 +592,11 @@
shutdownCamera();
mCurrentCameraIndex = index;
- mCameraId = mCameraIdList[index];
+
+ Set<String> cameraIdSet = mTestCases.keySet();
+ List<String> stringsList = new ArrayList<>(cameraIdSet);
+
+ mCameraId = stringsList.get(index);
try {
mCameraCharacteristics = mCameraManager.getCameraCharacteristics(mCameraId);
mCameraDevice = mBlockingCameraManager.openCamera(mCameraId,
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/StorageDeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/StorageDeviceInfo.java
index a951d41..8f1d450 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/StorageDeviceInfo.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/StorageDeviceInfo.java
@@ -16,6 +16,7 @@
package com.android.compatibility.common.deviceinfo;
import android.os.Environment;
+import android.os.SystemProperties;
import android.util.Log;
import com.android.compatibility.common.util.DeviceInfoStore;
@@ -57,6 +58,9 @@
store.addResult("num_emulated", emulated);
store.addListResult("raw_partition", scanPartitions());
+
+ boolean hasCompress = SystemProperties.getInt("vold.has_compress", 0) != 0 ? true : false;
+ store.addResult("compression", hasCompress);
}
private List<String> scanPartitions() {
diff --git a/tests/framework/base/biometrics/src/android/server/biometrics/BiometricSimpleTests.java b/tests/framework/base/biometrics/src/android/server/biometrics/BiometricSimpleTests.java
index 716db8d..d07c3ce 100644
--- a/tests/framework/base/biometrics/src/android/server/biometrics/BiometricSimpleTests.java
+++ b/tests/framework/base/biometrics/src/android/server/biometrics/BiometricSimpleTests.java
@@ -174,15 +174,31 @@
// Third case above. Since the deprecated API is intended to allow credential in addition
// to biometrics, we should be receiving BIOMETRIC_ERROR_NO_BIOMETRICS.
final boolean noSensors = mSensorProperties.isEmpty();
+ int expectedError;
+ if (noSensors) {
+ expectedError = BiometricPrompt.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL;
+ } else if (hasOnlyConvenienceSensors()) {
+ expectedError = BiometricPrompt.BIOMETRIC_ERROR_HW_NOT_PRESENT;
+ } else {
+ expectedError = BiometricPrompt.BIOMETRIC_ERROR_NO_BIOMETRICS;
+ }
callback = mock(BiometricPrompt.AuthenticationCallback.class);
showDeviceCredentialAllowedBiometricPrompt(callback, new CancellationSignal(),
false /* shouldShow */);
verify(callback).onAuthenticationError(
- eq(noSensors ? BiometricPrompt.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL
- : BiometricPrompt.BIOMETRIC_ERROR_NO_BIOMETRICS),
+ eq(expectedError),
any());
}
+ private boolean hasOnlyConvenienceSensors() {
+ for (SensorProperties sensor : mSensorProperties) {
+ if (sensor.getSensorStrength() != SensorProperties.STRENGTH_CONVENIENCE) {
+ return false;
+ }
+ }
+ return true;
+ }
+
/**
* When device credential is enrolled, check the behavior for
* 1) BiometricManager#canAuthenticate(DEVICE_CREDENTIAL)
diff --git a/tests/input/OWNERS b/tests/input/OWNERS
index 8ed76d2..824b5ac 100644
--- a/tests/input/OWNERS
+++ b/tests/input/OWNERS
@@ -1,5 +1,2 @@
-# Bug component: 136048
+include platform/frameworks/base:/INPUT_OWNERS
arthurhung@google.com
-lzye@google.com
-michaelwr@google.com
-svv@google.com
diff --git a/tests/media/jni/NativeCodecDecoderTest.cpp b/tests/media/jni/NativeCodecDecoderTest.cpp
index d68a040..2894009 100644
--- a/tests/media/jni/NativeCodecDecoderTest.cpp
+++ b/tests/media/jni/NativeCodecDecoderTest.cpp
@@ -43,7 +43,7 @@
void setUpAudioReference(const char* refFile);
void deleteReference();
- bool setUpExtractor(const char* srcFile);
+ bool setUpExtractor(const char* srcFile, int colorFormat);
void deleteExtractor();
bool configureCodec(AMediaFormat* format, bool isAsync, bool signalEOSWithLastFrame,
bool isEncoder) override;
@@ -59,10 +59,10 @@
~CodecDecoderTest();
bool testSimpleDecode(const char* decoder, const char* testFile, const char* refFile,
- float rmsError, uLong checksum);
- bool testFlush(const char* decoder, const char* testFile);
- bool testOnlyEos(const char* decoder, const char* testFile);
- bool testSimpleDecodeQueueCSD(const char* decoder, const char* testFile);
+ int colorFormat, float rmsError, uLong checksum);
+ bool testFlush(const char* decoder, const char* testFile, int colorFormat);
+ bool testOnlyEos(const char* decoder, const char* testFile, int colorFormat);
+ bool testSimpleDecodeQueueCSD(const char* decoder, const char* testFile, int colorFormat);
};
CodecDecoderTest::CodecDecoderTest(const char* mime, ANativeWindow* window)
@@ -102,7 +102,7 @@
mRefLength = 0;
}
-bool CodecDecoderTest::setUpExtractor(const char* srcFile) {
+bool CodecDecoderTest::setUpExtractor(const char* srcFile, int colorFormat) {
FILE* fp = fopen(srcFile, "rbe");
struct stat buf {};
if (fp && !fstat(fileno(fp), &buf)) {
@@ -113,6 +113,7 @@
if (res != AMEDIA_OK) {
deleteExtractor();
} else {
+ mBytesPerSample = (colorFormat == COLOR_FormatYUVP010) ? 2 : 1;
for (size_t trackID = 0; trackID < AMediaExtractor_getTrackCount(mExtractor);
trackID++) {
AMediaFormat* currFormat = AMediaExtractor_getTrackFormat(mExtractor, trackID);
@@ -122,7 +123,7 @@
AMediaExtractor_selectTrack(mExtractor, trackID);
if (!mIsAudio) {
AMediaFormat_setInt32(currFormat, AMEDIAFORMAT_KEY_COLOR_FORMAT,
- COLOR_FormatYUV420Flexible);
+ colorFormat);
}
mInpDecFormat = currFormat;
// TODO: determine this from the extractor format when it becomes exposed.
@@ -238,7 +239,7 @@
AMediaFormat_getInt32(format, "width", &width);
AMediaFormat_getInt32(format, "height", &height);
AMediaFormat_getInt32(format, "stride", &stride);
- mOutputBuff->updateChecksum(buf, info, width, height, stride);
+ mOutputBuff->updateChecksum(buf, info, width, height, stride, mBytesPerSample);
}
}
mOutputBuff->saveOutPTS(info->presentationTimeUs);
@@ -299,9 +300,10 @@
}
bool CodecDecoderTest::testSimpleDecode(const char* decoder, const char* testFile,
- const char* refFile, float rmsError, uLong checksum) {
+ const char* refFile, int colorFormat, float rmsError,
+ uLong checksum) {
bool isPass = true;
- if (!setUpExtractor(testFile)) return false;
+ if (!setUpExtractor(testFile, colorFormat)) return false;
mSaveToMem = (mWindow == nullptr);
auto ref = &mRefBuff;
auto test = &mTestBuff;
@@ -399,9 +401,9 @@
return isPass;
}
-bool CodecDecoderTest::testFlush(const char* decoder, const char* testFile) {
+bool CodecDecoderTest::testFlush(const char* decoder, const char* testFile, int colorFormat) {
bool isPass = true;
- if (!setUpExtractor(testFile)) return false;
+ if (!setUpExtractor(testFile, colorFormat)) return false;
mCsdBuffers.clear();
for (int i = 0;; i++) {
char csdName[16];
@@ -526,9 +528,9 @@
return isPass;
}
-bool CodecDecoderTest::testOnlyEos(const char* decoder, const char* testFile) {
+bool CodecDecoderTest::testOnlyEos(const char* decoder, const char* testFile, int colorFormat) {
bool isPass = true;
- if (!setUpExtractor(testFile)) return false;
+ if (!setUpExtractor(testFile, colorFormat)) return false;
mSaveToMem = (mWindow == nullptr);
auto ref = &mRefBuff;
auto test = &mTestBuff;
@@ -567,9 +569,10 @@
return isPass;
}
-bool CodecDecoderTest::testSimpleDecodeQueueCSD(const char* decoder, const char* testFile) {
+bool CodecDecoderTest::testSimpleDecodeQueueCSD(const char* decoder, const char* testFile,
+ int colorFormat) {
bool isPass = true;
- if (!setUpExtractor(testFile)) return false;
+ if (!setUpExtractor(testFile, colorFormat)) return false;
std::vector<AMediaFormat*> formats;
formats.push_back(mInpDecFormat);
mInpDecDupFormat = AMediaFormat_new();
@@ -663,7 +666,7 @@
static jboolean nativeTestSimpleDecode(JNIEnv* env, jobject, jstring jDecoder, jobject surface,
jstring jMime, jstring jtestFile, jstring jrefFile,
- jfloat jrmsError, jlong jChecksum) {
+ jint jColorFormat, jfloat jrmsError, jlong jChecksum) {
const char* cDecoder = env->GetStringUTFChars(jDecoder, nullptr);
const char* cMime = env->GetStringUTFChars(jMime, nullptr);
const char* cTestFile = env->GetStringUTFChars(jtestFile, nullptr);
@@ -672,8 +675,8 @@
uLong cChecksum = jChecksum;
ANativeWindow* window = surface ? ANativeWindow_fromSurface(env, surface) : nullptr;
auto* codecDecoderTest = new CodecDecoderTest(cMime, window);
- bool isPass =
- codecDecoderTest->testSimpleDecode(cDecoder, cTestFile, cRefFile, cRmsError, cChecksum);
+ bool isPass = codecDecoderTest->testSimpleDecode(cDecoder, cTestFile, cRefFile, jColorFormat,
+ cRmsError, cChecksum);
delete codecDecoderTest;
if (window) {
ANativeWindow_release(window);
@@ -687,12 +690,12 @@
}
static jboolean nativeTestOnlyEos(JNIEnv* env, jobject, jstring jDecoder, jstring jMime,
- jstring jtestFile) {
+ jstring jtestFile, jint jColorFormat) {
const char* cDecoder = env->GetStringUTFChars(jDecoder, nullptr);
const char* cMime = env->GetStringUTFChars(jMime, nullptr);
const char* cTestFile = env->GetStringUTFChars(jtestFile, nullptr);
auto* codecDecoderTest = new CodecDecoderTest(cMime, nullptr);
- bool isPass = codecDecoderTest->testOnlyEos(cDecoder, cTestFile);
+ bool isPass = codecDecoderTest->testOnlyEos(cDecoder, cTestFile, jColorFormat);
delete codecDecoderTest;
env->ReleaseStringUTFChars(jDecoder, cDecoder);
env->ReleaseStringUTFChars(jMime, cMime);
@@ -701,13 +704,13 @@
}
static jboolean nativeTestFlush(JNIEnv* env, jobject, jstring jDecoder, jobject surface,
- jstring jMime, jstring jtestFile) {
+ jstring jMime, jstring jtestFile, jint jColorFormat) {
const char* cDecoder = env->GetStringUTFChars(jDecoder, nullptr);
const char* cMime = env->GetStringUTFChars(jMime, nullptr);
const char* cTestFile = env->GetStringUTFChars(jtestFile, nullptr);
ANativeWindow* window = surface ? ANativeWindow_fromSurface(env, surface) : nullptr;
auto* codecDecoderTest = new CodecDecoderTest(cMime, window);
- bool isPass = codecDecoderTest->testFlush(cDecoder, cTestFile);
+ bool isPass = codecDecoderTest->testFlush(cDecoder, cTestFile, jColorFormat);
delete codecDecoderTest;
if (window) {
ANativeWindow_release(window);
@@ -720,12 +723,13 @@
}
static jboolean nativeTestSimpleDecodeQueueCSD(JNIEnv* env, jobject, jstring jDecoder,
- jstring jMime, jstring jtestFile) {
+ jstring jMime, jstring jtestFile,
+ jint jColorFormat) {
const char* cDecoder = env->GetStringUTFChars(jDecoder, nullptr);
const char* cMime = env->GetStringUTFChars(jMime, nullptr);
const char* cTestFile = env->GetStringUTFChars(jtestFile, nullptr);
auto codecDecoderTest = new CodecDecoderTest(cMime, nullptr);
- bool isPass = codecDecoderTest->testSimpleDecodeQueueCSD(cDecoder, cTestFile);
+ bool isPass = codecDecoderTest->testSimpleDecodeQueueCSD(cDecoder, cTestFile, jColorFormat);
delete codecDecoderTest;
env->ReleaseStringUTFChars(jDecoder, cDecoder);
env->ReleaseStringUTFChars(jMime, cMime);
@@ -737,15 +741,15 @@
const JNINativeMethod methodTable[] = {
{"nativeTestSimpleDecode",
"(Ljava/lang/String;Landroid/view/Surface;Ljava/lang/String;Ljava/lang/String;Ljava/"
- "lang/String;FJ)Z",
+ "lang/String;IFJ)Z",
(void*)nativeTestSimpleDecode},
- {"nativeTestOnlyEos", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z",
+ {"nativeTestOnlyEos", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Z",
(void*)nativeTestOnlyEos},
{"nativeTestFlush",
- "(Ljava/lang/String;Landroid/view/Surface;Ljava/lang/String;Ljava/lang/String;)Z",
+ "(Ljava/lang/String;Landroid/view/Surface;Ljava/lang/String;Ljava/lang/String;I)Z",
(void*)nativeTestFlush},
{"nativeTestSimpleDecodeQueueCSD",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z",
+ "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Z",
(void*)nativeTestSimpleDecodeQueueCSD},
};
jclass c = env->FindClass("android/mediav2/cts/CodecDecoderTest");
@@ -756,10 +760,10 @@
const JNINativeMethod methodTable[] = {
{"nativeTestSimpleDecode",
"(Ljava/lang/String;Landroid/view/Surface;Ljava/lang/String;Ljava/lang/String;Ljava/"
- "lang/String;FJ)Z",
+ "lang/String;IFJ)Z",
(void*)nativeTestSimpleDecode},
{"nativeTestFlush",
- "(Ljava/lang/String;Landroid/view/Surface;Ljava/lang/String;Ljava/lang/String;)Z",
+ "(Ljava/lang/String;Landroid/view/Surface;Ljava/lang/String;Ljava/lang/String;I)Z",
(void*)nativeTestFlush},
};
jclass c = env->FindClass("android/mediav2/cts/CodecDecoderSurfaceTest");
diff --git a/tests/media/jni/NativeCodecTestBase.cpp b/tests/media/jni/NativeCodecTestBase.cpp
index 1516185..391ef1e 100644
--- a/tests/media/jni/NativeCodecTestBase.cpp
+++ b/tests/media/jni/NativeCodecTestBase.cpp
@@ -207,8 +207,8 @@
return result;
}
-void OutputManager::updateChecksum(
- uint8_t* buf, AMediaCodecBufferInfo* info, int width, int height, int stride) {
+void OutputManager::updateChecksum(uint8_t* buf, AMediaCodecBufferInfo* info, int width, int height,
+ int stride, int bytesPerSample) {
uint8_t flattenInfo[16];
int pos = 0;
if (width <= 0 || height <= 0 || stride <= 0) {
@@ -218,15 +218,15 @@
info->flags & ~AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM);
flattenField<int64_t>(flattenInfo, &pos, info->presentationTimeUs);
crc32value = crc32(crc32value, flattenInfo, pos);
- if (width > 0 && height > 0 && stride > 0) {
+ if (width > 0 && height > 0 && stride > 0 && bytesPerSample > 0) {
// Only checksum Y plane
- std::vector<uint8_t> tmp(width * height, 0u);
+ std::vector<uint8_t> tmp(width * height * bytesPerSample, 0u);
size_t offset = 0;
for (int i = 0; i < height; ++i) {
- memcpy(tmp.data() + (i * width), buf + offset, width);
+ memcpy(tmp.data() + (i * width * bytesPerSample), buf + offset, width * bytesPerSample);
offset += stride;
}
- crc32value = crc32(crc32value, tmp.data(), width * height);
+ crc32value = crc32(crc32value, tmp.data(), width * height * bytesPerSample);
} else {
crc32value = crc32(crc32value, buf, info->size);
}
@@ -342,6 +342,7 @@
mSaveToMem = false;
mOutputBuff = nullptr;
mCodec = nullptr;
+ mBytesPerSample = mIsAudio ? 2 : 1;
}
CodecTestBase::~CodecTestBase() {
diff --git a/tests/media/jni/NativeCodecTestBase.h b/tests/media/jni/NativeCodecTestBase.h
index fca570b..d8256a8 100644
--- a/tests/media/jni/NativeCodecTestBase.h
+++ b/tests/media/jni/NativeCodecTestBase.h
@@ -106,10 +106,11 @@
memory.insert(memory.end(), buf, buf + info->size);
}
void updateChecksum(uint8_t* buf, AMediaCodecBufferInfo* info) {
- updateChecksum(buf, info, 0, 0, 0);
+ updateChecksum(buf, info, 0, 0, 0, 0);
}
- void updateChecksum(
- uint8_t* buf, AMediaCodecBufferInfo* info, int width, int height, int stride);
+
+ void updateChecksum(uint8_t* buf, AMediaCodecBufferInfo* info, int width, int height,
+ int stride, int bytesPerSample);
uLong getChecksum() { return crc32value; }
void reset() {
inpPtsArray.clear();
@@ -136,6 +137,7 @@
int64_t mPrevOutputPts;
bool mSignalledOutFormatChanged;
AMediaFormat* mOutFormat;
+ int mBytesPerSample;
bool mSaveToMem;
OutputManager* mOutputBuff;
diff --git a/tests/media/jni/NativeMediaCommon.h b/tests/media/jni/NativeMediaCommon.h
index e8f83f6..ca969e4 100644
--- a/tests/media/jni/NativeMediaCommon.h
+++ b/tests/media/jni/NativeMediaCommon.h
@@ -56,6 +56,7 @@
constexpr int COLOR_FormatYUV420SemiPlanar = 21;
constexpr int COLOR_FormatYUV420Flexible = 0x7F420888;
constexpr int COLOR_FormatSurface = 0x7f000789;
+constexpr int COLOR_FormatYUVP010 = 54;
// constants not defined in NDK
extern const char* TBD_AMEDIACODEC_PARAMETER_KEY_REQUEST_SYNC_FRAME;
diff --git a/tests/media/src/android/mediav2/cts/CodecDecoderSurfaceTest.java b/tests/media/src/android/mediav2/cts/CodecDecoderSurfaceTest.java
index 0dc1e95..b0da46f 100644
--- a/tests/media/src/android/mediav2/cts/CodecDecoderSurfaceTest.java
+++ b/tests/media/src/android/mediav2/cts/CodecDecoderSurfaceTest.java
@@ -443,7 +443,7 @@
}
private native boolean nativeTestSimpleDecode(String decoder, Surface surface, String mime,
- String testFile, String refFile, float rmsError, long checksum);
+ String testFile, String refFile, int colorFormat, float rmsError, long checksum);
@LargeTest
@Test(timeout = PER_TEST_TIMEOUT_LARGE_TEST_MS)
@@ -452,11 +452,12 @@
mExtractor.release();
mActivity.setScreenParams(getWidth(format), getHeight(format), false);
assertTrue(nativeTestSimpleDecode(mCodecName, mSurface, mMime, mInpPrefix + mTestFile,
- mInpPrefix + mReconfigFile, -1.0f, 0L));
+ mInpPrefix + mReconfigFile, format.getInteger(MediaFormat.KEY_COLOR_FORMAT), -1.0f,
+ 0L));
}
private native boolean nativeTestFlush(String decoder, Surface surface, String mime,
- String testFile);
+ String testFile, int colorFormat);
@LargeTest
@Test(timeout = PER_TEST_TIMEOUT_LARGE_TEST_MS)
@@ -464,6 +465,7 @@
MediaFormat format = setUpSource(mTestFile);
mExtractor.release();
mActivity.setScreenParams(getWidth(format), getHeight(format), true);
- assertTrue(nativeTestFlush(mCodecName, mSurface, mMime, mInpPrefix + mTestFile));
+ assertTrue(nativeTestFlush(mCodecName, mSurface, mMime, mInpPrefix + mTestFile,
+ format.getInteger(MediaFormat.KEY_COLOR_FORMAT)));
}
}
diff --git a/tests/media/src/android/mediav2/cts/CodecDecoderTest.java b/tests/media/src/android/mediav2/cts/CodecDecoderTest.java
index ff5ca6d..5cc2861 100644
--- a/tests/media/src/android/mediav2/cts/CodecDecoderTest.java
+++ b/tests/media/src/android/mediav2/cts/CodecDecoderTest.java
@@ -190,7 +190,7 @@
}
private native boolean nativeTestSimpleDecode(String decoder, Surface surface, String mime,
- String testFile, String refFile, float rmsError, long checksum);
+ String testFile, String refFile, int colorFormat, float rmsError, long checksum);
static void verify(OutputManager outBuff, String refFile, float rmsError, int audioFormat,
long refCRC) throws IOException {
@@ -328,15 +328,17 @@
}
}
mCodec.release();
+ mExtractor.release();
+ int colorFormat = mIsAudio ? 0 : format.getInteger(MediaFormat.KEY_COLOR_FORMAT);
+ assertTrue(nativeTestSimpleDecode(mCodecName, null, mMime, mInpPrefix + mTestFile,
+ mInpPrefix + mRefFile, colorFormat, mRmsError, ref.getCheckSumBuffer()));
if (mSaveToMem) {
int audioEncoding = mIsAudio ? format.getInteger(MediaFormat.KEY_PCM_ENCODING,
AudioFormat.ENCODING_PCM_16BIT) : AudioFormat.ENCODING_INVALID;
+ Assume.assumeFalse("skip checksum due to tone mapping", mSkipChecksumVerification);
verify(mOutputBuff, mRefFile, mRmsError, audioEncoding, mRefCRC);
}
- assertTrue(nativeTestSimpleDecode(mCodecName, null, mMime, mInpPrefix + mTestFile,
- mInpPrefix + mRefFile, mRmsError, ref.getCheckSumBuffer()));
}
- mExtractor.release();
}
/**
@@ -453,15 +455,19 @@
}
private native boolean nativeTestFlush(String decoder, Surface surface, String mime,
- String testFile);
+ String testFile, int colorFormat);
@Ignore("TODO(b/147576107)")
@LargeTest
@Test(timeout = PER_TEST_TIMEOUT_LARGE_TEST_MS)
- public void testFlushNative() {
- {
- assertTrue(nativeTestFlush(mCodecName, null, mMime, mInpPrefix + mTestFile));
+ public void testFlushNative() throws IOException {
+ int colorFormat = 0;
+ if (!mIsAudio) {
+ MediaFormat format = setUpSource(mTestFile);
+ mExtractor.release();
+ colorFormat = format.getInteger(MediaFormat.KEY_COLOR_FORMAT);
}
+ assertTrue(nativeTestFlush(mCodecName, null, mMime, mInpPrefix + mTestFile, colorFormat));
}
/**
@@ -677,14 +683,19 @@
mExtractor.release();
}
- private native boolean nativeTestOnlyEos(String decoder, String mime, String testFile);
+ private native boolean nativeTestOnlyEos(String decoder, String mime, String testFile,
+ int colorFormat);
@SmallTest
@Test
- public void testOnlyEosNative() {
- {
- assertTrue(nativeTestOnlyEos(mCodecName, mMime, mInpPrefix + mTestFile));
+ public void testOnlyEosNative() throws IOException {
+ int colorFormat = 0;
+ if (!mIsAudio) {
+ MediaFormat format = setUpSource(mTestFile);
+ mExtractor.release();
+ colorFormat = format.getInteger(MediaFormat.KEY_COLOR_FORMAT);
}
+ assertTrue(nativeTestOnlyEos(mCodecName, mMime, mInpPrefix + mTestFile, colorFormat));
}
/**
@@ -778,7 +789,7 @@
}
private native boolean nativeTestSimpleDecodeQueueCSD(String decoder, String mime,
- String testFile);
+ String testFile, int colorFormat);
@LargeTest
@Test(timeout = PER_TEST_TIMEOUT_LARGE_TEST_MS)
@@ -788,10 +799,10 @@
mExtractor.release();
return;
}
- {
- assertTrue(nativeTestSimpleDecodeQueueCSD(mCodecName, mMime, mInpPrefix + mTestFile));
- }
mExtractor.release();
+ int colorFormat = mIsAudio ? 0 : format.getInteger(MediaFormat.KEY_COLOR_FORMAT);
+ assertTrue(nativeTestSimpleDecodeQueueCSD(mCodecName, mMime, mInpPrefix + mTestFile,
+ colorFormat));
}
/**
diff --git a/tests/media/src/android/mediav2/cts/CodecDecoderValidationTest.java b/tests/media/src/android/mediav2/cts/CodecDecoderValidationTest.java
index 1938b8f..9729cc6 100644
--- a/tests/media/src/android/mediav2/cts/CodecDecoderValidationTest.java
+++ b/tests/media/src/android/mediav2/cts/CodecDecoderValidationTest.java
@@ -23,6 +23,7 @@
import androidx.test.filters.LargeTest;
+import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -639,6 +640,7 @@
assertEquals("width mismatch", mWidth, getWidth(mOutFormat));
assertEquals("height mismatch", mHeight, getHeight(mOutFormat));
}
+ Assume.assumeFalse("skip checksum due to tonemapping", mSkipChecksumVerification);
CodecDecoderTest.verify(ref, mRefFile, mRmsError, audioEncoding, mRefCRC);
}
}
diff --git a/tests/media/src/android/mediav2/cts/CodecTestBase.java b/tests/media/src/android/mediav2/cts/CodecTestBase.java
index d07a1df..fd68507 100644
--- a/tests/media/src/android/mediav2/cts/CodecTestBase.java
+++ b/tests/media/src/android/mediav2/cts/CodecTestBase.java
@@ -66,6 +66,7 @@
import static android.media.MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface;
import static android.media.MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Flexible;
+import static android.media.MediaCodecInfo.CodecCapabilities.COLOR_FormatYUVP010;
import static android.media.MediaCodecInfo.CodecProfileLevel.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -293,36 +294,37 @@
}
void checksum(ByteBuffer buf, int size) {
- checksum(buf, size, 0, 0, 0);
+ checksum(buf, size, 0, 0, 0, 0);
}
- void checksum(ByteBuffer buf, int size, int width, int height, int stride) {
+ void checksum(ByteBuffer buf, int size, int width, int height, int stride, int bytesPerSample) {
int cap = buf.capacity();
assertTrue("checksum() params are invalid: size = " + size + " cap = " + cap,
size > 0 && size <= cap);
if (buf.hasArray()) {
- if (width > 0 && height > 0 && stride > 0) {
+ if (width > 0 && height > 0 && stride > 0 && bytesPerSample > 0) {
int offset = buf.position() + buf.arrayOffset();
- byte[] bb = new byte[width * height];
+ byte[] bb = new byte[width * height * bytesPerSample];
for (int i = 0; i < height; ++i) {
- System.arraycopy(buf.array(), offset, bb, i * width, width);
+ System.arraycopy(buf.array(), offset, bb, i * width * bytesPerSample,
+ width * bytesPerSample);
offset += stride;
}
- mCrc32UsingBuffer.update(bb, 0, width * height);
+ mCrc32UsingBuffer.update(bb, 0, width * height * bytesPerSample);
} else {
mCrc32UsingBuffer.update(buf.array(), buf.position() + buf.arrayOffset(), size);
}
- } else if (width > 0 && height > 0 && stride > 0) {
+ } else if (width > 0 && height > 0 && stride > 0 && bytesPerSample > 0) {
// Checksum only the Y plane
int pos = buf.position();
int offset = pos;
- byte[] bb = new byte[width * height];
+ byte[] bb = new byte[width * height * bytesPerSample];
for (int i = 0; i < height; ++i) {
buf.position(offset);
- buf.get(bb, i * width, width);
+ buf.get(bb, i * width * bytesPerSample, width * bytesPerSample);
offset += stride;
}
- mCrc32UsingBuffer.update(bb, 0, width * height);
+ mCrc32UsingBuffer.update(bb, 0, width * height * bytesPerSample);
buf.position(pos);
} else {
int pos = buf.position();
@@ -340,7 +342,9 @@
void checksum(Image image) {
int format = image.getFormat();
- assertEquals("unexpected image format", ImageFormat.YUV_420_888, format);
+ assertTrue("unexpected image format",
+ format == ImageFormat.YUV_420_888 || format == ImageFormat.YCBCR_P010);
+ int bytesPerSample = (ImageFormat.getBitsPerPixel(format) * 2) / (8 * 3); // YUV420
Rect cropRect = image.getCropRect();
int imageWidth = cropRect.width();
@@ -356,6 +360,7 @@
rowStride = planes[i].getRowStride();
pixelStride = planes[i].getPixelStride();
if (i == 0) {
+ assertEquals(bytesPerSample, pixelStride);
width = imageWidth;
height = imageHeight;
left = imageLeft;
@@ -368,30 +373,35 @@
}
int cropOffset = (left * pixelStride) + top * rowStride;
// local contiguous pixel buffer
- byte[] bb = new byte[width * height];
+ byte[] bb = new byte[width * height * bytesPerSample];
+
if (buf.hasArray()) {
byte[] b = buf.array();
int offs = buf.arrayOffset() + cropOffset;
- if (pixelStride == 1) {
+ if (pixelStride == bytesPerSample) {
for (y = 0; y < height; ++y) {
- System.arraycopy(b, offs + y * rowStride, bb, y * width, width);
+ System.arraycopy(b, offs + y * rowStride, bb, y * width * bytesPerSample,
+ width * bytesPerSample);
}
} else {
// do it pixel-by-pixel
for (y = 0; y < height; ++y) {
int lineOffset = offs + y * rowStride;
for (x = 0; x < width; ++x) {
- bb[y * width + x] = b[lineOffset + x * pixelStride];
+ for (int bytePos = 0; bytePos < bytesPerSample; ++bytePos) {
+ bb[y * width * bytesPerSample + x * bytesPerSample + bytePos] =
+ b[lineOffset + x * pixelStride + bytePos];
+ }
}
}
}
} else { // almost always ends up here due to direct buffers
int base = buf.position();
int pos = base + cropOffset;
- if (pixelStride == 1) {
+ if (pixelStride == bytesPerSample) {
for (y = 0; y < height; ++y) {
buf.position(pos + y * rowStride);
- buf.get(bb, y * width, width);
+ buf.get(bb, y * width * bytesPerSample, width * bytesPerSample);
}
} else {
// local line buffer
@@ -399,16 +409,20 @@
// do it pixel-by-pixel
for (y = 0; y < height; ++y) {
buf.position(pos + y * rowStride);
- // we're only guaranteed to have pixelStride * (width - 1) + 1 bytes
- buf.get(lb, 0, pixelStride * (width - 1) + 1);
+ // we're only guaranteed to have pixelStride * (width - 1) +
+ // bytesPerSample bytes
+ buf.get(lb, 0, pixelStride * (width - 1) + bytesPerSample);
for (x = 0; x < width; ++x) {
- bb[y * width + x] = lb[x * pixelStride];
+ for (int bytePos = 0; bytePos < bytesPerSample; ++bytePos) {
+ bb[y * width * bytesPerSample + x * bytesPerSample + bytePos] =
+ lb[x * pixelStride + bytePos];
+ }
}
}
}
buf.position(base);
}
- mCrc32UsingImage.update(bb, 0, width * height);
+ mCrc32UsingImage.update(bb, 0, width * height * bytesPerSample);
}
}
@@ -683,6 +697,35 @@
return isSupported;
}
+ static boolean doesAnyFormatHaveHBDProfile(String mime, ArrayList<MediaFormat> formats) {
+ // check for HLG profiles
+ for (MediaFormat format : formats) {
+ assertEquals(mime, format.getString(MediaFormat.KEY_MIME));
+ switch (mime) {
+ case MediaFormat.MIMETYPE_VIDEO_VP9: {
+ int profile = format.getInteger(MediaFormat.KEY_PROFILE, VP9Profile0);
+ if (profile == VP9Profile2 || profile == VP9Profile3) {
+ return true;
+ }
+ }
+ case MediaFormat.MIMETYPE_VIDEO_HEVC: {
+ int profile = format.getInteger(MediaFormat.KEY_PROFILE, HEVCProfileMain);
+ if (profile == HEVCProfileMain10) {
+ return true;
+ }
+ }
+ case MediaFormat.MIMETYPE_VIDEO_AV1: {
+ int profile = format.getInteger(MediaFormat.KEY_PROFILE, AV1ProfileMain8);
+ if (profile == AV1ProfileMain10) {
+ return true;
+ }
+ }
+ }
+ }
+ // check for HDR profiles (if necessary)
+ return doesAnyFormatHaveHDRProfile(mime, formats);
+ }
+
static boolean doesAnyFormatHaveHDRProfile(String mime, ArrayList<MediaFormat> formats) {
for (MediaFormat format : formats) {
assertEquals(mime, format.getString(MediaFormat.KEY_MIME));
@@ -1225,6 +1268,7 @@
String mMime;
String mTestFile;
boolean mIsInterlaced;
+ boolean mSkipChecksumVerification;
ArrayList<ByteBuffer> mCsdBuffers;
private int mCurrCsdIdx;
@@ -1248,6 +1292,7 @@
}
MediaFormat setUpSource(String prefix, String srcFile) throws IOException {
+ Preconditions.assertTestFileExists(prefix + srcFile);
mExtractor = new MediaExtractor();
mExtractor.setDataSource(prefix + srcFile);
for (int trackID = 0; trackID < mExtractor.getTrackCount(); trackID++) {
@@ -1265,11 +1310,15 @@
}
}
} else {
- if (mSurface == null) {
- // COLOR_FormatYUV420Flexible must be supported by all components
- format.setInteger(MediaFormat.KEY_COLOR_FORMAT, COLOR_FormatYUV420Flexible);
- } else {
- format.setInteger(MediaFormat.KEY_COLOR_FORMAT, COLOR_FormatSurface);
+ ArrayList<MediaFormat> formatList = new ArrayList<>();
+ formatList.add(format);
+ boolean selectHBD = doesAnyFormatHaveHBDProfile(mMime, formatList) ||
+ srcFile.contains("10bit");
+ format.setInteger(MediaFormat.KEY_COLOR_FORMAT,
+ getColorFormat(mCodecName, mMime, mSurface != null, selectHBD));
+ if (selectHBD && (format.getInteger(MediaFormat.KEY_COLOR_FORMAT) !=
+ COLOR_FormatYUVP010)) {
+ mSkipChecksumVerification = true;
}
}
// TODO: determine this from the extractor format when it becomes exposed.
@@ -1281,6 +1330,23 @@
return null;
}
+ int getColorFormat(String name, String mediaType, boolean surfaceMode, boolean hbdMode)
+ throws IOException {
+ if (surfaceMode) return COLOR_FormatSurface;
+ if (hbdMode) {
+ MediaCodec codec = MediaCodec.createByCodecName(name);
+ MediaCodecInfo.CodecCapabilities cap =
+ codec.getCodecInfo().getCapabilitiesForType(mediaType);
+ codec.release();
+ for (int c : cap.colorFormats) {
+ if (c == COLOR_FormatYUVP010) {
+ return c;
+ }
+ }
+ }
+ return COLOR_FormatYUV420Flexible;
+ }
+
boolean hasCSD(MediaFormat format) {
return format.containsKey("csd-0");
}
@@ -1371,15 +1437,18 @@
} else {
// tests both getOutputImage and getOutputBuffer. Can do time division
// multiplexing but lets allow it for now
- MediaFormat format = mCodec.getOutputFormat();
- int width = format.getInteger(MediaFormat.KEY_WIDTH);
- int height = format.getInteger(MediaFormat.KEY_HEIGHT);
- int stride = format.getInteger(MediaFormat.KEY_STRIDE);
- mOutputBuff.checksum(buf, info.size, width, height, stride);
-
Image img = mCodec.getOutputImage(bufferIndex);
assertTrue(img != null);
mOutputBuff.checksum(img);
+ int imgFormat = img.getFormat();
+ int bytesPerSample = (ImageFormat.getBitsPerPixel(imgFormat) * 2) / (8 * 3);
+
+ MediaFormat format = mCodec.getOutputFormat();
+ buf = mCodec.getOutputBuffer(bufferIndex);
+ int width = format.getInteger(MediaFormat.KEY_WIDTH);
+ int height = format.getInteger(MediaFormat.KEY_HEIGHT);
+ int stride = format.getInteger(MediaFormat.KEY_STRIDE);
+ mOutputBuff.checksum(buf, info.size, width, height, stride, bytesPerSample);
}
}
if ((info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
diff --git a/tests/media/src/android/mediav2/cts/ExtractorTest.java b/tests/media/src/android/mediav2/cts/ExtractorTest.java
index b7840db..502a5ba 100644
--- a/tests/media/src/android/mediav2/cts/ExtractorTest.java
+++ b/tests/media/src/android/mediav2/cts/ExtractorTest.java
@@ -1612,26 +1612,38 @@
}
}
extractor.release();
- assertTrue(format != null);
+ assertTrue("missing track format from file " + file, format != null);
if (mMime.equals(MediaFormat.MIMETYPE_AUDIO_AAC)) {
- assertTrue(format.containsKey(MediaFormat.KEY_AAC_PROFILE) ||
+ assertTrue("neither KEY_AAC_PROFILE nor KEY_PROFILE found in file " + file,
+ format.containsKey(MediaFormat.KEY_AAC_PROFILE) ||
format.containsKey(MediaFormat.KEY_PROFILE));
if (format.containsKey(MediaFormat.KEY_AAC_PROFILE)) {
- assertEquals(mProfile, format.getInteger(MediaFormat.KEY_AAC_PROFILE));
+ int profile = format.getInteger(MediaFormat.KEY_AAC_PROFILE, -1);
+ assertEquals("mismatched KEY_AAC_PROFILE in file " + file,
+ mProfile, profile);
}
if (format.containsKey(MediaFormat.KEY_PROFILE)) {
- assertEquals(mProfile, format.getInteger(MediaFormat.KEY_PROFILE));
+ int profile = format.getInteger(MediaFormat.KEY_PROFILE, -1);
+ assertEquals("mismatched KEY_PROFILE in file " + file, mProfile, profile);
}
} else {
- assertEquals(mProfile, format.getInteger(MediaFormat.KEY_PROFILE));
- assertEquals(mLevel, format.getInteger(MediaFormat.KEY_LEVEL));
+ int profile = format.getInteger(MediaFormat.KEY_PROFILE, -1);
+ assertEquals("mismatched KEY_PROFILE in file " + file, mProfile, profile);
+ int level = format.getInteger(MediaFormat.KEY_LEVEL, -1);
+ assertEquals("mismatched KEY_LEVEL in file " + file, mLevel, level);
}
if (mMime.startsWith("audio/")) {
- assertEquals(mWR, format.getInteger(MediaFormat.KEY_SAMPLE_RATE));
- assertEquals(mHCh, format.getInteger(MediaFormat.KEY_CHANNEL_COUNT));
+ int sample_rate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE, -1);
+ assertEquals("mismatched KEY_SAMPLE_RATE in file " + file,
+ mWR, sample_rate);
+ int channel_count = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT, -1);
+ assertEquals("mismatched KEY_CHANNEL_COUNT in file " + file,
+ mHCh, channel_count);
} else if (mMime.startsWith("video/")) {
- assertEquals(mWR, format.getInteger(MediaFormat.KEY_WIDTH));
- assertEquals(mHCh, format.getInteger(MediaFormat.KEY_HEIGHT));
+ int width = format.getInteger(MediaFormat.KEY_WIDTH, -1);
+ assertEquals("mismatched KEY_WIDTH in file " + file, mWR, width);
+ int height = format.getInteger(MediaFormat.KEY_HEIGHT, -1);
+ assertEquals("mismatched KEY_HEIGHT in file " + file, mHCh, height);
}
}
}
diff --git a/tests/mediapc/AndroidTest.xml b/tests/mediapc/AndroidTest.xml
index 904368d..dcc8995 100644
--- a/tests/mediapc/AndroidTest.xml
+++ b/tests/mediapc/AndroidTest.xml
@@ -26,7 +26,7 @@
</target_preparer>
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.MediaPreparer">
<option name="push-all" value="true" />
- <option name="media-folder-name" value="CtsMediaPerformanceClassTestCases-1.1" />
+ <option name="media-folder-name" value="CtsMediaPerformanceClassTestCases-1.2" />
<option name="dynamic-config-module" value="CtsMediaPerformanceClassTestCases" />
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
diff --git a/tests/mediapc/DynamicConfig.xml b/tests/mediapc/DynamicConfig.xml
index 973305e..d7ba901 100644
--- a/tests/mediapc/DynamicConfig.xml
+++ b/tests/mediapc/DynamicConfig.xml
@@ -1,6 +1,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/cts/tests/mediapc/CtsMediaPerformanceClassTestCases-1.1.zip</value>
+ <value>https://storage.googleapis.com/android_media/cts/tests/mediapc/CtsMediaPerformanceClassTestCases-1.2.zip</value>
</entry>
</dynamicConfig>
diff --git a/tests/mediapc/README.md b/tests/mediapc/README.md
index 1cb0ec5..f21aeb9 100644
--- a/tests/mediapc/README.md
+++ b/tests/mediapc/README.md
@@ -1,7 +1,7 @@
## Media Performance Class CTS Tests
Current folder comprises of files necessary for testing media performance class.
-The test vectors used by the test suite is available at [link](https://storage.googleapis.com/android_media/cts/tests/mediapc/CtsMediaPerformanceClassTestCases-1.1.zip) and is downloaded automatically while running tests. Manual installation of these can be done using copy_media.sh script in this directory.
+The test vectors used by the test suite is available at [link](https://storage.googleapis.com/android_media/cts/tests/mediapc/CtsMediaPerformanceClassTestCases-1.2.zip) and is downloaded automatically while running tests. Manual installation of these can be done using copy_media.sh script in this directory.
### Commands
```sh
diff --git a/tests/mediapc/copy_media.sh b/tests/mediapc/copy_media.sh
index 20437d1..054fe76 100644
--- a/tests/mediapc/copy_media.sh
+++ b/tests/mediapc/copy_media.sh
@@ -17,7 +17,7 @@
## script to install media performance class test files manually
adbOptions=" "
-resLabel=CtsMediaPerformanceClassTestCases-1.1
+resLabel=CtsMediaPerformanceClassTestCases-1.2
srcDir="/tmp/$resLabel"
tgtDir="/sdcard/test"
usage="Usage: $0 [-h] [-s serial]"
diff --git a/tests/mediapc/src/android/mediapc/cts/EncoderInitializationLatencyTest.java b/tests/mediapc/src/android/mediapc/cts/EncoderInitializationLatencyTest.java
index 6a2372f..9168e24 100644
--- a/tests/mediapc/src/android/mediapc/cts/EncoderInitializationLatencyTest.java
+++ b/tests/mediapc/src/android/mediapc/cts/EncoderInitializationLatencyTest.java
@@ -16,6 +16,13 @@
package android.mediapc.cts;
+import static android.mediapc.cts.CodecTestBase.selectCodecs;
+import static android.mediapc.cts.CodecTestBase.selectHardwareCodecs;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
+
import android.app.Instrumentation;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -34,9 +41,6 @@
import androidx.test.rule.ActivityTestRule;
import com.android.compatibility.common.util.CddTest;
-import com.android.compatibility.common.util.ReportLog;
-import com.android.compatibility.common.util.ReportLog.Metric;
-
import com.android.compatibility.common.util.DeviceReportLog;
import com.android.compatibility.common.util.ResultType;
import com.android.compatibility.common.util.ResultUnit;
@@ -55,13 +59,6 @@
import java.util.Collection;
import java.util.List;
-import static android.mediapc.cts.CodecTestBase.selectCodecs;
-import static android.mediapc.cts.CodecTestBase.selectHardwareCodecs;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeFalse;
-import static org.junit.Assume.assumeTrue;
-
/**
* The following test class validates the codec initialization latency (time for codec create +
* configure) for the audio encoders and hardware video encoders available in the device, under the
@@ -75,6 +72,8 @@
private static final int MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_R_MS = 65;
private static final int MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_S_MS = 40;
private static final int MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_S_MS = 50;
+ private static final int MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_T_MS = 30;
+ private static final int MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_T_MS = 40;
private static final int MAX_AUDIOENC_INITIALIZATION_LATENCY_MS;
private static final int MAX_VIDEOENC_INITIALIZATION_LATENCY_MS;
@@ -88,10 +87,13 @@
if (Utils.isRPerfClass()) {
MAX_AUDIOENC_INITIALIZATION_LATENCY_MS = MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_R_MS;
MAX_VIDEOENC_INITIALIZATION_LATENCY_MS = MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_R_MS;
- } else {
- // Performance class Build.VERSION_CODES.S and beyond
+ } else if (Utils.isSPerfClass()) {
MAX_AUDIOENC_INITIALIZATION_LATENCY_MS = MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_S_MS;
MAX_VIDEOENC_INITIALIZATION_LATENCY_MS = MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_S_MS;
+ } else {
+ // Performance class Build.VERSION_CODES.TIRAMISU and beyond
+ MAX_AUDIOENC_INITIALIZATION_LATENCY_MS = MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_T_MS;
+ MAX_VIDEOENC_INITIALIZATION_LATENCY_MS = MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_T_MS;
}
}
@@ -109,7 +111,7 @@
public void setUp() throws Exception {
Utils.assumeDeviceMeetsPerformanceClassPreconditions();
- ArrayList<String> listOfAvcHwDecoders = selectHardwareCodecs(AVC, null, null, false);
+ ArrayList<String> listOfAvcHwDecoders = selectHardwareCodecs(AVC, null, null, false);
assumeFalse("Test requires h/w avc decoder", listOfAvcHwDecoders.isEmpty());
AVC_DECODER_NAME = listOfAvcHwDecoders.get(0);
@@ -196,14 +198,15 @@
listOfEncoders = selectHardwareCodecs(mime, null, null, true);
}
for (String encoder : listOfEncoders) {
- argsList.add(new Object[] {mime, encoder});
+ argsList.add(new Object[]{mime, encoder});
}
}
return argsList;
}
private MediaRecorder createMediaRecorderLoad(Surface surface) throws Exception {
- MediaRecorder mediaRecorder = new MediaRecorder();
+ MediaRecorder mediaRecorder = new MediaRecorder(InstrumentationRegistry.getInstrumentation()
+ .getContext());
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
@@ -259,7 +262,7 @@
mMediaRecorderLoad.stop();
mMediaRecorderLoad.release();
mMediaRecorderLoad = null;
- if(mTempRecordedFile != null && mTempRecordedFile.exists()) {
+ if (mTempRecordedFile != null && mTempRecordedFile.exists()) {
mTempRecordedFile.delete();
mTempRecordedFile = null;
}
@@ -290,7 +293,7 @@
*/
@LargeTest
@Test(timeout = CodecTestBase.PER_TEST_TIMEOUT_LARGE_TEST_MS)
- @CddTest(requirement="2.2.7.1/5.1/H-1-7,H-1-8")
+ @CddTest(requirement = "2.2.7.1/5.1/H-1-7,H-1-8")
public void testInitializationLatency() throws Exception {
final int NUM_MEASUREMENTS = 5;
// Test gathers initialization latency for a number of iterations and
@@ -328,17 +331,21 @@
expectedMaxCodecInitializationLatencyMs);
assertTrue(errorLog, initializationLatency <= expectedMaxCodecInitializationLatencyMs);
} else {
- int pc = 0;
+ int pc;
if (mMime.startsWith("audio/")) {
- pc = initializationLatency < MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_S_MS
- ? Build.VERSION_CODES.S
- : initializationLatency < MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_R_MS
- ? Build.VERSION_CODES.R : 0;
+ pc = initializationLatency < MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_T_MS ?
+ Build.VERSION_CODES.TIRAMISU :
+ initializationLatency < MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_S_MS ?
+ Build.VERSION_CODES.S : initializationLatency <
+ MAX_AUDIOENC_INITIALIZATION_LATENCY_PC_R_MS ?
+ Build.VERSION_CODES.R : 0;
} else {
- pc = initializationLatency < MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_S_MS
- ? Build.VERSION_CODES.S
- : initializationLatency < MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_R_MS
- ? Build.VERSION_CODES.R : 0;
+ pc = initializationLatency < MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_T_MS ?
+ Build.VERSION_CODES.TIRAMISU :
+ initializationLatency < MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_S_MS ?
+ Build.VERSION_CODES.S : initializationLatency <
+ MAX_VIDEOENC_INITIALIZATION_LATENCY_PC_R_MS ?
+ Build.VERSION_CODES.R : 0;
}
DeviceReportLog log = new DeviceReportLog("MediaPerformanceClassLogs",
"InitializationLatency_" + mEncoderName);
diff --git a/tests/mediapc/src/android/mediapc/cts/WorkDir.java b/tests/mediapc/src/android/mediapc/cts/WorkDir.java
index d45c14b..cd5ad7e 100644
--- a/tests/mediapc/src/android/mediapc/cts/WorkDir.java
+++ b/tests/mediapc/src/android/mediapc/cts/WorkDir.java
@@ -40,7 +40,7 @@
// user has specified the mediaDirString via instrumentation-arg
return mediaDirString + ((mediaDirString.endsWith("/")) ? "" : "/");
} else {
- return (getTopDirString() + "test/CtsMediaPerformanceClassTestCases-1.1/");
+ return (getTopDirString() + "test/CtsMediaPerformanceClassTestCases-1.2/");
}
}
}
diff --git a/tests/tests/binder_ndk/libbinder_ndk_test/test_native_aidl_client.cpp b/tests/tests/binder_ndk/libbinder_ndk_test/test_native_aidl_client.cpp
index 48bdf6d..3d067c0 100644
--- a/tests/tests/binder_ndk/libbinder_ndk_test/test_native_aidl_client.cpp
+++ b/tests/tests/binder_ndk/libbinder_ndk_test/test_native_aidl_client.cpp
@@ -346,8 +346,10 @@
ASSERT_OK(iface->RepeatInterface(empty, &ret));
EXPECT_EQ(empty.get(), ret.get());
- // interfaces are always nullable in AIDL C++, and that behavior was carried
- // over to the NDK backend for consistency
+ // b/210547999
+ // interface writes are always nullable in AIDL C++ (but reads are not
+ // nullable by default). However, the NDK backend follows the Java behavior
+ // and always allows interfaces to be nullable (for reads and writes).
ASSERT_OK(iface->RepeatInterface(nullptr, &ret));
EXPECT_EQ(nullptr, ret.get());
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java
new file mode 100644
index 0000000..aef247b
--- /dev/null
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2022 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.bluetooth.cts;
+
+import static android.Manifest.permission.BLUETOOTH_CONNECT;
+
+import static org.junit.Assert.assertThrows;
+
+import android.app.UiAutomation;
+import android.bluetooth.BluetoothA2dpSink;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothManager;
+import android.bluetooth.BluetoothProfile;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.test.AndroidTestCase;
+import android.util.Log;
+
+import androidx.test.InstrumentationRegistry;
+
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+public class BluetoothA2dpSinkTest extends AndroidTestCase {
+ private static final String TAG = BluetoothA2dpSinkTest.class.getSimpleName();
+
+ private static final int PROXY_CONNECTION_TIMEOUT_MS = 500; // ms timeout for Proxy Connect
+ private static final String PROFILE_SUPPORTED_A2DP_SINK = "profile_supported_a2dp_sink";
+
+ private boolean mHasBluetooth;
+ private BluetoothAdapter mAdapter;
+ private UiAutomation mUiAutomation;;
+
+ private BluetoothA2dpSink mBluetoothA2dpSink;
+ private boolean mIsA2dpSinkSupported;
+ private boolean mIsProfileReady;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ mHasBluetooth = getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_BLUETOOTH);
+
+ if (!mHasBluetooth) return;
+
+ Resources bluetoothResources = mContext.getPackageManager().getResourcesForApplication(
+ "com.android.bluetooth");
+ int a2dpSinkSupportId = bluetoothResources.getIdentifier(
+ PROFILE_SUPPORTED_A2DP_SINK, "bool", "com.android.bluetooth");
+ assertTrue("resource profile_supported_a2dp not found", a2dpSinkSupportId != 0);
+ mIsA2dpSinkSupported = bluetoothResources.getBoolean(a2dpSinkSupportId);
+ if (!mIsA2dpSinkSupported) return;
+
+ mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
+ mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
+
+ BluetoothManager manager = getContext().getSystemService(BluetoothManager.class);
+ mAdapter = manager.getAdapter();
+ assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
+
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
+ mIsProfileReady = false;
+ mBluetoothA2dpSink = null;
+
+ mAdapter.getProfileProxy(getContext(), new BluetoothA2dpSinkServiceListener(),
+ BluetoothProfile.A2DP_SINK);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ if (!(mHasBluetooth && mIsA2dpSinkSupported)) return;
+
+ if (mAdapter != null && mBluetoothA2dpSink != null) {
+ mAdapter.closeProfileProxy(BluetoothProfile.A2DP_SINK, mBluetoothA2dpSink);
+ mBluetoothA2dpSink = null;
+ mIsProfileReady = false;
+ }
+ mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ mUiAutomation.dropShellPermissionIdentity();
+ mAdapter = null;
+ }
+
+ public void test_getConnectedDevices() {
+ if (!(mHasBluetooth && mIsA2dpSinkSupported)) return;
+
+ assertTrue(waitForProfileConnect());
+ assertNotNull(mBluetoothA2dpSink);
+
+ assertEquals(mBluetoothA2dpSink.getConnectedDevices(), new ArrayList<BluetoothDevice>());
+
+ mUiAutomation.dropShellPermissionIdentity();
+ assertThrows(SecurityException.class, () -> mBluetoothA2dpSink.getConnectedDevices());
+ }
+
+ public void test_getDevicesMatchingConnectionStates() {
+ if (!(mHasBluetooth && mIsA2dpSinkSupported)) return;
+
+ assertTrue(waitForProfileConnect());
+ assertNotNull(mBluetoothA2dpSink);
+
+ assertEquals(mBluetoothA2dpSink.getDevicesMatchingConnectionStates(
+ new int[]{BluetoothProfile.STATE_CONNECTED}),
+ new ArrayList<BluetoothDevice>());
+ }
+
+ public void test_getConnectionState() {
+ if (!(mHasBluetooth && mIsA2dpSinkSupported)) return;
+
+ assertTrue(waitForProfileConnect());
+ assertNotNull(mBluetoothA2dpSink);
+
+ BluetoothDevice testDevice = mAdapter.getRemoteDevice("00:11:22:AA:BB:CC");
+
+ assertEquals(mBluetoothA2dpSink.getConnectionState(testDevice),
+ BluetoothProfile.STATE_DISCONNECTED);
+
+ mUiAutomation.dropShellPermissionIdentity();
+ assertThrows(SecurityException.class,
+ () -> mBluetoothA2dpSink.getConnectionState(testDevice));
+ }
+
+ private boolean waitForProfileConnect() {
+ mProfileConnectedlock.lock();
+ try {
+ // Wait for the Adapter to be disabled
+ while (!mIsProfileReady) {
+ if (!mConditionProfileIsConnected.await(
+ PROXY_CONNECTION_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
+ // Timeout
+ Log.e(TAG, "Timeout while waiting for Profile Connect");
+ break;
+ } // else spurious wakeups
+ }
+ } catch (InterruptedException e) {
+ Log.e(TAG, "waitForProfileConnect: interrrupted");
+ } finally {
+ mProfileConnectedlock.unlock();
+ }
+ return mIsProfileReady;
+ }
+
+ private final class BluetoothA2dpSinkServiceListener implements
+ BluetoothProfile.ServiceListener {
+
+ @Override
+ public void onServiceConnected(int profile, BluetoothProfile proxy) {
+ mProfileConnectedlock.lock();
+ mBluetoothA2dpSink = (BluetoothA2dpSink) proxy;
+ mIsProfileReady = true;
+ try {
+ mConditionProfileIsConnected.signal();
+ } finally {
+ mProfileConnectedlock.unlock();
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(int profile) {
+ }
+ }
+}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
index b013b63..15039fa 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
@@ -176,6 +176,26 @@
});
}
+ public void test_setOptionalCodecsEnabled() {
+ if (!(mHasBluetooth && mIsA2dpSupported)) return;
+
+ assertTrue(waitForProfileConnect());
+ assertNotNull(mBluetoothA2dp);
+
+ assertThrows(IllegalArgumentException.class,
+ () -> mBluetoothA2dp.setOptionalCodecsEnabled(null, 0));
+ BluetoothDevice testDevice = mAdapter.getRemoteDevice("00:11:22:AA:BB:CC");
+
+ mUiAutomation.dropShellPermissionIdentity();
+ assertThrows(SecurityException.class, () -> mBluetoothA2dp
+ .setOptionalCodecsEnabled(testDevice, BluetoothA2dp.OPTIONAL_CODECS_PREF_UNKNOWN));
+ assertThrows(SecurityException.class, () -> mBluetoothA2dp
+ .setOptionalCodecsEnabled(testDevice, BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED));
+ assertThrows(SecurityException.class, () -> mBluetoothA2dp
+ .setOptionalCodecsEnabled(testDevice, BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED));
+ mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
+ }
+
private static <T extends Exception> void assertThrows(Class<T> clazz, Runnable r) {
try {
r.run();
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothAdapterTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothAdapterTest.java
index ede7ac3..e4cd745 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothAdapterTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothAdapterTest.java
@@ -441,39 +441,6 @@
public void test_BluetoothConnectionCallback_disconnectReasonText() {
assertEquals("Reason unknown", BluetoothAdapter.BluetoothConnectionCallback
.disconnectReasonText(BluetoothStatusCodes.ERROR_UNKNOWN));
- assertEquals("Local request", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(BluetoothStatusCodes.ERROR_DISCONNECT_REASON_LOCAL_REQUEST));
- assertEquals("Remote request", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(BluetoothStatusCodes.ERROR_DISCONNECT_REASON_REMOTE_REQUEST));
- assertEquals("Local error", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(BluetoothStatusCodes.ERROR_DISCONNECT_REASON_LOCAL));
- assertEquals("Remote error", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(BluetoothStatusCodes.ERROR_DISCONNECT_REASON_REMOTE));
- assertEquals("Timeout", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(BluetoothStatusCodes.ERROR_DISCONNECT_REASON_TIMEOUT));
- assertEquals("Security", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(BluetoothStatusCodes.ERROR_DISCONNECT_REASON_SECURITY));
- assertEquals("System policy", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(BluetoothStatusCodes.ERROR_DISCONNECT_REASON_SYSTEM_POLICY));
- assertEquals("Resource constrained", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(
- BluetoothStatusCodes.ERROR_DISCONNECT_REASON_RESOURCE_LIMIT_REACHED));
- assertEquals("Connection already exists", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(
- BluetoothStatusCodes.ERROR_DISCONNECT_REASON_CONNECTION_ALREADY_EXISTS));
- assertEquals("Bad parameters", BluetoothAdapter.BluetoothConnectionCallback
- .disconnectReasonText(BluetoothStatusCodes.ERROR_DISCONNECT_REASON_BAD_PARAMETERS));
- final int min_reason = BluetoothStatusCodes.ERROR_DISCONNECT_REASON_LOCAL_REQUEST - 1;
- for (int reason = 0; reason < min_reason; reason++) {
- assertEquals("Unrecognized disconnect reason: " + reason,
- BluetoothAdapter.BluetoothConnectionCallback.disconnectReasonText(reason));
- }
- final int max_reason = BluetoothStatusCodes.ERROR_DISCONNECT_REASON_BAD_PARAMETERS + 1;
- // Check value after state range (skip TURNING_OFF)
- for (int reason = max_reason; reason < max_reason + 100; reason++) {
- assertEquals("Unrecognized disconnect reason: " + reason,
- BluetoothAdapter.BluetoothConnectionCallback.disconnectReasonText(reason));
- }
}
public void test_registerBluetoothConnectionCallback() {
@@ -489,6 +456,10 @@
};
+ // placeholder call for coverage
+ callback.onDeviceConnected(null);
+ callback.onDeviceDisconnected(null, BluetoothStatusCodes.ERROR_UNKNOWN);
+
// Verify parameter
assertFalse(mAdapter.registerBluetoothConnectionCallback(null, callback));
assertFalse(mAdapter.registerBluetoothConnectionCallback(executor, null));
@@ -593,8 +564,8 @@
BluetoothProfile.getProfileName(BluetoothProfile.A2DP_SINK));
assertEquals("AVRCP_CONTROLLER",
BluetoothProfile.getProfileName(BluetoothProfile.AVRCP_CONTROLLER));
- assertEquals("AVRCP",
- BluetoothProfile.getProfileName(BluetoothProfile.AVRCP));
+ // assertEquals("AVRCP",
+ // BluetoothProfile.getProfileName(BluetoothProfile.AVRCP));
assertEquals("HEADSET_CLIENT",
BluetoothProfile.getProfileName(BluetoothProfile.HEADSET_CLIENT));
assertEquals("PBAP_CLIENT",
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothCodecsTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothCodecsTest.java
new file mode 100644
index 0000000..10c18a2
--- /dev/null
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothCodecsTest.java
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2022 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.bluetooth.cts;
+
+import android.app.UiAutomation;
+import android.bluetooth.BluetoothCodecConfig;
+import android.bluetooth.BluetoothCodecStatus;
+import android.test.AndroidTestCase;
+
+import androidx.test.InstrumentationRegistry;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+public class BluetoothCodecsTest extends AndroidTestCase {
+ private static final String TAG = BluetoothCodecsTest.class.getSimpleName();
+
+ // Codec configs: A and B are same; C is different
+ private static final BluetoothCodecConfig config_A =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig config_B =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig config_C =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO,
+ 1000, 2000, 3000, 4000);
+
+ // Local capabilities: A and B are same; C is different
+ private static final BluetoothCodecConfig local_capability1_A =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100 |
+ BluetoothCodecConfig.SAMPLE_RATE_48000,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO |
+ BluetoothCodecConfig.CHANNEL_MODE_MONO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig local_capability1_B =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100 |
+ BluetoothCodecConfig.SAMPLE_RATE_48000,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO |
+ BluetoothCodecConfig.CHANNEL_MODE_MONO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig local_capability1_C =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100 |
+ BluetoothCodecConfig.SAMPLE_RATE_48000,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig local_capability2_A =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100 |
+ BluetoothCodecConfig.SAMPLE_RATE_48000,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO |
+ BluetoothCodecConfig.CHANNEL_MODE_MONO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig local_capability2_B =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100 |
+ BluetoothCodecConfig.SAMPLE_RATE_48000,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO |
+ BluetoothCodecConfig.CHANNEL_MODE_MONO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig local_capability2_C =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100 |
+ BluetoothCodecConfig.SAMPLE_RATE_48000,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO,
+ 1000, 2000, 3000, 4000);
+
+ // Selectable capabilities: A and B are same; C is different
+ private static final BluetoothCodecConfig selectable_capability1_A =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO |
+ BluetoothCodecConfig.CHANNEL_MODE_MONO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig selectable_capability1_B =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO |
+ BluetoothCodecConfig.CHANNEL_MODE_MONO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig selectable_capability1_C =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig selectable_capability2_A =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO |
+ BluetoothCodecConfig.CHANNEL_MODE_MONO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig selectable_capability2_B =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO |
+ BluetoothCodecConfig.CHANNEL_MODE_MONO,
+ 1000, 2000, 3000, 4000);
+
+ private static final BluetoothCodecConfig selectable_capability2_C =
+ buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
+ BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
+ BluetoothCodecConfig.SAMPLE_RATE_44100,
+ BluetoothCodecConfig.BITS_PER_SAMPLE_16,
+ BluetoothCodecConfig.CHANNEL_MODE_STEREO,
+ 1000, 2000, 3000, 4000);
+
+ private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_A =
+ new ArrayList() {{
+ add(local_capability1_A);
+ add(local_capability2_A);
+ }};
+
+ private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_B =
+ new ArrayList() {{
+ add(local_capability1_B);
+ add(local_capability2_B);
+ }};
+
+ private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_C =
+ new ArrayList() {{
+ add(local_capability1_C);
+ add(local_capability2_C);
+ }};
+
+ private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_A =
+ new ArrayList() {{
+ add(selectable_capability1_A);
+ add(selectable_capability2_A);
+ }};
+
+ private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_B =
+ new ArrayList() {{
+ add(selectable_capability1_B);
+ add(selectable_capability2_B);
+ }};
+
+ private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_C =
+ new ArrayList() {{
+ add(selectable_capability1_C);
+ add(selectable_capability2_C);
+ }};
+
+ private static final BluetoothCodecStatus bcs_A =
+ new BluetoothCodecStatus.Builder()
+ .setCodecConfig(config_A)
+ .setCodecsLocalCapabilities(LOCAL_CAPABILITY_A)
+ .setCodecsSelectableCapabilities(SELECTABLE_CAPABILITY_A)
+ .build();
+ private static final BluetoothCodecStatus bcs_B =
+ new BluetoothCodecStatus.Builder()
+ .setCodecConfig(config_B)
+ .setCodecsLocalCapabilities(LOCAL_CAPABILITY_B)
+ .setCodecsSelectableCapabilities(SELECTABLE_CAPABILITY_B)
+ .build();
+ private static final BluetoothCodecStatus bcs_C =
+ new BluetoothCodecStatus.Builder()
+ .setCodecConfig(config_C)
+ .setCodecsLocalCapabilities(LOCAL_CAPABILITY_C)
+ .setCodecsSelectableCapabilities(SELECTABLE_CAPABILITY_C)
+ .build();
+
+ public void test_BluetoothCodecStatusBuilder() {
+ BluetoothCodecStatus builderConfig = new BluetoothCodecStatus.Builder()
+ .setCodecConfig(config_A)
+ .setCodecsLocalCapabilities(LOCAL_CAPABILITY_B)
+ .setCodecsSelectableCapabilities(SELECTABLE_CAPABILITY_C)
+ .build();
+
+ assertTrue(Objects.equals(builderConfig.getCodecConfig(), config_A));
+ assertTrue(Objects.equals(builderConfig.getCodecsLocalCapabilities(),
+ LOCAL_CAPABILITY_B));
+ assertTrue(Objects.equals(builderConfig.getCodecsSelectableCapabilities(),
+ SELECTABLE_CAPABILITY_C));
+ }
+
+ public void test_BluetoothCodecConfigBuilder() {
+ BluetoothCodecConfig builderConfig = new BluetoothCodecConfig.Builder()
+ .setCodecType(config_A.getCodecType())
+ .setCodecPriority(config_A.getCodecPriority())
+ .setSampleRate(config_A.getSampleRate())
+ .setBitsPerSample(config_A.getBitsPerSample())
+ .setChannelMode(config_A.getChannelMode())
+ .setCodecSpecific1(config_A.getCodecSpecific1())
+ .setCodecSpecific2(config_A.getCodecSpecific2())
+ .setCodecSpecific3(config_A.getCodecSpecific3())
+ .setCodecSpecific4(config_A.getCodecSpecific4())
+ .build();
+
+ assertTrue(Objects.equals(builderConfig, config_A));
+ assertTrue(builderConfig.isMandatoryCodec());
+ }
+
+ public void test_GetCodecConfig() {
+ assertTrue(Objects.equals(bcs_A.getCodecConfig(), config_A));
+ assertTrue(Objects.equals(bcs_A.getCodecConfig(), config_B));
+ assertFalse(Objects.equals(bcs_A.getCodecConfig(), config_C));
+ }
+
+ public void test_CodecsCapabilities() {
+ assertTrue(bcs_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_A));
+ assertTrue(bcs_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_B));
+ assertFalse(bcs_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_C));
+
+ assertTrue(bcs_A.getCodecsSelectableCapabilities()
+ .equals(SELECTABLE_CAPABILITY_A));
+ assertTrue(bcs_A.getCodecsSelectableCapabilities()
+ .equals(SELECTABLE_CAPABILITY_B));
+ assertFalse(bcs_A.getCodecsSelectableCapabilities()
+ .equals(SELECTABLE_CAPABILITY_C));
+ }
+
+ public void test_IsCodecConfigSelectable() {
+ assertFalse(bcs_A.isCodecConfigSelectable(null));
+ assertTrue(bcs_A.isCodecConfigSelectable(selectable_capability1_C));
+ assertTrue(bcs_A.isCodecConfigSelectable(selectable_capability2_C));
+
+ // Not selectable due to multiple channel modes
+ assertFalse(bcs_A.isCodecConfigSelectable(selectable_capability1_A));
+ assertFalse(bcs_A.isCodecConfigSelectable(selectable_capability1_B));
+ assertFalse(bcs_A.isCodecConfigSelectable(selectable_capability2_A));
+ assertFalse(bcs_A.isCodecConfigSelectable(selectable_capability2_B));
+ }
+
+ private static BluetoothCodecConfig buildBluetoothCodecConfig(int sourceCodecType,
+ int codecPriority, int sampleRate, int bitsPerSample, int channelMode,
+ long codecSpecific1, long codecSpecific2, long codecSpecific3, long codecSpecific4) {
+ return new BluetoothCodecConfig.Builder()
+ .setCodecType(sourceCodecType)
+ .setCodecPriority(codecPriority)
+ .setSampleRate(sampleRate)
+ .setBitsPerSample(bitsPerSample)
+ .setChannelMode(channelMode)
+ .setCodecSpecific1(codecSpecific1)
+ .setCodecSpecific2(codecSpecific2)
+ .setCodecSpecific3(codecSpecific3)
+ .setCodecSpecific4(codecSpecific4)
+ .build();
+ }
+}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioCodecConfigMetadataTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioCodecConfigMetadataTest.java
index af30292..0100442 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioCodecConfigMetadataTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioCodecConfigMetadataTest.java
@@ -115,6 +115,21 @@
}
@Test
+ public void testCreateCodecConfigMetadataFromCopy() {
+ if (shouldSkipTest()) {
+ return;
+ }
+ BluetoothLeAudioCodecConfigMetadata codecMetadata =
+ new BluetoothLeAudioCodecConfigMetadata.Builder()
+ .setAudioLocation(TEST_AUDIO_LOCATION_FRONT_LEFT).build();
+ BluetoothLeAudioCodecConfigMetadata codecMetadataCopy =
+ new BluetoothLeAudioCodecConfigMetadata.Builder(codecMetadata).build();
+ assertEquals(codecMetadata, codecMetadataCopy);
+ assertEquals(TEST_AUDIO_LOCATION_FRONT_LEFT, codecMetadataCopy.getAudioLocation());
+ assertArrayEquals(TEST_METADATA_BYTES, codecMetadata.getRawMetadata());
+ }
+
+ @Test
public void testCreateCodecConfigMetadataFromBytes() {
if (shouldSkipTest()) {
return;
@@ -124,8 +139,7 @@
byte[] metadataBytes = codecMetadata.getRawMetadata();
assertNotNull(metadataBytes);
assertArrayEquals(TEST_METADATA_BYTES, metadataBytes);
- // TODO: Implement implicit LTV byte conversion in the API class
- // assertEquals(TEST_AUDIO_LOCATION_FRONT_LEFT, codecMetadata.getAudioLocation());
+ assertEquals(TEST_AUDIO_LOCATION_FRONT_LEFT, codecMetadata.getAudioLocation());
}
private boolean shouldSkipTest() {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioContentMetadataTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioContentMetadataTest.java
index 6c32580..08deed4 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioContentMetadataTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioContentMetadataTest.java
@@ -117,8 +117,22 @@
.setProgramInfo(TEST_PROGRAM_INFO).setLanguage(TEST_LANGUAGE).build();
assertEquals(TEST_PROGRAM_INFO, contentMetadata.getProgramInfo());
assertEquals(TEST_LANGUAGE, contentMetadata.getLanguage());
- // TODO: Implement implicit LTV byte conversion in the API class
- // assertArrayEquals(TEST_METADATA_BYTES, contentMetadata.getRawMetadata());
+ assertArrayEquals(TEST_METADATA_BYTES, contentMetadata.getRawMetadata());
+ }
+
+ @Test
+ public void testCreateCodecConfigMetadataFromCopy() {
+ if (shouldSkipTest()) {
+ return;
+ }
+ BluetoothLeAudioContentMetadata contentMetadata =
+ new BluetoothLeAudioContentMetadata.Builder()
+ .setProgramInfo(TEST_PROGRAM_INFO).setLanguage(TEST_LANGUAGE).build();
+ BluetoothLeAudioContentMetadata contentMetadataCopy =
+ new BluetoothLeAudioContentMetadata.Builder(contentMetadata).build();
+ assertEquals(TEST_PROGRAM_INFO, contentMetadataCopy.getProgramInfo());
+ assertEquals(TEST_LANGUAGE, contentMetadataCopy.getLanguage());
+ assertArrayEquals(TEST_METADATA_BYTES, contentMetadataCopy.getRawMetadata());
}
@Test
@@ -131,9 +145,8 @@
byte[] metadataBytes = contentMetadata.getRawMetadata();
assertNotNull(metadataBytes);
assertArrayEquals(TEST_METADATA_BYTES, metadataBytes);
- // TODO: Implement implicit LTV byte conversion in the API class
- // assertEquals(TEST_PROGRAM_INFO, contentMetadata.getProgramInfo());
- // assertEquals(TEST_LANGUAGE, contentMetadata.getLanguage());
+ assertEquals(TEST_PROGRAM_INFO, contentMetadata.getProgramInfo());
+ assertEquals(TEST_LANGUAGE, contentMetadata.getLanguage());
}
private boolean shouldSkipTest() {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
index 6b349e7..1c0cb12 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
@@ -21,6 +21,7 @@
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothLeAudio;
+import android.bluetooth.BluetoothLeAudioCodecStatus;
import android.bluetooth.BluetoothLeAudioCodecConfig;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
@@ -35,6 +36,7 @@
import com.android.compatibility.common.util.ApiLevelUtil;
import java.util.List;
+import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@@ -176,47 +178,27 @@
mBluetoothLeAudio.getConnectionPolicy(null));
}
- public void test_setVolume() {
+ public void testRegisterCallback() {
if (!(mHasBluetooth && mIsLeAudioSupported)) return;
assertTrue(waitForProfileConnect());
assertNotNull(mBluetoothLeAudio);
- // This should throw a SecurityException because no BLUETOOTH_PRIVILEGED permission
- assertThrows(SecurityException.class, () -> mBluetoothLeAudio.setVolume(42));
- }
+ Executor executor = mContext.getMainExecutor();
+ BluetoothLeAudio.Callback callback =
+ new BluetoothLeAudio.Callback() {
+ @Override
+ public void onCodecConfigChanged(int groupId,
+ BluetoothLeAudioCodecStatus status) {}
+ };
- public void testGetCodecStatus() {
- if (!(mHasBluetooth && mIsLeAudioSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothLeAudio);
-
- BluetoothDevice testDevice = mAdapter.getRemoteDevice("00:11:22:AA:BB:CC");
-
- assertNull(mBluetoothLeAudio.getCodecStatus(testDevice));
- assertThrows(IllegalArgumentException.class, () -> {
- mBluetoothLeAudio.getCodecStatus(null);
- });
- }
-
- public void testSetCodecConfigPreference() {
- if (!(mHasBluetooth && mIsLeAudioSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothLeAudio);
-
- BluetoothDevice testDevice = mAdapter.getRemoteDevice("00:11:22:AA:BB:CC");
-
- BluetoothLeAudioCodecConfig codecConfig = new BluetoothLeAudioCodecConfig.Builder()
- .setCodecType(BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_LC3)
- .setCodecPriority(0)
- .build();
- mBluetoothLeAudio.setCodecConfigPreference(testDevice, codecConfig);
- assertNull(mBluetoothLeAudio.getCodecStatus(testDevice));
- assertThrows(IllegalArgumentException.class, () -> {
- mBluetoothLeAudio.setCodecConfigPreference(null, null);
- });
+ // Verify parameter
+ assertThrows(NullPointerException.class, () ->
+ mBluetoothLeAudio.registerCallback(null, callback));
+ assertThrows(NullPointerException.class, () ->
+ mBluetoothLeAudio.registerCallback(executor, null));
+ assertThrows(NullPointerException.class, () ->
+ mBluetoothLeAudio.unregisterCallback(null));
}
private boolean waitForProfileConnect() {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastMetadataTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastMetadataTest.java
index 5651320..d0f3118 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastMetadataTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastMetadataTest.java
@@ -19,13 +19,20 @@
import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.bluetooth.BluetoothStatusCodes.FEATURE_SUPPORTED;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothLeAudioCodecConfigMetadata;
+import android.bluetooth.BluetoothLeAudioContentMetadata;
+import android.bluetooth.BluetoothLeBroadcastChannel;
import android.bluetooth.BluetoothLeBroadcastMetadata;
+import android.bluetooth.BluetoothLeBroadcastSubgroup;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.os.Build;
@@ -50,6 +57,17 @@
private static final int TEST_PA_SYNC_INTERVAL = 100;
private static final int TEST_PRESENTATION_DELAY_MS = 345;
+ private static final int TEST_CODEC_ID = 42;
+ private static final BluetoothLeBroadcastChannel[] TEST_CHANNELS = {null};
+
+ // For BluetoothLeAudioCodecConfigMetadata
+ private static final long TEST_AUDIO_LOCATION_FRONT_LEFT = 0x01;
+
+ // For BluetoothLeAudioContentMetadata
+ private static final String TEST_PROGRAM_INFO = "Test";
+ // German language code in ISO 639-3
+ private static final String TEST_LANGUAGE = "deu";
+
private Context mContext;
private boolean mHasBluetooth;
private BluetoothAdapter mAdapter;
@@ -107,25 +125,99 @@
}
BluetoothDevice testDevice =
mAdapter.getRemoteLeDevice(TEST_MAC_ADDRESS, BluetoothDevice.ADDRESS_TYPE_RANDOM);
- BluetoothLeBroadcastMetadata.Builder builder = new BluetoothLeBroadcastMetadata.Builder();
- BluetoothLeBroadcastMetadata metadata =
- builder.setEncrypted(false)
+ BluetoothLeBroadcastMetadata.Builder builder = new BluetoothLeBroadcastMetadata.Builder()
+ .setEncrypted(false)
.setSourceDevice(testDevice, BluetoothDevice.ADDRESS_TYPE_RANDOM)
.setSourceAdvertisingSid(TEST_ADVERTISER_SID)
.setBroadcastId(TEST_BROADCAST_ID)
.setBroadcastCode(null)
.setPaSyncInterval(TEST_PA_SYNC_INTERVAL)
- .setPresentationDelayMicros(TEST_PRESENTATION_DELAY_MS)
- .build();
+ .setPresentationDelayMicros(TEST_PRESENTATION_DELAY_MS);
+ // builder expect at least one subgroup
+ assertThrows(IllegalArgumentException.class, builder::build);
+ BluetoothLeBroadcastSubgroup[] subgroups = new BluetoothLeBroadcastSubgroup[] {
+ createBroadcastSubgroup()
+ };
+ for (BluetoothLeBroadcastSubgroup subgroup : subgroups) {
+ builder.addSubgroup(subgroup);
+ }
+ BluetoothLeBroadcastMetadata metadata = builder.build();
+ assertFalse(metadata.isEncrypted());
assertEquals(testDevice, metadata.getSourceDevice());
assertEquals(BluetoothDevice.ADDRESS_TYPE_RANDOM, metadata.getSourceAddressType());
+ assertEquals(TEST_ADVERTISER_SID, metadata.getSourceAdvertisingSid());
assertEquals(TEST_BROADCAST_ID, metadata.getBroadcastId());
assertNull(metadata.getBroadcastCode());
assertEquals(TEST_PA_SYNC_INTERVAL, metadata.getPaSyncInterval());
assertEquals(TEST_PRESENTATION_DELAY_MS, metadata.getPresentationDelayMicros());
+ assertArrayEquals(subgroups,
+ metadata.getSubgroups().toArray(new BluetoothLeBroadcastSubgroup[0]));
+ builder.clearSubgroup();
+ // builder expect at least one subgroup
+ assertThrows(IllegalArgumentException.class, builder::build);
+ }
+
+ @Test
+ public void testCreateMetadataFromCopy() {
+ if (shouldSkipTest()) {
+ return;
+ }
+ BluetoothDevice testDevice =
+ mAdapter.getRemoteLeDevice(TEST_MAC_ADDRESS, BluetoothDevice.ADDRESS_TYPE_RANDOM);
+ BluetoothLeBroadcastMetadata.Builder builder = new BluetoothLeBroadcastMetadata.Builder()
+ .setEncrypted(false)
+ .setSourceDevice(testDevice, BluetoothDevice.ADDRESS_TYPE_RANDOM)
+ .setSourceAdvertisingSid(TEST_ADVERTISER_SID)
+ .setBroadcastId(TEST_BROADCAST_ID)
+ .setBroadcastCode(null)
+ .setPaSyncInterval(TEST_PA_SYNC_INTERVAL)
+ .setPresentationDelayMicros(TEST_PRESENTATION_DELAY_MS);
+ // builder expect at least one subgroup
+ assertThrows(IllegalArgumentException.class, builder::build);
+ BluetoothLeBroadcastSubgroup[] subgroups = new BluetoothLeBroadcastSubgroup[] {
+ createBroadcastSubgroup()
+ };
+ for (BluetoothLeBroadcastSubgroup subgroup : subgroups) {
+ builder.addSubgroup(subgroup);
+ }
+ BluetoothLeBroadcastMetadata metadata = builder.build();
+ BluetoothLeBroadcastMetadata metadataCopy =
+ new BluetoothLeBroadcastMetadata.Builder(metadata).build();
+ assertFalse(metadataCopy.isEncrypted());
+ assertEquals(testDevice, metadataCopy.getSourceDevice());
+ assertEquals(BluetoothDevice.ADDRESS_TYPE_RANDOM, metadataCopy.getSourceAddressType());
+ assertEquals(TEST_ADVERTISER_SID, metadataCopy.getSourceAdvertisingSid());
+ assertEquals(TEST_BROADCAST_ID, metadataCopy.getBroadcastId());
+ assertNull(metadataCopy.getBroadcastCode());
+ assertEquals(TEST_PA_SYNC_INTERVAL, metadataCopy.getPaSyncInterval());
+ assertEquals(TEST_PRESENTATION_DELAY_MS, metadataCopy.getPresentationDelayMicros());
+ assertArrayEquals(subgroups,
+ metadataCopy.getSubgroups().toArray(new BluetoothLeBroadcastSubgroup[0]));
+ builder.clearSubgroup();
+ // builder expect at least one subgroup
+ assertThrows(IllegalArgumentException.class, builder::build);
}
private boolean shouldSkipTest() {
return !mHasBluetooth || (!mIsBroadcastSourceSupported && !mIsBroadcastAssistantSupported);
}
+
+ static BluetoothLeBroadcastSubgroup createBroadcastSubgroup() {
+ BluetoothLeAudioCodecConfigMetadata codecMetadata =
+ new BluetoothLeAudioCodecConfigMetadata.Builder()
+ .setAudioLocation(TEST_AUDIO_LOCATION_FRONT_LEFT).build();
+ BluetoothLeAudioContentMetadata contentMetadata =
+ new BluetoothLeAudioContentMetadata.Builder()
+ .setProgramInfo(TEST_PROGRAM_INFO).setLanguage(TEST_LANGUAGE).build();
+ BluetoothLeBroadcastSubgroup.Builder builder = new BluetoothLeBroadcastSubgroup.Builder()
+ .setCodecId(TEST_CODEC_ID)
+ .setCodecSpecificConfig(codecMetadata)
+ .setContentMetadata(contentMetadata)
+ .setNoChannelPreference(true);
+ for (BluetoothLeBroadcastChannel channel : TEST_CHANNELS) {
+ builder.addChannel(channel);
+ }
+ return builder.build();
+ }
+
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastSubgroupTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastSubgroupTest.java
index 3ad73c7..ea72dcd 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastSubgroupTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastSubgroupTest.java
@@ -21,9 +21,12 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothLeAudioCodecConfigMetadata;
+import android.bluetooth.BluetoothLeAudioContentMetadata;
import android.bluetooth.BluetoothLeBroadcastChannel;
import android.bluetooth.BluetoothLeBroadcastSubgroup;
import android.bluetooth.BluetoothProfile;
@@ -47,6 +50,14 @@
private static final int TEST_CODEC_ID = 42;
private static final BluetoothLeBroadcastChannel[] TEST_CHANNELS = {null};
+ // For BluetoothLeAudioCodecConfigMetadata
+ private static final long TEST_AUDIO_LOCATION_FRONT_LEFT = 0x01;
+
+ // For BluetoothLeAudioContentMetadata
+ private static final String TEST_PROGRAM_INFO = "Test";
+ // German language code in ISO 639-3
+ private static final String TEST_LANGUAGE = "deu";
+
private Context mContext;
private boolean mHasBluetooth;
private BluetoothAdapter mAdapter;
@@ -102,18 +113,63 @@
if (shouldSkipTest()) {
return;
}
+ BluetoothLeAudioCodecConfigMetadata codecMetadata =
+ new BluetoothLeAudioCodecConfigMetadata.Builder()
+ .setAudioLocation(TEST_AUDIO_LOCATION_FRONT_LEFT).build();
+ BluetoothLeAudioContentMetadata contentMetadata =
+ new BluetoothLeAudioContentMetadata.Builder()
+ .setProgramInfo(TEST_PROGRAM_INFO).setLanguage(TEST_LANGUAGE).build();
BluetoothLeBroadcastSubgroup.Builder builder = new BluetoothLeBroadcastSubgroup.Builder()
.setCodecId(TEST_CODEC_ID)
- .setCodecSpecificConfig(null)
- .setContentMetadata(null)
+ .setCodecSpecificConfig(codecMetadata)
+ .setContentMetadata(contentMetadata)
.setNoChannelPreference(true);
for (BluetoothLeBroadcastChannel channel : TEST_CHANNELS) {
builder.addChannel(channel);
}
BluetoothLeBroadcastSubgroup subgroup = builder.build();
assertEquals(TEST_CODEC_ID, subgroup.getCodecId());
+ assertEquals(codecMetadata, subgroup.getCodecSpecificConfig());
+ assertEquals(contentMetadata, subgroup.getContentMetadata());
+ assertTrue(subgroup.isNoChannelPreference());
assertArrayEquals(TEST_CHANNELS,
subgroup.getChannels().toArray(new BluetoothLeBroadcastChannel[0]));
+ builder.clearChannel();
+ // builder expect at least one channel
+ assertThrows(IllegalArgumentException.class, builder::build);
+ }
+
+ @Test
+ public void testCreateBroadcastSubgroupFromCopy() {
+ if (shouldSkipTest()) {
+ return;
+ }
+ BluetoothLeAudioCodecConfigMetadata codecMetadata =
+ new BluetoothLeAudioCodecConfigMetadata.Builder()
+ .setAudioLocation(TEST_AUDIO_LOCATION_FRONT_LEFT).build();
+ BluetoothLeAudioContentMetadata contentMetadata =
+ new BluetoothLeAudioContentMetadata.Builder()
+ .setProgramInfo(TEST_PROGRAM_INFO).setLanguage(TEST_LANGUAGE).build();
+ BluetoothLeBroadcastSubgroup.Builder builder = new BluetoothLeBroadcastSubgroup.Builder()
+ .setCodecId(TEST_CODEC_ID)
+ .setCodecSpecificConfig(codecMetadata)
+ .setContentMetadata(contentMetadata)
+ .setNoChannelPreference(true);
+ for (BluetoothLeBroadcastChannel channel : TEST_CHANNELS) {
+ builder.addChannel(channel);
+ }
+ BluetoothLeBroadcastSubgroup subgroup = builder.build();
+ BluetoothLeBroadcastSubgroup subgroupCopy =
+ new BluetoothLeBroadcastSubgroup.Builder(subgroup).build();
+ assertEquals(TEST_CODEC_ID, subgroupCopy.getCodecId());
+ assertEquals(codecMetadata, subgroupCopy.getCodecSpecificConfig());
+ assertEquals(contentMetadata, subgroupCopy.getContentMetadata());
+ assertTrue(subgroupCopy.isNoChannelPreference());
+ assertArrayEquals(TEST_CHANNELS,
+ subgroupCopy.getChannels().toArray(new BluetoothLeBroadcastChannel[0]));
+ builder.clearChannel();
+ // builder expect at least one channel
+ assertThrows(IllegalArgumentException.class, builder::build);
}
private boolean shouldSkipTest() {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
index dfe22d1..5525de6 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
@@ -16,15 +16,20 @@
package android.bluetooth.cts;
+import static android.Manifest.permission.BLUETOOTH_CONNECT;
+
import static org.junit.Assert.assertThrows;
+import android.app.UiAutomation;
import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothSap;
import android.content.pm.PackageManager;
import android.sysprop.BluetoothProperties;
import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.MediumTest;
import android.util.Log;
import androidx.test.InstrumentationRegistry;
@@ -40,6 +45,7 @@
private boolean mHasBluetooth;
private BluetoothAdapter mAdapter;
+ private UiAutomation mUiAutomation;;
private BluetoothSap mBluetoothSap;
private boolean mIsProfileReady;
@@ -59,8 +65,8 @@
mIsSapSupported = BluetoothProperties.isProfileSapServerEnabled().orElse(false);
if (!mIsSapSupported) return;
- InstrumentationRegistry.getInstrumentation().getUiAutomation()
- .adoptShellPermissionIdentity(android.Manifest.permission.BLUETOOTH_CONNECT);
+ mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
+ mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
mAdapter = getContext().getSystemService(BluetoothManager.class).getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
@@ -79,17 +85,64 @@
super.tearDown();
if (mHasBluetooth && mIsSapSupported) {
if (mAdapter != null && mBluetoothSap != null) {
- mBluetoothSap.close();
+ mAdapter.closeProfileProxy(BluetoothProfile.SAP, mBluetoothSap);
+ // mBluetoothSap.close();
mBluetoothSap = null;
mIsProfileReady = false;
}
+ mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
- InstrumentationRegistry.getInstrumentation().getUiAutomation()
- .dropShellPermissionIdentity();
+ mUiAutomation.dropShellPermissionIdentity();
mAdapter = null;
}
}
+ @MediumTest
+ public void test_getConnectedDevices() {
+ if (!mHasBluetooth || !mIsSapSupported) return;
+
+ assertTrue(waitForProfileConnect());
+ assertNotNull(mBluetoothSap);
+
+ assertNotNull(mBluetoothSap.getConnectedDevices());
+
+ mUiAutomation.dropShellPermissionIdentity();
+ assertThrows(SecurityException.class, () -> mBluetoothSap.getConnectedDevices());
+ }
+
+ @MediumTest
+ public void test_getDevicesMatchingConnectionStates() {
+ if (!mHasBluetooth || !mIsSapSupported) return;
+
+ assertTrue(waitForProfileConnect());
+ assertNotNull(mBluetoothSap);
+
+ int[] connectionState = new int[]{BluetoothProfile.STATE_CONNECTED};
+
+ assertTrue(mBluetoothSap.getDevicesMatchingConnectionStates(connectionState).isEmpty());
+
+ mUiAutomation.dropShellPermissionIdentity();
+ assertThrows(SecurityException.class,
+ () -> mBluetoothSap.getDevicesMatchingConnectionStates(connectionState));
+ }
+
+ @MediumTest
+ public void test_getConnectionState() {
+ if (!mHasBluetooth || !mIsSapSupported) return;
+
+ assertTrue(waitForProfileConnect());
+ assertNotNull(mBluetoothSap);
+
+ BluetoothDevice testDevice = mAdapter.getRemoteDevice("00:11:22:AA:BB:CC");
+
+ assertEquals(mBluetoothSap.getConnectionState(testDevice),
+ BluetoothProfile.STATE_DISCONNECTED);
+
+ mUiAutomation.dropShellPermissionIdentity();
+ assertThrows(SecurityException.class, () -> mBluetoothSap.getConnectionState(testDevice));
+ }
+
+ @MediumTest
public void test_setgetConnectionPolicy() {
if (!mHasBluetooth || !mIsSapSupported) return;
@@ -98,6 +151,12 @@
assertThrows(NullPointerException.class, () -> mBluetoothSap.setConnectionPolicy(null, 0));
assertThrows(NullPointerException.class, () -> mBluetoothSap.getConnectionPolicy(null));
+
+ mUiAutomation.dropShellPermissionIdentity();
+ BluetoothDevice testDevice = mAdapter.getRemoteDevice("00:11:22:AA:BB:CC");
+ assertThrows(SecurityException.class, () -> mBluetoothSap.setConnectionPolicy(testDevice,
+ BluetoothProfile.CONNECTION_POLICY_FORBIDDEN));
+ assertThrows(SecurityException.class, () -> mBluetoothSap.getConnectionPolicy(testDevice));
}
private boolean waitForProfileConnect() {
diff --git a/tests/tests/hardware/OWNERS b/tests/tests/hardware/OWNERS
index 8001641..21b257e 100644
--- a/tests/tests/hardware/OWNERS
+++ b/tests/tests/hardware/OWNERS
@@ -8,4 +8,4 @@
# Trust that people only touch their own resources.
per-file *.xml=*
# Only input tests use JSON so far
-per-file *.json=svv@google.com
+per-file *.json=file:platform/frameworks/base:/INPUT_OWNERS
diff --git a/tests/tests/hardware/src/android/hardware/input/OWNERS b/tests/tests/hardware/src/android/hardware/input/OWNERS
index b0a2050..c88bfe9 100644
--- a/tests/tests/hardware/src/android/hardware/input/OWNERS
+++ b/tests/tests/hardware/src/android/hardware/input/OWNERS
@@ -1,4 +1 @@
-# Bug component:136048
-lzye@google.com
-michaelwr@google.com
-svv@google.com
+include platform/frameworks/base:/INPUT_OWNERS
diff --git a/tests/tests/keystore/Android.bp b/tests/tests/keystore/Android.bp
index 931f04e..8b18756 100644
--- a/tests/tests/keystore/Android.bp
+++ b/tests/tests/keystore/Android.bp
@@ -117,3 +117,25 @@
// sdk_version: "test_current",
platform_apis: true,
}
+
+android_test {
+ name: "CtsKeystoreWycheproofTestCases",
+ defaults: ["cts_defaults"],
+ manifest: "CtsKeystoreWycheproofTestManifest.xml",
+ test_config: "CtsKeystoreWycheproofTestConfig.xml",
+ // Tag this module as a cts test artifact
+ test_suites: [
+ "cts",
+ "general-tests",
+ ],
+ libs: [
+ "android.test.base",
+ "android.test.runner",
+ ],
+ static_libs: [
+ "cts-core-test-runner-axt",
+ "wycheproof-keystore",
+ ],
+ // sdk_version: "test_current",
+ platform_apis: true,
+}
diff --git a/tests/tests/keystore/CtsKeystoreWycheproofTestConfig.xml b/tests/tests/keystore/CtsKeystoreWycheproofTestConfig.xml
new file mode 100644
index 0000000..0b09028
--- /dev/null
+++ b/tests/tests/keystore/CtsKeystoreWycheproofTestConfig.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 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 Keystore wycheproof tests">
+ <option name="test-suite-tag" value="cts" />
+ <option name="config-descriptor:metadata" key="component" value="security" />
+ <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+ <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+ <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsKeystoreWycheproofTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.keystore.cts.wycheproof" />
+ <option name="runtime-hint" value="17m" />
+ <option name="test-timeout" value="34m" />
+ <option name="hidden-api-checks" value="false" />
+ <option name="isolated-storage" value="false" />
+ </test>
+</configuration>
diff --git a/tests/tests/keystore/CtsKeystoreWycheproofTestManifest.xml b/tests/tests/keystore/CtsKeystoreWycheproofTestManifest.xml
new file mode 100644
index 0000000..9ef7249
--- /dev/null
+++ b/tests/tests/keystore/CtsKeystoreWycheproofTestManifest.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright 2022 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.keystore.cts.wycheproof">
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.keystore.cts.wycheproof"
+ android:label="CTS tests of android.keystore.cts.wycheproof">
+ <meta-data android:name="listener"
+ android:value="com.android.cts.runner.CtsTestRunListener" />
+ </instrumentation>
+
+</manifest>
+
diff --git a/tests/tests/keystore/src/android/keystore/cts/Curve25519Test.java b/tests/tests/keystore/src/android/keystore/cts/Curve25519Test.java
index 7feecd1..30bd40b 100644
--- a/tests/tests/keystore/src/android/keystore/cts/Curve25519Test.java
+++ b/tests/tests/keystore/src/android/keystore/cts/Curve25519Test.java
@@ -37,6 +37,7 @@
import java.security.NoSuchProviderException;
import java.security.ProviderException;
import java.security.spec.ECGenParameterSpec;
+import java.security.spec.NamedParameterSpec;
@RunWith(AndroidJUnit4.class)
public class Curve25519Test {
@@ -119,4 +120,34 @@
assertThrows(InvalidAlgorithmParameterException.class, () -> kpg.initialize(keySpec));
}
+
+ @Test
+ public void x25519CannotCreateKeyUsingKPGWithNamedParameterSpec()
+ throws NoSuchAlgorithmException, NoSuchProviderException,
+ InvalidAlgorithmParameterException {
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance("XDH", "AndroidKeyStore");
+
+ NamedParameterSpec paramSpec = new NamedParameterSpec("X25519");
+ try {
+ kpg.initialize(paramSpec);
+ fail("Should not be able to generate keys using NamedParameterSpec");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage()).contains("cannot be initialized using NamedParameterSpec");
+ }
+ }
+
+ @Test
+ public void ed25519CannotCreateKeyUsingKPGWithNamedParameterSpec()
+ throws NoSuchAlgorithmException, NoSuchProviderException,
+ InvalidAlgorithmParameterException {
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance("XDH", "AndroidKeyStore");
+
+ NamedParameterSpec paramSpec = new NamedParameterSpec("Ed25519");
+ try {
+ kpg.initialize(paramSpec);
+ fail("Should not be able to generate keys using NamedParameterSpec");
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage()).contains("cannot be initialized using NamedParameterSpec");
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
index d182cfc..d5f919a 100644
--- a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
@@ -80,6 +80,8 @@
import androidx.test.filters.RequiresDevice;
import androidx.test.runner.AndroidJUnit4;
+import com.android.compatibility.common.util.CddTest;
+
import com.google.common.collect.ImmutableSet;
import org.bouncycastle.asn1.x500.X500Name;
@@ -726,6 +728,7 @@
testDeviceIdAttestationFailure(AttestationUtils.ID_TYPE_MEID, "Unable to retrieve MEID");
}
+ @CddTest(requirement="9.11.4")
@Test
public void testMandatoryDeviceidAttestation() {
// ID attestation is only mandatory on devices that have shipped with T and
diff --git a/tests/tests/keystore/src/android/keystore/cts/KeyFactoryTest.java b/tests/tests/keystore/src/android/keystore/cts/KeyFactoryTest.java
index 98cb2c3..8c6759d 100644
--- a/tests/tests/keystore/src/android/keystore/cts/KeyFactoryTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/KeyFactoryTest.java
@@ -22,8 +22,8 @@
import static org.junit.Assert.fail;
import android.content.Context;
-import android.keystore.cts.util.TestUtils;
import android.keystore.cts.R;
+import android.keystore.cts.util.TestUtils;
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyInfo;
import android.security.keystore.KeyProperties;
@@ -32,6 +32,9 @@
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
@@ -41,6 +44,8 @@
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.Provider;
+import java.security.Provider.Service;
+import java.security.PublicKey;
import java.security.Security;
import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPublicKey;
@@ -52,8 +57,6 @@
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.security.spec.X509EncodedKeySpec;
-import java.security.Provider.Service;
-import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -65,9 +68,6 @@
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
@RunWith(AndroidJUnit4.class)
public class KeyFactoryTest {
private static final String EXPECTED_PROVIDER_NAME = TestUtils.EXPECTED_PROVIDER_NAME;
@@ -94,6 +94,9 @@
Set<String> actualAlgsLowerCase = new HashSet<String>();
Set<String> expectedAlgsLowerCase = new HashSet<String>(
Arrays.asList(TestUtils.toLowerCase(EXPECTED_ALGORITHMS)));
+ // XDH is also a supported algorithm, but not available for other tests as the keys
+ // generated with it have more limited set of uses.
+ expectedAlgsLowerCase.add("xdh");
for (Service service : services) {
if ("KeyFactory".equalsIgnoreCase(service.getType())) {
String algLowerCase = service.getAlgorithm().toLowerCase(Locale.US);
diff --git a/tests/tests/media/codec/src/android/media/codec/cts/ExtractDecodeEditEncodeMuxTest.java b/tests/tests/media/codec/src/android/media/codec/cts/ExtractDecodeEditEncodeMuxTest.java
index eec4568..b2fbc6c 100644
--- a/tests/tests/media/codec/src/android/media/codec/cts/ExtractDecodeEditEncodeMuxTest.java
+++ b/tests/tests/media/codec/src/android/media/codec/cts/ExtractDecodeEditEncodeMuxTest.java
@@ -524,8 +524,11 @@
int expectedSampleRate = OUTPUT_AUDIO_SAMPLE_RATE_HZ;
// SBR mode halves the sample rate in the format.
- if (OUTPUT_AUDIO_AAC_PROFILE ==
- MediaCodecInfo.CodecProfileLevel.AACObjectHE) {
+ // Query output profile. KEY_PROFILE gets precedence over KEY_AAC_PROFILE
+ int aac_profile = trackFormat.getInteger(MediaFormat.KEY_AAC_PROFILE, -1);
+ int profile = trackFormat.getInteger(MediaFormat.KEY_PROFILE, aac_profile);
+
+ if (profile == MediaCodecInfo.CodecProfileLevel.AACObjectHE) {
expectedSampleRate /= 2;
}
assertEquals("sample rates should match", expectedSampleRate,
diff --git a/tests/tests/media/codec/src/android/media/codec/cts/VideoCodecTestBase.java b/tests/tests/media/codec/src/android/media/codec/cts/VideoCodecTestBase.java
index a15249c..b4d4b31 100644
--- a/tests/tests/media/codec/src/android/media/codec/cts/VideoCodecTestBase.java
+++ b/tests/tests/media/codec/src/android/media/codec/cts/VideoCodecTestBase.java
@@ -344,6 +344,7 @@
params.runInLooperThread = true;
}
outputParameters.add(params);
+ params.encodingStatisticsLevel = MediaFormat.VIDEO_ENCODING_STATISTICS_LEVEL_NONE;
}
return outputParameters;
}
diff --git a/tests/tests/media/codec/src/android/media/codec/cts/VideoEncodingStatisticsTest.java b/tests/tests/media/codec/src/android/media/codec/cts/VideoEncodingStatisticsTest.java
index 10a18dd..ff38e6c 100644
--- a/tests/tests/media/codec/src/android/media/codec/cts/VideoEncodingStatisticsTest.java
+++ b/tests/tests/media/codec/src/android/media/codec/cts/VideoEncodingStatisticsTest.java
@@ -193,7 +193,7 @@
}
double differenceBitrate = TEST_BITRATES_SET[i] - TEST_BITRATES_SET[j];
double differenceAvgQp = avgSeqQp[i] - avgSeqQp[j];
- if (differenceBitrate * differenceAvgQp > 0) {
+ if (differenceBitrate * differenceAvgQp >= 0) {
throw new RuntimeException("Target bitrates: " +
TEST_BITRATES_SET[j] + ", " + TEST_BITRATES_SET[i] +
". Average QP: "
diff --git a/tests/tests/media/drmframework/AndroidTest.xml b/tests/tests/media/drmframework/AndroidTest.xml
index f6c5638..fc7b670 100644
--- a/tests/tests/media/drmframework/AndroidTest.xml
+++ b/tests/tests/media/drmframework/AndroidTest.xml
@@ -34,10 +34,6 @@
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsMediaDrmFrameworkTestCases.apk" />
</target_preparer>
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <!-- MediaProjectionTest needs this one to not be granted, SuiteApkInstaller grants all of them by default.-->
- <option name="run-command" value="pm revoke android.media.drmframework.cts android.permission.SYSTEM_ALERT_WINDOW"/>
- </target_preparer>
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher">
<option name="target" value="device" />
<option name="config-filename" value="CtsMediaDrmFrameworkTestCases" />
diff --git a/tests/tests/media/extractor/AndroidTest.xml b/tests/tests/media/extractor/AndroidTest.xml
index 09c79fc..007a65b 100644
--- a/tests/tests/media/extractor/AndroidTest.xml
+++ b/tests/tests/media/extractor/AndroidTest.xml
@@ -47,10 +47,6 @@
<option name="config-filename" value="CtsMediaExtractorTestCases" />
<option name="version" value="1.0"/>
</target_preparer>
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <!-- MediaProjectionTest needs this one to not be granted, SuiteApkInstaller grants all of them by default.-->
- <option name="run-command" value="pm revoke android.media.extractor.cts android.permission.SYSTEM_ALERT_WINDOW"/>
- </target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.media.extractor.cts" />
<!-- setup can be expensive so limit the number of shards -->
diff --git a/tests/tests/media/muxer/AndroidTest.xml b/tests/tests/media/muxer/AndroidTest.xml
index aa4110b..502f2ca 100644
--- a/tests/tests/media/muxer/AndroidTest.xml
+++ b/tests/tests/media/muxer/AndroidTest.xml
@@ -47,10 +47,6 @@
<option name="config-filename" value="CtsMediaMuxerTestCases" />
<option name="version" value="1.0"/>
</target_preparer>
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <!-- MediaProjectionTest needs this one to not be granted, SuiteApkInstaller grants all of them by default.-->
- <option name="run-command" value="pm revoke android.media.muxer.cts android.permission.SYSTEM_ALERT_WINDOW"/>
- </target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.media.muxer.cts" />
<!-- setup can be expensive so limit the number of shards -->
diff --git a/tests/tests/media/player/AndroidTest.xml b/tests/tests/media/player/AndroidTest.xml
index 7b92b12..e3e8b02 100644
--- a/tests/tests/media/player/AndroidTest.xml
+++ b/tests/tests/media/player/AndroidTest.xml
@@ -47,10 +47,6 @@
<option name="config-filename" value="CtsMediaPlayerTestCases" />
<option name="version" value="1.0"/>
</target_preparer>
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <!-- MediaProjectionTest needs this one to not be granted, SuiteApkInstaller grants all of them by default.-->
- <option name="run-command" value="pm revoke android.media.player.cts android.permission.SYSTEM_ALERT_WINDOW"/>
- </target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.media.player.cts" />
<!-- setup can be expensive so limit the number of shards -->
diff --git a/tests/tests/os/UffdGc/jni/android_os_cts_uffdgc_UserfaultfdTest.cc b/tests/tests/os/UffdGc/jni/android_os_cts_uffdgc_UserfaultfdTest.cc
index a35ff16..8c17a72f 100644
--- a/tests/tests/os/UffdGc/jni/android_os_cts_uffdgc_UserfaultfdTest.cc
+++ b/tests/tests/os/UffdGc/jni/android_os_cts_uffdgc_UserfaultfdTest.cc
@@ -23,13 +23,17 @@
#include <poll.h>
#include <pthread.h>
#include <stdio.h>
+#include <string.h>
#include <syscall.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/utsname.h>
+#include <sys/xattr.h>
#include <unistd.h>
+#define SELINUX_CTXT_LEN 255
+
static void* userfault_handler_thread(void* arg) {
struct uffd_msg msg;
struct uffdio_copy uffdio_copy;
@@ -95,6 +99,17 @@
pthread_exit(reinterpret_cast<void*>(ret));
}
+int64_t uffd_api_ioctl(int fd, uint64_t features) {
+ struct uffdio_api api;
+ std::memset(&api, '\0', sizeof api);
+ api.api = UFFD_API;
+ api.features = features;
+ if (ioctl(fd, UFFDIO_API, &api) < 0) {
+ return -1;
+ }
+ return api.features;
+}
+
extern "C"
JNIEXPORT bool JNICALL Java_android_os_cts_uffdgc_UserfaultfdTest_confirmKernelVersion(JNIEnv*) {
#if defined(__linux__)
@@ -150,10 +165,7 @@
goto out_close_both;
}
- struct uffdio_api api;
- std::memset(&api, '\0', sizeof api);
- api.api = UFFD_API;
- if (ioctl(uffd, UFFDIO_API, &api) < 0) {
+ if (uffd_api_ioctl(uffd, /*features*/ 0) == -1) {
ret = errno;
goto out_unmap;
}
@@ -227,25 +239,51 @@
extern "C"
JNIEXPORT jint JNICALL Java_android_os_cts_uffdgc_UserfaultfdTest_performMinorUffd(JNIEnv*) {
- uint64_t req_features;
+ uint64_t req_features = UFFD_FEATURE_MINOR_SHMEM;
+ int64_t available_features = 0;
int ret = 0;
int uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY);
if (uffd < 0) {
ret = errno;
goto out;
}
- struct uffdio_api api;
- std::memset(&api, '\0', sizeof api);
- api.api = UFFD_API;
- req_features = UFFD_FEATURE_MINOR_SHMEM;
- api.features = req_features;
- if (ioctl(uffd, UFFDIO_API, &api) < 0) {
+ available_features = uffd_api_ioctl(uffd, req_features);
+ if (available_features == -1) {
ret = errno;
+ } else if ((available_features & req_features) != req_features) {
+ // Minor feature is not supported by this kernel.
+ ret = EINVAL;
}
- // Minor feature is not supported by this kernel.
- if ((api.features & req_features) != req_features) {
- ret = -EINVAL;
+ close(uffd);
+out:
+ return ret;
+}
+
+extern "C"
+JNIEXPORT jint JNICALL Java_android_os_cts_uffdgc_UserfaultfdTest_checkGetattr(JNIEnv*) {
+ ssize_t attr_ret = 0;
+ char selinux_ctxt[SELINUX_CTXT_LEN + 1];
+ int ret = 0;
+ int uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK | UFFD_USER_MODE_ONLY);
+ if (uffd < 0) {
+ ret = errno;
+ goto out;
}
+ if (uffd_api_ioctl(uffd, /*features*/ 0) == -1) {
+ ret = errno;
+ goto out_close;
+ }
+ attr_ret = fgetxattr(uffd, XATTR_NAME_SELINUX, selinux_ctxt, SELINUX_CTXT_LEN);
+ if (attr_ret == -1) {
+ ret = errno;
+ goto out_close;
+ }
+ // We should never reach here as the call to fgetxattr must return EACCES.
+ selinux_ctxt[attr_ret] = 0;
+ if (strstr(selinux_ctxt, "userfaultfd") == nullptr) {
+ ret = -1;
+ }
+out_close:
close(uffd);
out:
return ret;
diff --git a/tests/tests/os/UffdGc/src/android/os/cts/uffdgc/UserfaultfdTest.java b/tests/tests/os/UffdGc/src/android/os/cts/uffdgc/UserfaultfdTest.java
index b537489..5291752 100644
--- a/tests/tests/os/UffdGc/src/android/os/cts/uffdgc/UserfaultfdTest.java
+++ b/tests/tests/os/UffdGc/src/android/os/cts/uffdgc/UserfaultfdTest.java
@@ -74,9 +74,18 @@
assertEquals(0, performMinorUffd());
}
+ // Confirms if userfaultfd is controlled by selinux or not.
+ // We don't allow getattr operation in our selinux policy.
+ @Test
+ public void selinuxEnabled() {
+ // Expect the return value to be EACCES (13).
+ assertEquals(13, checkGetattr());
+ }
+
private native boolean confirmKernelVersion();
private native int performKernelSpaceUffd();
private native int uffdWithoutUserModeOnly();
private native int performMremapDontUnmap();
private native int performMinorUffd();
+ private native int checkGetattr();
}
diff --git a/tests/tests/os/src/android/os/cts/BundleTest.java b/tests/tests/os/src/android/os/cts/BundleTest.java
index 27d5643..380cf23 100644
--- a/tests/tests/os/src/android/os/cts/BundleTest.java
+++ b/tests/tests/os/src/android/os/cts/BundleTest.java
@@ -671,6 +671,28 @@
}
@Test
+ public void testGetParcelableArrayListTypeSafe_withMismatchingTypeAndDifferentReturnType_returnsNull() {
+ final ArrayList<CustomParcelable> originalObjects = new ArrayList<>();
+ originalObjects.add(new CustomParcelable(42, "don't panic"));
+ mBundle.putParcelableArrayList(KEY1, originalObjects);
+ roundtrip();
+ ArrayList<Parcelable> result = mBundle.getParcelableArrayList(KEY1, Intent.class);
+ assertNull(result);
+ assertFalse(CustomParcelable.sDeserialized);
+ }
+
+ @Test
+ public void testGetParcelableArrayListTypeSafe_withMatchingTypeAndDifferentReturnType__returnsObject() {
+ final ArrayList<CustomParcelable> original = new ArrayList<>();
+ original.add(new CustomParcelable(42, "don't panic"));
+ original.add(new CustomParcelable(1961, "off we go"));
+ mBundle.putParcelableArrayList(KEY1, original);
+ roundtrip();
+ ArrayList<Parcelable> result = mBundle.getParcelableArrayList(KEY1, CustomParcelable.class);
+ assertEquals(original, result);
+ }
+
+ @Test
public void testGetParcelableArrayListTypeSafe_withBaseType_returnsObject() {
final ArrayList<CustomParcelable> original = new ArrayList<>();
original.add(new CustomParcelable(42, "don't panic"));
@@ -826,6 +848,29 @@
}
@Test
+ public void testGetSparseParcelableArrayTypeSafe_withMismatchingTypeAndDifferentReturnType_returnsNull() {
+ final SparseArray<CustomParcelable> originalObjects = new SparseArray<>();
+ originalObjects.put(42, new CustomParcelable(42, "don't panic"));
+ mBundle.putSparseParcelableArray(KEY1, originalObjects);
+ roundtrip();
+ SparseArray<Parcelable> result = mBundle.getSparseParcelableArray(KEY1, Intent.class);
+ assertNull(result);
+ assertFalse(CustomParcelable.sDeserialized);
+ }
+
+ @Test
+ public void testGetSparseParcelableArrayTypeSafe_withMatchingTypeAndDifferentReturnType_returnsObject() {
+ final SparseArray<CustomParcelable> original = new SparseArray<>();
+ original.put(42, new CustomParcelable(42, "don't panic"));
+ original.put(1961, new CustomParcelable(1961, "off we go"));
+ mBundle.putSparseParcelableArray(KEY1, original);
+ roundtrip();
+ SparseArray<Parcelable> result = mBundle.getSparseParcelableArray(KEY1,
+ CustomParcelable.class);
+ assertTrue(original.contentEquals(result));
+ }
+
+ @Test
public void testGetSparseParcelableArrayTypeSafe_withBaseType_returnsObject() {
final SparseArray<CustomParcelable> original = new SparseArray<>();
original.put(42, new CustomParcelable(42, "don't panic"));
diff --git a/tests/tests/secure_element/omapi/apk/signed-CtsOmapiTestCases.apk b/tests/tests/secure_element/omapi/apk/signed-CtsOmapiTestCases.apk
index 53275fd..a53bf88 100644
--- a/tests/tests/secure_element/omapi/apk/signed-CtsOmapiTestCases.apk
+++ b/tests/tests/secure_element/omapi/apk/signed-CtsOmapiTestCases.apk
Binary files differ
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/ApnSettingTest.java b/tests/tests/telephony/current/src/android/telephony/cts/ApnSettingTest.java
index 1be3eb8..bb25a89 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/ApnSettingTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/ApnSettingTest.java
@@ -42,6 +42,8 @@
EXPECTED_STRING_TO_INT_MAP.put(ApnSetting.TYPE_EMERGENCY_STRING, ApnSetting.TYPE_EMERGENCY);
EXPECTED_STRING_TO_INT_MAP.put(ApnSetting.TYPE_MCX_STRING, ApnSetting.TYPE_MCX);
EXPECTED_STRING_TO_INT_MAP.put(ApnSetting.TYPE_XCAP_STRING, ApnSetting.TYPE_XCAP);
+ EXPECTED_STRING_TO_INT_MAP.put(ApnSetting.TYPE_ENTERPRISE_STRING,
+ ApnSetting.TYPE_ENTERPRISE);
EXPECTED_INT_TO_STRING_MAP = new ArrayMap<>();
EXPECTED_INT_TO_STRING_MAP.put(ApnSetting.TYPE_DEFAULT, ApnSetting.TYPE_DEFAULT_STRING);
@@ -56,6 +58,8 @@
EXPECTED_INT_TO_STRING_MAP.put(ApnSetting.TYPE_EMERGENCY, ApnSetting.TYPE_EMERGENCY_STRING);
EXPECTED_INT_TO_STRING_MAP.put(ApnSetting.TYPE_MCX, ApnSetting.TYPE_MCX_STRING);
EXPECTED_INT_TO_STRING_MAP.put(ApnSetting.TYPE_XCAP, ApnSetting.TYPE_XCAP_STRING);
+ EXPECTED_INT_TO_STRING_MAP.put(ApnSetting.TYPE_ENTERPRISE,
+ ApnSetting.TYPE_ENTERPRISE_STRING);
}
@Test
diff --git a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java
index 01361ff..3495b66 100644
--- a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java
@@ -1472,14 +1472,8 @@
ImsException.class);
// IMS registers
- ArraySet<String> featureTags = new ArraySet<>();
- // Chat Session
- featureTags.add(CHAT_FEATURE_TAG);
- featureTags.add(FILE_TRANSFER_FEATURE_TAG);
- ImsRegistrationAttributes attr = new ImsRegistrationAttributes.Builder(
- IMS_REGI_TECH_LTE).setFeatureTags(featureTags).build();
- sServiceConnector.getCarrierService().getImsRegistration().onRegistered(attr);
- waitForParam(mQueue, attr);
+ sServiceConnector.getCarrierService().getImsRegistration().onRegistered(
+ IMS_REGI_TECH_LTE);
// Notify framework that the RCS capability status is changed and PRESENCE UCE is enabled.
RcsImsCapabilities capabilities =
@@ -1502,6 +1496,20 @@
assertEquals(RcsUceAdapter.PUBLISH_STATE_OK, waitForIntResult(publishStateQueue));
publishStateQueue.clear();
+ // IMS registers
+ ArraySet<String> featureTags = new ArraySet<>();
+ // Chat Session
+ featureTags.add(CHAT_FEATURE_TAG);
+ featureTags.add(FILE_TRANSFER_FEATURE_TAG);
+ ImsRegistrationAttributes attr = new ImsRegistrationAttributes.Builder(
+ IMS_REGI_TECH_LTE).setFeatureTags(featureTags).build();
+ sServiceConnector.getCarrierService().getImsRegistration().onRegistered(attr);
+ waitForParam(mQueue, attr);
+
+ assertEquals(RcsUceAdapter.PUBLISH_STATE_PUBLISHING, waitForIntResult(publishStateQueue));
+ assertEquals(RcsUceAdapter.PUBLISH_STATE_OK, waitForIntResult(publishStateQueue));
+ publishStateQueue.clear();
+
// Can not verify the pidf fully, but we can ensure that the service id for the feature is
// contained in the XML. Multible PUBLISH requests may occur based on the state of the stack
// at the time of this call, retry to get correct PIDF up to 5 times.
diff --git a/tests/tests/view/src/android/view/cts/input/OWNERS b/tests/tests/view/src/android/view/cts/input/OWNERS
index 50445ea..c88bfe9 100644
--- a/tests/tests/view/src/android/view/cts/input/OWNERS
+++ b/tests/tests/view/src/android/view/cts/input/OWNERS
@@ -1,4 +1 @@
-# Bug component: 136048
-lzye@google.com
-michaelwr@google.com
-svv@google.com
\ No newline at end of file
+include platform/frameworks/base:/INPUT_OWNERS
diff --git a/tools/cts-tradefed/res/config/csi-known-failures.xml b/tools/cts-tradefed/res/config/csi-known-failures.xml
index bbb98b7..86c8fe6 100644
--- a/tools/cts-tradefed/res/config/csi-known-failures.xml
+++ b/tools/cts-tradefed/res/config/csi-known-failures.xml
@@ -32,84 +32,38 @@
<option name="compatibility:exclude-filter" value="CtsStatsdHostTestCases android.cts.statsd.atom.UidAtomTests#testAppCrashOccurred" />
<option name="compatibility:exclude-filter" value="CtsUiRenderingTestCases android.uirendering.cts.testclasses.SurfaceViewTests#testMovingWhiteSurfaceView" />
- <!-- Exclude known failure of CtsMediaTestCases (mostly on some Pixel phones) -->
+ <!-- Exclude known failure of CtsMedia*TestCases (mostly on some Pixel phones) -->
<!-- CSI doesn't seem to include ringtones. -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.RingtoneManagerTest" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.RingtoneTest" />
+ <option name="compatibility:exclude-filter" value="CtsMediaAudioTestCases android.media.audio.cts.RingtoneManagerTest" />
+ <option name="compatibility:exclude-filter" value="CtsMediaAudioTestCases android.media.audio.cts.RingtoneTest" />
<!-- Following failures take about 10 min each, so exclude them to reduce test time. -->
<!-- CSI on Goldfish can pass the following tests in StreamingMediaPlayerTest. -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.StreamingMediaPlayerTest#testHTTP_H263_AMR_Video2" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.StreamingMediaPlayerTest#testHTTP_H264Base_AAC_Video2" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.StreamingMediaPlayerTest#testHTTP_MPEG4SP_AAC_Video2" />
+ <option name="compatibility:exclude-filter" value="CtsMediaPlayerTestCases android.media.cts.player.StreamingMediaPlayerTest#testHTTP_H263_AMR_Video2" />
+ <option name="compatibility:exclude-filter" value="CtsMediaPlayerTestCases android.media.cts.player.StreamingMediaPlayerTest#testHTTP_H264Base_AAC_Video2" />
+ <option name="compatibility:exclude-filter" value="CtsMediaPlayerTestCases android.media.cts.player.StreamingMediaPlayerTest#testHTTP_MPEG4SP_AAC_Video2" />
<!-- CSI on Cuttlefish and Goldfish can pass the following tests in VideoCodecTest. -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoCodecTest#testParallelEncodingAndDecodingAVC" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoCodecTest#testParallelEncodingAndDecodingHEVC" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoCodecTest#testParallelEncodingAndDecodingVP8" />
+ <option name="compatibility:exclude-filter" value="CtsMediaCodecTestCases android.media.codec.cts.VideoCodecTest#testParallelEncodingAndDecoding" />
<!-- Failures will crash the test harness, so exclude it here (even though only failed with VP9 decoder). -->
<!-- CSI on Cuttlefish and Goldfish can pass the following tests in VideoDecoderRotationTest. -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderRotationTest" />
+ <option name="compatibility:exclude-filter" value="CtsMediaCodecTestCases android.media.codec.cts.VideoDecoderRotationTest" />
<!-- CSI on Cuttlefish and Goldfish can pass the following tests in VideoDecoderPerfTest. -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther0Perf0320x0240" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther0Perf0720x0480" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther0Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther1Perf0320x0240" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther1Perf0720x0480" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther1Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testAvcOther1Perf1920x1080" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf0352x0288" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf0640x0360" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf0720x0480" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther0Perf1920x1080" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf0352x0288" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf0640x0360" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf0720x0480" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf1280x0720" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf1920x1080" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoDecoderPerfTest#testHevcOther1Perf3840x2160" />
+ <option name="compatibility:exclude-filter" value="CtsMediaDecoderTestCases android.media.decoder.cts.VideoDecoderPerfTest#testPerf" />
<!-- CSI on Cuttlefish and Goldfish can pass the following tests in VideoEncoderTest. -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH263SurfMinMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfArbitraryH" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfArbitraryW" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfNearMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfNearMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfNearMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH265SurfQCIF" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfArbitraryH" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfArbitraryW" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfNearMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfNearMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfNearMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogMpeg4SurfNearMinMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8Surf480p" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfArbitraryH" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfArbitraryW" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfNearMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfNearMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfNearMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP8SurfQCIF" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9Surf480p" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfArbitraryH" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfArbitraryW" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfNearMaxMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfNearMaxMin" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfNearMinMax" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogVP9SurfQCIF" />
-
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfMinMin" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfArbitraryH" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfArbitraryW" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfMaxMax" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfMaxMin" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfMinMax" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfNearMaxMax" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfNearMaxMin" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfNearMinMax" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfQCIF" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurfNearMinMin" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases android.media.encoder.cts.VideoEncoderTest#testSurf480p" />
</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-meerkat.xml b/tools/cts-tradefed/res/config/cts-meerkat.xml
index 6bc6b30..31aed81 100644
--- a/tools/cts-tradefed/res/config/cts-meerkat.xml
+++ b/tools/cts-tradefed/res/config/cts-meerkat.xml
@@ -39,7 +39,7 @@
<!-- System Alert Window (SAW) -->
<option name="compatibility:include-filter" value="CtsSystemIntentTestCases"/>
<option name="compatibility:include-filter" value="CtsWindowManagerDeviceTestCases android.server.wm.HideOverlayWindowsTest"/>
- <option name="compatibility:include-filter" value="CtsMediaTestCases android.media.cts.MediaProjectionTest"/>
+ <option name="compatibility:include-filter" value="CtsMediaMiscTestCases android.media.misc.cts.MediaProjectionTest"/>
<!-- Toasts -->
<option name="compatibility:include-filter" value="CtsWindowManagerDeviceTestCases android.server.wm.ToastWindowTest"/>
diff --git a/tools/cts-tradefed/res/config/cts-on-aosp-exclude.xml b/tools/cts-tradefed/res/config/cts-on-aosp-exclude.xml
index d220e8f..bd4153b 100644
--- a/tools/cts-tradefed/res/config/cts-on-aosp-exclude.xml
+++ b/tools/cts-tradefed/res/config/cts-on-aosp-exclude.xml
@@ -61,10 +61,10 @@
<option name="compatibility:exclude-filter" value="CtsAppTestCases android.app.cts.ActivityKeyboardShortcutsTest#testRequestShowKeyboardShortcuts" />
<!-- b/161837932: Fix MediaPlayerTests that use "too small" resolution -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerTest#testOnSubtitleDataListener" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerTest#testChangeSubtitleTrack" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerTest#testDeselectTrackForSubtitleTracks" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaPlayerTest#testGetTrackInfoForVideoWithSubtitleTracks" />
+ <option name="compatibility:exclude-filter" value="CtsMediaPlayerTestCases android.media.player.cts.MediaPlayerTest#testOnSubtitleDataListener" />
+ <option name="compatibility:exclude-filter" value="CtsMediaPlayerTestCases android.media.player.cts.MediaPlayerTest#testChangeSubtitleTrack" />
+ <option name="compatibility:exclude-filter" value="CtsMediaPlayerTestCases android.media.player.cts.MediaPlayerTest#testDeselectTrackForSubtitleTracks" />
+ <option name="compatibility:exclude-filter" value="CtsMediaPlayerTestCases android.media.player.cts.MediaPlayerTest#testGetTrackInfoForVideoWithSubtitleTracks" />
<!-- b/152359655: ResumeOnReboot can't work on GSI -->
<option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.ResumeOnRebootHostTest" />
diff --git a/tools/cts-tradefed/res/config/cts-on-csi-cf.xml b/tools/cts-tradefed/res/config/cts-on-csi-cf.xml
index c810f2d..6d55fe2 100644
--- a/tools/cts-tradefed/res/config/cts-on-csi-cf.xml
+++ b/tools/cts-tradefed/res/config/cts-on-csi-cf.xml
@@ -41,8 +41,16 @@
<option name="compatibility:exclude-filter" value="CtsKeystoreTestCases" />
<option name="compatibility:exclude-filter" value="CtsMediaBitstreamsTestCases" />
<option name="compatibility:exclude-filter" value="CtsMediaStressTestCases" />
- <option name="compatibility:exclude-filter" value="CtsMediaDrmTestCases" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaAudioTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaCodecTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaDecoderTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaDrmFrameworkTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaEncoderTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaExtractorTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaMiscTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaMuxerTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaPlayerTestCases" />
+ <option name="compatibility:exclude-filter" value="CtsMediaRecorderTestCases" />
<option name="compatibility:exclude-filter" value="CtsMediaV2TestCases" />
<option name="compatibility:exclude-filter" value="CtsNativeHardwareTestCases" />
<option name="compatibility:exclude-filter" value="CtsOpenGLTestCases" />
diff --git a/tools/cts-tradefed/res/config/cts-on-csi-no-apks.xml b/tools/cts-tradefed/res/config/cts-on-csi-no-apks.xml
index a99c656..dc93565 100644
--- a/tools/cts-tradefed/res/config/cts-on-csi-no-apks.xml
+++ b/tools/cts-tradefed/res/config/cts-on-csi-no-apks.xml
@@ -159,8 +159,8 @@
<option name="compatibility:exclude-filter" value="CtsContentTestCases android.content.cts.AvailableIntentsTest#testManageStorage" />
<!-- No SystemUI -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.AudioPlaybackCaptureTest" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.MediaProjectionTest" />
+ <option name="compatibility:exclude-filter" value="CtsMediaAudioTestCases android.media.audio.cts.AudioPlaybackCaptureTest" />
+ <option name="compatibility:exclude-filter" value="CtsMediaMiscTestCases android.media.misc.cts.MediaProjectionTest" />
<option name="compatibility:exclude-filter" value="CtsPermission3TestCases android.permission3.cts.PermissionTest22#testCompatRevoked" />
<option name="compatibility:exclude-filter" value="CtsPermission3TestCases android.permission3.cts.PermissionTest23#testGranted" />
<option name="compatibility:exclude-filter" value="CtsPermission3TestCases android.permission3.cts.PermissionTest23#testRevokeAffectsWholeGroup" />
diff --git a/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java b/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java
index 673d93c..ced6aaf 100644
--- a/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java
+++ b/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ApkPackageNameCheck.java
@@ -30,13 +30,13 @@
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.testtype.InstrumentationTest;
import com.android.tradefed.util.AaptParser;
+import com.android.tradefed.util.FileUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.File;
-import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -69,20 +69,12 @@
fail(String.format("%s does not exists", testcases));
return;
}
- File[] listConfig = testcases.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- if (name.endsWith(".config")) {
- return true;
- }
- return false;
- }
- });
- assertTrue(listConfig.length > 0);
+ Set<File> listConfigs = FileUtil.findFilesObject(testcases, ".*\\.config");
+ assertTrue(listConfigs.size() > 0);
// We check all apk installed by all modules
Map<String, String> packageNames = new HashMap<>();
- for (File config : listConfig) {
+ for (File config : listConfigs) {
IConfiguration c = ConfigurationFactory.getInstance()
.createConfigurationFromArgs(new String[] {config.getAbsolutePath()});
// For each config, we check all the apk it's going to install
@@ -97,15 +89,17 @@
if (prep instanceof FilePusher && ((FilePusher) prep).shouldAppendBitness()) {
for (File f : ((PushFilePreparer) prep).getPushSpecs(null).values()) {
String path = f.getPath();
- if (!new File(testcases, path + "32").exists()
- || !new File(testcases, path + "64").exists()) {
+ File file32 = FileUtil.findFile(config.getParentFile(), path + "32");
+ File file64 = FileUtil.findFile(config.getParentFile(), path + "64");
+ if (file32 == null || file64 == null) {
// TODO: Enforce should abort on failure is True in CTS
if (((FilePusher) prep).shouldAbortOnFailure()) {
fail(
String.format(
- "File %s[32/64] wasn't found in testcases/ while "
- + "it's expected to be pushed as part of "
- + "%s",
+ "File %s[32/64] wasn't found in module "
+ + "dependencies while "
+ + "it's expected to be pushed as part"
+ + " of %s.",
path, config.getName()));
}
}
@@ -113,24 +107,27 @@
} else if (prep instanceof PushFilePreparer) {
for (File f : ((PushFilePreparer) prep).getPushSpecs(null).values()) {
String path = f.getPath();
- if (!new File(testcases, path).exists()) {
+ File toBePushed = FileUtil.findFile(config.getParentFile(), path);
+ if (toBePushed == null) {
// TODO: Enforce should abort on failure is True in CTS
if (((PushFilePreparer) prep).shouldAbortOnFailure()) {
fail(
String.format(
- "File %s wasn't found in testcases/ while it's "
- + "expected to be pushed as part of %s",
+ "File %s wasn't found in module dependencies "
+ + "while it's expected to be pushed "
+ + "as part of %s.",
path, config.getName()));
}
}
}
}
}
-
+
+ // All apks need to be in the config dir or sub-dir
for (File apk : apkNames) {
String apkName = apk.getName();
- File apkFile = new File(testcases, apkName);
- if (!apkFile.exists()) {
+ File apkFile = FileUtil.findFile(config.getParentFile(), apkName);
+ if (apkFile == null || !apkFile.exists()) {
fail(String.format("Module %s is trying to install %s which does not "
+ "exists in testcases/", config.getName(), apkFile));
}
diff --git a/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java b/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
index 0a392fd..7b6e0d1 100644
--- a/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
+++ b/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/CtsConfigLoadingTest.java
@@ -40,6 +40,7 @@
import com.android.tradefed.testtype.ITestFilterReceiver;
import com.android.tradefed.testtype.suite.ITestSuite;
import com.android.tradefed.testtype.suite.params.ModuleParameters;
+import com.android.tradefed.util.FileUtil;
import org.junit.Assert;
import org.junit.Test;
@@ -47,7 +48,6 @@
import org.junit.runners.JUnit4;
import java.io.File;
-import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -193,16 +193,8 @@
fail(String.format("%s does not exists", testcases));
return;
}
- File[] listConfig = testcases.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- if (name.endsWith(".config")) {
- return true;
- }
- return false;
- }
- });
- assertTrue(listConfig.length > 0);
+ Set<File> listConfigs = FileUtil.findFilesObject(testcases, ".*\\.config");
+ assertTrue(listConfigs.size() > 0);
// Create a FolderBuildInfo to similate the CompatibilityBuildProvider
FolderBuildInfo stubFolder = new FolderBuildInfo("-1", "-1");
stubFolder.setRootDir(new File(ctsRoot));
@@ -213,7 +205,7 @@
List<String> missingMandatoryParameters = new ArrayList<>();
// We expect to be able to load every single config in testcases/
- for (File config : listConfig) {
+ for (File config : listConfigs) {
IConfiguration c = ConfigurationFactory.getInstance()
.createConfigurationFromArgs(new String[] {config.getAbsolutePath()});
if (c.getDeviceConfig().size() > 2) {
diff --git a/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java b/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java
index 97ee339..94a65bf 100644
--- a/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java
+++ b/tools/cts-tradefed/tests/src/com/android/compatibility/common/tradefed/presubmit/ValidateTestsAbi.java
@@ -29,18 +29,17 @@
import org.junit.runners.JUnit4;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.Set;
+import java.util.stream.Collectors;
/**
* Tests to validate that the build is containing usable test artifact.
@@ -83,23 +82,31 @@
* and embed native libraries.
*/
APK_EXCEPTIONS.add("CtsExtractNativeLibsAppFalse64");
+
+ /**
+ * These apks are prebuilts needed for some tests
+ */
+ APK_EXCEPTIONS.add("CtsApkVerityTestAppPrebuilt");
+ APK_EXCEPTIONS.add("CtsApkVerityTestApp2Prebuilt");
+
+ /**
+ * Data apk used by SimpleperfTestCases
+ */
+ APK_EXCEPTIONS.add("base");
}
private static final Set<String> BINARY_EXCEPTIONS = new HashSet<>();
static {
/**
- * Tests that build for either 32 bit or 64 bit only.
- */
- BINARY_EXCEPTIONS.add("CVE-2017-0684" + "32");
- BINARY_EXCEPTIONS.add("CVE_2019_2135" + "64");
- BINARY_EXCEPTIONS.add("CVE-2020-0037" + "64");
- BINARY_EXCEPTIONS.add("CVE-2020-0038" + "64");
- BINARY_EXCEPTIONS.add("CVE-2020-0039" + "64");
-
- /**
- * This binary is a host side helper, so we do not need to check it.
+ * These binaries are host side helpers, so we do not need to check them.
*/
BINARY_EXCEPTIONS.add("sepolicy-analyze");
+ BINARY_EXCEPTIONS.add("avbtool");
+ BINARY_EXCEPTIONS.add("img2simg");
+ BINARY_EXCEPTIONS.add("lpmake");
+ BINARY_EXCEPTIONS.add("lpunpack");
+ BINARY_EXCEPTIONS.add("sign_virt_apex");
+ BINARY_EXCEPTIONS.add("simg2img");
}
private static final String BINARY_EXCEPTIONS_REGEX [] = {
@@ -126,26 +133,22 @@
* the two abis required and the second one will fail.
*/
@Test
- public void testApksAbis() {
+ public void testApksAbis() throws IOException {
String ctsRoot = System.getProperty("CTS_ROOT");
File testcases = new File(ctsRoot, "/android-cts/testcases/");
if (!testcases.exists()) {
fail(String.format("%s does not exists", testcases));
return;
}
- File[] listApks = testcases.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- for (String apk : APK_EXCEPTIONS) {
- if (name.startsWith(apk)) {
- return false;
+ Set<File> listApks = FileUtil.findFilesObject(testcases, ".*\\.apk");
+ listApks.removeIf(
+ a -> {for (String apk : APK_EXCEPTIONS) {
+ if (a.getName().startsWith(apk)) {
+ return true;
}
}
-
- return name.endsWith(".apk");
- }
- });
- assertTrue(listApks.length > 0);
+ return false;});
+ assertTrue(listApks.size() > 0);
int maxAbi = 0;
Map<String, Integer> apkToAbi = new HashMap<>();
@@ -205,38 +208,37 @@
* If there is only one bitness, then we check that it's the right one.
*/
@Test
- public void testBinariesAbis() {
+ public void testBinariesAbis() throws IOException {
String ctsRoot = System.getProperty("CTS_ROOT");
File testcases = new File(ctsRoot, "/android-cts/testcases/");
if (!testcases.exists()) {
fail(String.format("%s does not exist", testcases));
return;
}
- String[] listBinaries = testcases.list(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
+ Set<File> listBinaries = FileUtil.findFilesObject(testcases, ".*");
+ listBinaries.removeIf(f -> {
+ String name = f.getName();
if (name.contains(".")) {
- return false;
+ return true;
}
if (BINARY_EXCEPTIONS.contains(name)) {
- return false;
+ return true;
}
for (String suffixException : BINARY_SUFFIX_EXCEPTIONS) {
if (name.endsWith(suffixException)) {
- return false;
+ return true;
}
}
- File file = new File(dir, name);
- if (file.isDirectory()) {
- return false;
+ if (f.isDirectory()) {
+ return true;
}
- if (!file.canExecute()) {
- return false;
+ if (!f.canExecute()) {
+ return true;
}
try {
// Ignore python binaries
- if (FileUtil.readStringFromFile(file).startsWith("#!/usr/bin/env python")) {
- return false;
+ if (FileUtil.readStringFromFile(f).startsWith("#!/usr/bin/env python")) {
+ return true;
}
} catch (IOException e) {
throw new RuntimeException(e);
@@ -244,14 +246,13 @@
for(String pattern: BINARY_EXCEPTIONS_REGEX) {
Matcher matcher = Pattern.compile(pattern).matcher(name);
if (matcher.matches()) {
- return false;
+ return true;
}
}
- return true;
- }
+ return false;
});
- assertTrue(listBinaries.length > 0);
- List<String> orderedList = Arrays.asList(listBinaries);
+ assertTrue(listBinaries.size() > 0);
+ List<String> orderedList = listBinaries.stream().map(f->f.getName()).collect(Collectors.toList());
// we sort to have binary starting with same name, next to each other. The last two
// characters of their name with be the bitness (32 or 64).
Collections.sort(orderedList);