Merge "make perf-measuring code safe across SDK levels" into qt-dev
am: f4a034c42c

Change-Id: Ibaf00601964a6b1d4cfab3e80577a2b2e1c3bf67
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/MediaUtils.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/MediaUtils.java
index 53da03a..3e9e2df 100644
--- a/common/device-side/util-axt/src/com/android/compatibility/common/util/MediaUtils.java
+++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/MediaUtils.java
@@ -32,6 +32,7 @@
 import android.media.MediaExtractor;
 import android.media.MediaFormat;
 import android.net.Uri;
+import android.os.Build;
 import android.util.Log;
 import android.util.Range;
 
@@ -317,6 +318,11 @@
             return true;
 	}
 
+        // before Q, we always said yes once we found a decoder for the format.
+        if (ApiLevelUtil.isBefore(Build.VERSION_CODES.Q)) {
+            return true;
+	}
+
 	// we care about speed of decoding
         Log.d(TAG, "checking for decoding " + format + " at " +
                    rate + " fps with " + decoder);
@@ -347,16 +353,7 @@
             return false;
         }
 
-        if (mci.isSoftwareOnly()) {
-            String verified = MediaPerfUtils.areAchievableFrameRates(
-                              decoder, mime, width, height, rate);
-            if (verified == null) {
-                Log.d(TAG, "claims to decode content at " + rate + " fps");
-                return true;
-            }
-            Log.d(TAG, "achieveable framerates says: " + verified);
-            return false;
-        } else {
+        if (ApiLevelUtil.isAtLeast(Build.VERSION_CODES.Q) && mci.isHardwareAccelerated()) {
             MediaCodecInfo.VideoCapabilities caps =
                             mci.getCapabilitiesForType(mime).getVideoCapabilities();
             List<MediaCodecInfo.VideoCapabilities.PerformancePoint> pp =
@@ -372,7 +369,16 @@
             }
             Log.i(TAG, "NOT covered by any hardware performance point");
             return false;
-        }
+	} else {
+            String verified = MediaPerfUtils.areAchievableFrameRates(
+                              decoder, mime, width, height, rate);
+            if (verified == null) {
+                Log.d(TAG, "claims to decode content at " + rate + " fps");
+                return true;
+            }
+            Log.d(TAG, "achieveable framerates says: " + verified);
+            return false;
+	}
     }
 
     public static boolean supports(String codecName, String mime, int w, int h) {