Consider system and vendor apis for performance points
both system and vendor API levels need to be >= Q before performance
points are required. Prior version mistakenly tried to test on some P devices
which had only been upgraded system to Q, which triggered false
failures.
Bug: 139126326
Bug: 139908823
Test: run GTS com.google.android.youtube.gts.DecodePerformanceTest
Change-Id: I0406e3a041daa6a0af3fb9e6da771f55c0837cba
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 3e9e2df..19e1215 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
@@ -314,16 +314,16 @@
return false;
}
- if (rate == 0.0) {
+ if (rate == 0.0) {
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
+ // we care about speed of decoding
Log.d(TAG, "checking for decoding " + format + " at " +
rate + " fps with " + decoder);
@@ -353,7 +353,9 @@
return false;
}
- if (ApiLevelUtil.isAtLeast(Build.VERSION_CODES.Q) && mci.isHardwareAccelerated()) {
+ if (ApiLevelUtil.isAtLeast(Build.VERSION_CODES.Q)
+ && PropertyUtil.isVendorApiLevelAtLeast(Build.VERSION_CODES.Q)
+ && mci.isHardwareAccelerated()) {
MediaCodecInfo.VideoCapabilities caps =
mci.getCapabilitiesForType(mime).getVideoCapabilities();
List<MediaCodecInfo.VideoCapabilities.PerformancePoint> pp =
@@ -369,7 +371,7 @@
}
Log.i(TAG, "NOT covered by any hardware performance point");
return false;
- } else {
+ } else {
String verified = MediaPerfUtils.areAchievableFrameRates(
decoder, mime, width, height, rate);
if (verified == null) {
@@ -378,7 +380,7 @@
}
Log.d(TAG, "achieveable framerates says: " + verified);
return false;
- }
+ }
}
public static boolean supports(String codecName, String mime, int w, int h) {
@@ -631,7 +633,7 @@
// checks format, does not address actual speed of decoding
public static boolean canDecodeVideo(String mime, int width, int height, float rate) {
- return canDecodeVideo(mime, width, height, rate, (float)0.0);
+ return canDecodeVideo(mime, width, height, rate, (float)0.0);
}
// format + decode rate
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java
index b87e88b..fb25dd7 100644
--- a/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java
+++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/PropertyUtil.java
@@ -88,6 +88,20 @@
}
/**
+ * Return whether the SDK version of the vendor partiton is same or newer than the
+ * given API level.
+ * If the property is set to non-integer value, this means the vendor partition is using
+ * current API level and true is returned.
+ */
+ public static boolean isVendorApiLevelAtLeast(int apiLevel) {
+ int vendorApiLevel = getPropertyInt(VNDK_VERSION);
+ if (vendorApiLevel == INT_VALUE_IF_UNSET) {
+ return true;
+ }
+ return vendorApiLevel >= apiLevel;
+ }
+
+ /**
* Return the manufacturer of this product. If unset, return null.
*/
public static String getManufacturer() {