Merge "RESTRICT AUTOMERGE Fixed testHlsSampleAes_bbb_audio_only_overridable CTS failure" into oreo-mr1-cts-dev
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
index ff8efc7..921db5a 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
@@ -234,6 +234,12 @@
         playVideoWithRetries(uri, headers, cookies, null /* width */, null /* height */, playTime);
     }
 
+    protected void playLiveAudioOnlyTest(
+            Uri uri, Map<String, String> headers, List<HttpCookie> cookies,
+            int playTime) throws Exception {
+        playVideoWithRetries(uri, headers, cookies, -1 /* width */, -1 /* height */, playTime);
+    }
+
     protected void playVideoWithRetries(
             Uri uri, Map<String, String> headers, List<HttpCookie> cookies,
             Integer width, Integer height, int playTime) throws Exception {
diff --git a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
index 13d1fbc..80ec789 100644
--- a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
@@ -190,7 +190,7 @@
 
         // Play stream for 60 seconds
         // limit rate to workaround multiplication overflow in framework
-        localHlsTest("hls_variant/index.m3u8", 60 * 1000, LOCAL_HLS_BITS_PER_MS);
+        localHlsTest("hls_variant/index.m3u8", 60 * 1000, LOCAL_HLS_BITS_PER_MS, false /*isAudioOnly*/);
     }
 
     public void testHlsWithHeadersCookies() throws Exception {
@@ -218,7 +218,7 @@
 
         // Play stream for 60 seconds
         // limit rate to workaround multiplication overflow in framework
-        localHlsTest("hls_variant/index.m3u8", 60 * 1000, LOCAL_HLS_BITS_PER_MS);
+        localHlsTest("hls_variant/index.m3u8", 60 * 1000, LOCAL_HLS_BITS_PER_MS, false /*isAudioOnly*/);
     }
 
     public void testHlsSampleAes_bbb_audio_only_overridable() throws Exception {
@@ -231,7 +231,7 @@
             // if url override provided
             playLiveAudioOnlyTest(mInputUrl, 60 * 1000);
         } else {
-            localHlsTest("audio_only/index.m3u8", 60 * 1000, -1);
+            localHlsTest("audio_only/index.m3u8", 60 * 1000, -1, true /*isAudioOnly*/);
         }
 
     }
@@ -253,7 +253,7 @@
 
                 // Play 1080p stream for 60 seconds if platform supports.
                 if (vcaps.areSizeAndRateSupported(1920 ,1080, 30)) {
-                    localHlsTest("unmuxed_1500k/index.m3u8", 60 * 1000, -1);
+                    localHlsTest("unmuxed_1500k/index.m3u8", 60 * 1000, -1, false /*isAudioOnly*/);
                 }
             } catch (IllegalArgumentException e) {
             }
@@ -267,7 +267,7 @@
         }
 
         // Play 480p stream for 60 seconds
-        localHlsTest("unmuxed_1000k/index.m3u8", 60 * 1000, -1);
+        localHlsTest("unmuxed_1000k/index.m3u8", 60 * 1000, -1, false /*isAudioOnly*/);
     }
 
     // Streaming audio from local HTTP server
@@ -485,21 +485,21 @@
         if (!MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
             return; // skip
         }
-        localHlsTest("hls.m3u8", false, false);
+        localHlsTest("hls.m3u8", false, false, false /*isAudioOnly*/);
     }
 
     public void testPlayHlsStreamWithQueryString() throws Throwable {
         if (!MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
             return; // skip
         }
-        localHlsTest("hls.m3u8", true, false);
+        localHlsTest("hls.m3u8", true, false, false /*isAudioOnly*/);
     }
 
     public void testPlayHlsStreamWithRedirect() throws Throwable {
         if (!MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
             return; // skip
         }
-        localHlsTest("hls.m3u8", false, true);
+        localHlsTest("hls.m3u8", false, true, false /*isAudioOnly*/);
     }
 
     public void testPlayHlsStreamWithTimedId3() throws Throwable {
@@ -682,19 +682,19 @@
         worker.quit();
     }
 
-    private void localHlsTest(final String name, boolean appendQueryString, boolean redirect)
-            throws Exception {
-        localHlsTest(name, null, null, appendQueryString, redirect, 10, -1);
+    private void localHlsTest(final String name, boolean appendQueryString,
+            boolean redirect, boolean isAudioOnly) throws Exception {
+        localHlsTest(name, null, null, appendQueryString, redirect, 10, -1, isAudioOnly);
     }
 
-    private void localHlsTest(final String name, int playTime, int bitsPerMs)
+    private void localHlsTest(final String name, int playTime, int bitsPerMs, boolean isAudioOnly)
             throws Exception {
-        localHlsTest(name, null, null, false, false, playTime, bitsPerMs);
+        localHlsTest(name, null, null, false, false, playTime, bitsPerMs, isAudioOnly);
     }
 
     private void localHlsTest(String name, Map<String, String> headers, List<HttpCookie> cookies,
-            boolean appendQueryString, boolean redirect, int playTime, int bitsPerMs)
-            throws Exception {
+            boolean appendQueryString, boolean redirect, int playTime, int bitsPerMs,
+            boolean isAudioOnly) throws Exception {
         if (bitsPerMs >= 0) {
             mServer = new CtsTestServer(mContext) {
                 @Override
@@ -715,8 +715,11 @@
             if (appendQueryString) {
                 stream_url += "?foo=bar/baz";
             }
-
-            playLiveVideoTest(Uri.parse(stream_url), headers, cookies, playTime);
+            if (isAudioOnly) {
+                playLiveAudioOnlyTest(Uri.parse(stream_url), headers, cookies, playTime);
+            } else {
+                playLiveVideoTest(Uri.parse(stream_url), headers, cookies, playTime);
+            }
         } finally {
             mServer.shutdown();
         }