CodecCapabilities: Fix validFeatures().
This test api returns an array with the same size as getValidFeatures()
but having null objects.
It is hide and not called by any tests before.
The issues is detected by the newly added NativeAMediaCodecInfoTest.
Bug: 363320865
Test: NativeAMediaCoecInfoTest
Change-Id: Ib1a4ceb77e04e607af59bab244cc36b9fb16bbad
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index 782db35..cf54f6c 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -907,13 +907,13 @@
/** @hide */
public String[] validFeatures() {
Feature[] features = getValidFeatures();
- String[] res = new String[features.length];
- for (int i = 0; i < res.length; i++) {
+ ArrayList<String> res = new ArrayList();
+ for (int i = 0; i < features.length; i++) {
if (!features[i].mInternal) {
- res[i] = features[i].mName;
+ res.add(features[i].mName);
}
}
- return res;
+ return res.toArray(new String[0]);
}
private Feature[] getValidFeatures() {