From 9bf3064f6c6e413bc8909c085302a4fc3f60ce4f Mon Sep 17 00:00:00 2001 From: Jia Zhao Date: Mon, 10 Jul 2017 18:48:20 -0700 Subject: Check max supported size before setting them to media format. Test: to be shared in the bug Bug: 62809013 Change-Id: If0076f286b619fa6d998c7f5f612848cc02a5b44 --- .../src/android/media/cts/DecodeAccuracyTest.java | 18 +++++-------- .../android/media/cts/DecodeAccuracyTestBase.java | 31 +++++++++++++++++++--- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java b/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java index 010d9923e0f..72838e5dd26 100644 --- a/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java +++ b/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java @@ -264,13 +264,10 @@ public class DecodeAccuracyTest extends DecodeAccuracyTestBase { public int getHeight() { return super.getHeight() + OFFSET; } + @Override - public int getMaxHeight() { - return super.getHeight() * 2 + OFFSET; - } - @Override - public int getMaxWidth() { - return super.getWidth() * 2 + OFFSET; + public boolean isAbrEnabled() { + return true; } }; } @@ -281,13 +278,10 @@ public class DecodeAccuracyTest extends DecodeAccuracyTestBase { public int getWidth() { return super.getWidth() + OFFSET; } + @Override - public int getMaxHeight() { - return super.getHeight() * 2 + OFFSET; - } - @Override - public int getMaxWidth() { - return super.getWidth() * 2 + OFFSET; + public boolean isAbrEnabled() { + return true; } }; } diff --git a/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java b/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java index 0e92e3df92e..58f16075748 100644 --- a/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java +++ b/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java @@ -20,6 +20,7 @@ import android.media.cts.R; import static org.junit.Assert.assertNotNull; import com.android.compatibility.common.util.ApiLevelUtil; +import com.android.compatibility.common.util.MediaUtils; import android.annotation.TargetApi; import android.annotation.SuppressLint; @@ -38,6 +39,7 @@ import android.graphics.SurfaceTexture; import android.media.MediaCodec; import android.media.MediaCodec.BufferInfo; import android.media.MediaCodec.CodecException; +import android.media.MediaCodecInfo.VideoCapabilities; import android.media.MediaCodecList; import android.media.MediaExtractor; import android.media.MediaFormat; @@ -480,10 +482,27 @@ public class DecodeAccuracyTestBase { if (ApiLevelUtil.isBefore(Build.VERSION_CODES.KITKAT)) { return; } - if (videoFormat.getMaxWidth() != VideoFormat.INT_UNSET - && videoFormat.getMaxHeight() != VideoFormat.INT_UNSET) { - mediaFormat.setInteger(MediaFormat.KEY_MAX_WIDTH, videoFormat.getMaxWidth()); - mediaFormat.setInteger(MediaFormat.KEY_MAX_HEIGHT, videoFormat.getMaxHeight()); + // Set KEY_MAX_WIDTH and KEY_MAX_HEIGHT when isAbrEnabled() is set. + if (videoFormat.isAbrEnabled()) { + try { + // Check for max resolution supported by the codec. + final MediaCodec decoder = MediaUtils.getDecoder(mediaFormat); + final VideoCapabilities videoCapabilities = MediaUtils.getVideoCapabilities( + decoder.getName(), videoFormat.getMimeType()); + decoder.release(); + final int maxWidth = videoCapabilities.getSupportedWidths().getUpper(); + final int maxHeight = + videoCapabilities.getSupportedHeightsFor(maxWidth).getUpper(); + if (maxWidth >= videoFormat.getWidth() && maxHeight >= videoFormat.getHeight()) { + mediaFormat.setInteger(MediaFormat.KEY_MAX_WIDTH, maxWidth); + mediaFormat.setInteger(MediaFormat.KEY_MAX_HEIGHT, maxHeight); + return; + } + } catch (NullPointerException exception) { /* */ } + // Set max width/height to current size if can't get codec's max supported + // width/height or max is not greater than the current size. + mediaFormat.setInteger(MediaFormat.KEY_MAX_WIDTH, videoFormat.getWidth()); + mediaFormat.setInteger(MediaFormat.KEY_MAX_HEIGHT, videoFormat.getHeight()); } } @@ -1591,6 +1610,10 @@ class VideoFormat { return getParsedName().getHeight(); } + public boolean isAbrEnabled() { + return false; + } + public String getOriginalSize() { if (width == INT_UNSET || height == INT_UNSET) { return getParsedName().getSize(); -- cgit v1.2.3 From 43b608fbb11ddf9b8d154a1de0094ff8b7083234 Mon Sep 17 00:00:00 2001 From: jdesprez Date: Mon, 14 Aug 2017 18:03:21 -0700 Subject: Close CTS ResultReporter streams Test: build, unit tests Bug: 62864604 Change-Id: Icd65f66ea00d3e0d0b95bba7b51413ebf041a47a --- .../compatibility/common/tradefed/result/ResultReporter.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java index e85119bf11b..ce642548994 100644 --- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java +++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java @@ -558,9 +558,13 @@ public class ResultReporter implements ILogSaverListener, ITestInvocationListene try { File logFile = null; if (mCompressLogs) { - logFile = mTestLogSaver.saveAndGZipLogData(name, type, stream.createInputStream()); + try (InputStream inputStream = stream.createInputStream()) { + logFile = mTestLogSaver.saveAndGZipLogData(name, type, inputStream); + } } else { - logFile = mTestLogSaver.saveLogData(name, type, stream.createInputStream()); + try (InputStream inputStream = stream.createInputStream()) { + logFile = mTestLogSaver.saveLogData(name, type, inputStream); + } } debug("Saved logs for %s in %s", name, logFile.getAbsolutePath()); } catch (IOException e) { -- cgit v1.2.3 From b5f981d75aa7d1553a1c1c7de6dd206819275399 Mon Sep 17 00:00:00 2001 From: Fyodor Kupolov Date: Tue, 15 Aug 2017 16:05:01 -0700 Subject: Add PrivappPermissionsTest to known failures CDD does not require that the whitelist must be an exact match with what the apps are requesting. Test: make cts Bug: 64690009 Bug: 36730743 Change-Id: I3df04557baa461fb7092f866d2dd967acafdbeca --- tools/cts-tradefed/res/config/cts-known-failures.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/cts-tradefed/res/config/cts-known-failures.xml b/tools/cts-tradefed/res/config/cts-known-failures.xml index d4cd4813ba9..2ecc0c8d3c7 100644 --- a/tools/cts-tradefed/res/config/cts-known-failures.xml +++ b/tools/cts-tradefed/res/config/cts-known-failures.xml @@ -264,4 +264,6 @@