Audio V4: some legacy getSupported can return NOT_SUPPORTED

Legacy implementation through getParameter can not return a status_t.
This is problematic for
 - getSupportedChannelMasks(format)
 - getSupportedSampleRate(format)
as they should be able to return NOT_SUPPORTED if they do not support
the provided format.

In that case, allow the legacy implementation to return an empty string
that will be converted to NOT_SUPPORTED.

Test: atest VtsHalAudioV4_0TargetTest
Bug: 77307068
Change-Id: I78c37caf059885e3d33e6a308876dbc0e3ef7145
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h
index 7415112..72d7a37 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h
+++ b/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h
@@ -101,11 +101,15 @@
         halSampleRates =
             samplingRatesFromString(halListValue.string(), AudioParameter::valueListSeparator);
         sampleRates.setToExternal(halSampleRates.editArray(), halSampleRates.size());
+        // Legacy get_parameter does not return a status_t, thus can not advertise of failure.
+        // Note that this method must succeed (non empty list) if the format is supported.
+        if (sampleRates.size() == 0) {
+            result = Result::NOT_SUPPORTED;
+        }
     }
 #ifdef AUDIO_HAL_VERSION_2_0
     _hidl_cb(sampleRates);
-#endif
-#ifdef AUDIO_HAL_VERSION_4_0
+#elif AUDIO_HAL_VERSION_4_0
     _hidl_cb(result, sampleRates);
 #endif
     return Void();
@@ -126,6 +130,11 @@
         for (size_t i = 0; i < halChannelMasks.size(); ++i) {
             channelMasks[i] = AudioChannelBitfield(halChannelMasks[i]);
         }
+        // Legacy get_parameter does not return a status_t, thus can not advertise of failure.
+        // Note that this method must succeed (non empty list) if the format is supported.
+        if (channelMasks.size() == 0) {
+            result = Result::NOT_SUPPORTED;
+        }
     }
 #ifdef AUDIO_HAL_VERSION_2_0
     _hidl_cb(channelMasks);