CCodecConfig: skip subscribing to optional params until requested

Also fix subscription logic for encoding statistics.

Bug: 232485352
Test: atest android.media.misc.cts.HeifWriterTest
Test: atest android.media.codec.cts.VideoEncodingStatisticsTest
Merged-In: Ie3c65307f43ab7f836ca9faf099b2c4a6560f29d
Change-Id: Ie3c65307f43ab7f836ca9faf099b2c4a6560f29d
(cherry picked from commit eebab653db49db342197b983735929019a5380a2)
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 529ee36..296d7ed 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -1492,8 +1492,12 @@
                                                            // with more enc stat kinds
                 // Future extended encoding statistics for the level 2 should be added here
                 case VIDEO_ENCODING_STATISTICS_LEVEL_1:
-                    config->subscribeToConfigUpdate(comp,
-                        {kParamIndexAverageBlockQuantization, kParamIndexPictureType});
+                    config->subscribeToConfigUpdate(
+                            comp,
+                            {
+                                C2AndroidStreamAverageBlockQuantizationInfo::output::PARAM_TYPE,
+                                C2StreamPictureTypeInfo::output::PARAM_TYPE,
+                            });
                     break;
                 case VIDEO_ENCODING_STATISTICS_LEVEL_NONE:
                     break;