libaudiohal: Implement some functions called during startup

Based on the logs during CF startup, implemented the following
methods:
  - DeviceFactoryHalAild::getHalPids
  - DeviceHalAidl::dump
  - DeviceHalAidl::get/setMasterMute
  - DeviceHalAidl::get/setMasterVolume
  - DeviceHalAidl::get/setMicMute
  - DeviceHalAidl::setMode
  - DeviceHalAidl::setVoiceVolume

Also implemented retrieving of IStreamCommon.

Bug: 205884982
Test: boot cuttlefish with AIDL enabled
Change-Id: Ie1619def1b5d8e2079d849b2e9e23ebeed6e2936
diff --git a/media/libaudiohal/impl/StreamHalAidl.cpp b/media/libaudiohal/impl/StreamHalAidl.cpp
index 7338952..1c6a014 100644
--- a/media/libaudiohal/impl/StreamHalAidl.cpp
+++ b/media/libaudiohal/impl/StreamHalAidl.cpp
@@ -31,6 +31,20 @@
 
 namespace android {
 
+// static
+template<class T>
+std::shared_ptr<IStreamCommon> StreamHalAidl::getStreamCommon(const std::shared_ptr<T>& stream) {
+    std::shared_ptr<::aidl::android::hardware::audio::core::IStreamCommon> streamCommon;
+    if (stream != nullptr) {
+        if (ndk::ScopedAStatus status = stream->getStreamCommon(&streamCommon);
+                !status.isOk()) {
+            ALOGE("%s: failed to retrieve IStreamCommon instance: %s", __func__,
+                    status.getDescription().c_str());
+        }
+    }
+    return streamCommon;
+}
+
 StreamHalAidl::StreamHalAidl(
         std::string_view className, bool isInput, const StreamDescriptor& descriptor,
         const std::shared_ptr<IStreamCommon>& stream)
@@ -130,11 +144,10 @@
     return OK;
 }
 
-status_t StreamHalAidl::dump(int fd __unused, const Vector<String16>& args __unused) {
+status_t StreamHalAidl::dump(int fd, const Vector<String16>& args) {
     TIME_CHECK();
     if (!mStream) return NO_INIT;
-    ALOGE("%s not implemented yet", __func__);
-    return OK;
+    return mStream->dump(fd, Args(args).args(), args.size());
 }
 
 status_t StreamHalAidl::start() {
@@ -190,18 +203,13 @@
 status_t StreamHalAidl::legacyCreateAudioPatch(const struct audio_port_config& port __unused,
                                                std::optional<audio_source_t> source __unused,
                                                audio_devices_t type __unused) {
-    TIME_CHECK();
-    LOG_ALWAYS_FATAL_IF(port.type != AUDIO_PORT_TYPE_DEVICE, "port type must be device");
-    if (!mStream) return NO_INIT;
-    ALOGE("%s not implemented yet", __func__);
-    return OK;
+    // Obsolete since 'DeviceHalAidl.supportsAudioPatches' always returns 'true'.
+    return INVALID_OPERATION;
 }
 
 status_t StreamHalAidl::legacyReleaseAudioPatch() {
-    TIME_CHECK();
-    if (!mStream) return NO_INIT;
-    ALOGE("%s not implemented yet", __func__);
-    return OK;
+    // Obsolete since 'DeviceHalAidl.supportsAudioPatches' always returns 'true'.
+    return INVALID_OPERATION;
 }
 
 namespace {
@@ -237,8 +245,7 @@
 
 StreamOutHalAidl::StreamOutHalAidl(
         const StreamDescriptor& descriptor, const std::shared_ptr<IStreamOut>& stream)
-        : StreamHalAidl("StreamOutHalAidl", false /*isInput*/, descriptor,
-                nullptr /* FIXME: Retrieve IStreamCommon */),
+        : StreamHalAidl("StreamOutHalAidl", false /*isInput*/, descriptor, getStreamCommon(stream)),
           mStream(stream) {}
 
 status_t StreamOutHalAidl::getLatency(uint32_t *latency) {
@@ -452,8 +459,7 @@
 
 StreamInHalAidl::StreamInHalAidl(
         const StreamDescriptor& descriptor, const std::shared_ptr<IStreamIn>& stream)
-        : StreamHalAidl("StreamInHalAidl", true /*isInput*/, descriptor,
-                nullptr /* FIXME: Retrieve IStreamCommon */),
+        : StreamHalAidl("StreamInHalAidl", true /*isInput*/, descriptor, getStreamCommon(stream)),
           mStream(stream) {}
 
 status_t StreamInHalAidl::setGain(float gain __unused) {