Make IAudioRecord pure (stable) AIDL

The MicrophoneInfo type has manual parceling. Converted to AIDL.
This required exposing a private method from the AidlConversion module
as well as making some changes in build files.

As part of the process, also modernized MicrophoneInfo to use standard
library types instead of Vector and String16.

Another thing that's happening here is that av-headers is now defined
as a standard Soong module, so that we can list its dependencies.

Test: Audio-related CTS tests from CtsMediaTestCases
Change-Id: I6d50d411c59987b7d3561f97ee94baa1b306e21d
diff --git a/Android.bp b/Android.bp
index 87a8f41..d3d81d8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -8,6 +8,7 @@
     srcs: [
         "aidl/android/media/InterpolatorConfig.aidl",
         "aidl/android/media/InterpolatorType.aidl",
+        "aidl/android/media/MicrophoneInfoData.aidl",
         "aidl/android/media/VolumeShaperConfiguration.aidl",
         "aidl/android/media/VolumeShaperConfigurationOptionFlag.aidl",
         "aidl/android/media/VolumeShaperConfigurationType.aidl",
@@ -20,8 +21,33 @@
             min_sdk_version: "29",
             apex_available: [
                 "//apex_available:platform",
+                "com.android.bluetooth.updatable",
                 "com.android.media",
+                "com.android.media.swcodec",
             ],
         },
     },
 }
+
+cc_library_headers {
+    name: "av-headers",
+    export_include_dirs: ["include"],
+    static_libs: [
+        "av-types-aidl-unstable-cpp",
+        "libaudioclient_aidl_conversion",
+    ],
+    export_static_lib_headers: [
+        "av-types-aidl-unstable-cpp",
+        "libaudioclient_aidl_conversion",
+    ],
+    host_supported: true,
+    vendor_available: true,
+    double_loadable: true,
+    min_sdk_version: "29",
+    apex_available: [
+        "//apex_available:platform",
+        "com.android.bluetooth.updatable",
+        "com.android.media",
+        "com.android.media.swcodec",
+    ],
+}
diff --git a/aidl/android/media/MicrophoneInfoData.aidl b/aidl/android/media/MicrophoneInfoData.aidl
new file mode 100644
index 0000000..747bfa5
--- /dev/null
+++ b/aidl/android/media/MicrophoneInfoData.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media;
+
+/**
+ * {@hide}
+ */
+parcelable MicrophoneInfoData {
+    @utf8InCpp String deviceId;
+    int portId;
+    int type;
+    @utf8InCpp String address;
+    int deviceLocation;
+    int deviceGroup;
+    int indexInTheGroup;
+    float[] geometricLocation;
+    float[] orientation;
+    float[] frequencies;
+    float[] frequencyResponses;
+    int[] channelMapping;
+    float sensitivity;
+    float maxSpl;
+    float minSpl;
+    int directionality;
+}
diff --git a/include/media/MicrophoneInfo.h b/include/media/MicrophoneInfo.h
index 0a24b02..dd90a11 100644
--- a/include/media/MicrophoneInfo.h
+++ b/include/media/MicrophoneInfo.h
@@ -17,33 +17,31 @@
 #ifndef ANDROID_MICROPHONE_INFO_H
 #define ANDROID_MICROPHONE_INFO_H
 
+#include <android/media/MicrophoneInfoData.h>
 #include <binder/Parcel.h>
 #include <binder/Parcelable.h>
+#include <media/AidlConversion.h>
 #include <system/audio.h>
-#include <utils/String16.h>
-#include <utils/Vector.h>
 
 namespace android {
 namespace media {
 
-#define RETURN_IF_FAILED(calledOnce)                                     \
-    {                                                                    \
-        status_t returnStatus = calledOnce;                              \
-        if (returnStatus) {                                              \
-            ALOGE("Failed at %s:%d (%s)", __FILE__, __LINE__, __func__); \
-            return returnStatus;                                         \
-         }                                                               \
-    }
+#define VALUE_OR_RETURN_STATUS(exp)          \
+    ({                                       \
+        auto _tmp = (exp);                   \
+        if (!_tmp.ok()) return _tmp.error(); \
+        std::move(_tmp.value());             \
+    })
 
 class MicrophoneInfo : public Parcelable {
 public:
     MicrophoneInfo() = default;
     MicrophoneInfo(const MicrophoneInfo& microphoneInfo) = default;
     MicrophoneInfo(audio_microphone_characteristic_t& characteristic) {
-        mDeviceId = String16(&characteristic.device_id[0]);
+        mDeviceId = std::string(&characteristic.device_id[0]);
         mPortId = characteristic.id;
         mType = characteristic.device;
-        mAddress = String16(&characteristic.address[0]);
+        mAddress = std::string(&characteristic.address[0]);
         mDeviceLocation = characteristic.location;
         mDeviceGroup = characteristic.group;
         mIndexInTheGroup = characteristic.index_in_the_group;
@@ -53,8 +51,8 @@
         mOrientation.push_back(characteristic.orientation.x);
         mOrientation.push_back(characteristic.orientation.y);
         mOrientation.push_back(characteristic.orientation.z);
-        Vector<float> frequencies;
-        Vector<float> responses;
+        std::vector<float> frequencies;
+        std::vector<float> responses;
         for (size_t i = 0; i < characteristic.num_frequency_responses; i++) {
             frequencies.push_back(characteristic.frequency_responses[0][i]);
             responses.push_back(characteristic.frequency_responses[1][i]);
@@ -73,76 +71,73 @@
     virtual ~MicrophoneInfo() = default;
 
     virtual status_t writeToParcel(Parcel* parcel) const {
-        RETURN_IF_FAILED(parcel->writeString16(mDeviceId));
-        RETURN_IF_FAILED(parcel->writeInt32(mPortId));
-        RETURN_IF_FAILED(parcel->writeUint32(mType));
-        RETURN_IF_FAILED(parcel->writeString16(mAddress));
-        RETURN_IF_FAILED(parcel->writeInt32(mDeviceLocation));
-        RETURN_IF_FAILED(parcel->writeInt32(mDeviceGroup));
-        RETURN_IF_FAILED(parcel->writeInt32(mIndexInTheGroup));
-        RETURN_IF_FAILED(writeFloatVector(parcel, mGeometricLocation));
-        RETURN_IF_FAILED(writeFloatVector(parcel, mOrientation));
+        MicrophoneInfoData parcelable;
+        return writeToParcelable(&parcelable)
+               ?: parcelable.writeToParcel(parcel);
+    }
+
+    virtual status_t writeToParcelable(MicrophoneInfoData* parcelable) const {
+        parcelable->deviceId = mDeviceId;
+        parcelable->portId = mPortId;
+        parcelable->type = VALUE_OR_RETURN_STATUS(convertReinterpret<int32_t>(mType));
+        parcelable->address = mAddress;
+        parcelable->deviceGroup = mDeviceGroup;
+        parcelable->indexInTheGroup = mIndexInTheGroup;
+        parcelable->geometricLocation = mGeometricLocation;
+        parcelable->orientation = mOrientation;
         if (mFrequencyResponses.size() != 2) {
             return BAD_VALUE;
         }
-        for (size_t i = 0; i < mFrequencyResponses.size(); i++) {
-            RETURN_IF_FAILED(parcel->writeInt32(mFrequencyResponses[i].size()));
-            RETURN_IF_FAILED(writeFloatVector(parcel, mFrequencyResponses[i]));
-        }
-        std::vector<int> channelMapping;
-        for (size_t i = 0; i < mChannelMapping.size(); ++i) {
-            channelMapping.push_back(mChannelMapping[i]);
-        }
-        RETURN_IF_FAILED(parcel->writeInt32Vector(channelMapping));
-        RETURN_IF_FAILED(parcel->writeFloat(mSensitivity));
-        RETURN_IF_FAILED(parcel->writeFloat(mMaxSpl));
-        RETURN_IF_FAILED(parcel->writeFloat(mMinSpl));
-        RETURN_IF_FAILED(parcel->writeInt32(mDirectionality));
+        parcelable->frequencies = mFrequencyResponses[0];
+        parcelable->frequencyResponses = mFrequencyResponses[1];
+        parcelable->channelMapping = mChannelMapping;
+        parcelable->sensitivity = mSensitivity;
+        parcelable->maxSpl = mMaxSpl;
+        parcelable->minSpl = mMinSpl;
+        parcelable->directionality = mDirectionality;
         return OK;
     }
 
     virtual status_t readFromParcel(const Parcel* parcel) {
-        RETURN_IF_FAILED(parcel->readString16(&mDeviceId));
-        RETURN_IF_FAILED(parcel->readInt32(&mPortId));
-        RETURN_IF_FAILED(parcel->readUint32(&mType));
-        RETURN_IF_FAILED(parcel->readString16(&mAddress));
-        RETURN_IF_FAILED(parcel->readInt32(&mDeviceLocation));
-        RETURN_IF_FAILED(parcel->readInt32(&mDeviceGroup));
-        RETURN_IF_FAILED(parcel->readInt32(&mIndexInTheGroup));
-        RETURN_IF_FAILED(readFloatVector(parcel, &mGeometricLocation, 3));
-        RETURN_IF_FAILED(readFloatVector(parcel, &mOrientation, 3));
-        int32_t frequenciesNum;
-        RETURN_IF_FAILED(parcel->readInt32(&frequenciesNum));
-        Vector<float> frequencies;
-        RETURN_IF_FAILED(readFloatVector(parcel, &frequencies, frequenciesNum));
-        int32_t responsesNum;
-        RETURN_IF_FAILED(parcel->readInt32(&responsesNum));
-        Vector<float> responses;
-        RETURN_IF_FAILED(readFloatVector(parcel, &responses, responsesNum));
-        if (frequencies.size() != responses.size()) {
+        MicrophoneInfoData data;
+        return data.readFromParcel(parcel)
+            ?: readFromParcelable(data);
+    }
+
+    virtual status_t readFromParcelable(const MicrophoneInfoData& parcelable) {
+        mDeviceId = parcelable.deviceId;
+        mPortId = parcelable.portId;
+        mType = VALUE_OR_RETURN_STATUS(convertReinterpret<uint32_t>(parcelable.type));
+        mAddress = parcelable.address;
+        mDeviceLocation = parcelable.deviceLocation;
+        mDeviceGroup = parcelable.deviceGroup;
+        mIndexInTheGroup = parcelable.indexInTheGroup;
+        if (parcelable.geometricLocation.size() != 3) {
             return BAD_VALUE;
         }
-        mFrequencyResponses.push_back(frequencies);
-        mFrequencyResponses.push_back(responses);
-        std::vector<int> channelMapping;
-        status_t result = parcel->readInt32Vector(&channelMapping);
-        if (result != OK) {
-            return result;
-        }
-        if (channelMapping.size() != AUDIO_CHANNEL_COUNT_MAX) {
+        mGeometricLocation = parcelable.geometricLocation;
+        if (parcelable.orientation.size() != 3) {
             return BAD_VALUE;
         }
-        for (size_t i = 0; i < channelMapping.size(); i++) {
-            mChannelMapping.push_back(channelMapping[i]);
+        mOrientation = parcelable.orientation;
+        if (parcelable.frequencies.size() != parcelable.frequencyResponses.size()) {
+            return BAD_VALUE;
         }
-        RETURN_IF_FAILED(parcel->readFloat(&mSensitivity));
-        RETURN_IF_FAILED(parcel->readFloat(&mMaxSpl));
-        RETURN_IF_FAILED(parcel->readFloat(&mMinSpl));
-        RETURN_IF_FAILED(parcel->readInt32(&mDirectionality));
+
+        mFrequencyResponses.push_back(parcelable.frequencies);
+        mFrequencyResponses.push_back(parcelable.frequencyResponses);
+        if (parcelable.channelMapping.size() != AUDIO_CHANNEL_COUNT_MAX) {
+            return BAD_VALUE;
+        }
+        mChannelMapping = parcelable.channelMapping;
+        mSensitivity = parcelable.sensitivity;
+        mMaxSpl = parcelable.maxSpl;
+        mMinSpl = parcelable.minSpl;
+        mDirectionality = parcelable.directionality;
         return OK;
     }
 
-    String16 getDeviceId() const {
+    std::string getDeviceId() const {
         return mDeviceId;
     }
 
@@ -154,7 +149,7 @@
         return mType;
     }
 
-    String16 getAddress() const {
+    std::string getAddress() const {
         return mAddress;
     }
 
@@ -170,19 +165,19 @@
         return mIndexInTheGroup;
     }
 
-    const Vector<float>& getGeometricLocation() const {
+    const std::vector<float>& getGeometricLocation() const {
         return mGeometricLocation;
     }
 
-    const Vector<float>& getOrientation() const {
+    const std::vector<float>& getOrientation() const {
         return mOrientation;
     }
 
-    const Vector<Vector<float>>& getFrequencyResponses() const {
+    const std::vector<std::vector<float>>& getFrequencyResponses() const {
         return mFrequencyResponses;
     }
 
-    const Vector<int>& getChannelMapping() const {
+    const std::vector<int>& getChannelMapping() const {
         return mChannelMapping;
     }
 
@@ -203,46 +198,25 @@
     }
 
 private:
-    status_t readFloatVector(
-            const Parcel* parcel, Vector<float> *vectorPtr, size_t defaultLength) {
-        std::optional<std::vector<float>> v;
-        status_t result = parcel->readFloatVector(&v);
-        if (result != OK) return result;
-        vectorPtr->clear();
-        if (v) {
-            for (const auto& iter : *v) {
-                vectorPtr->push_back(iter);
-            }
-        } else {
-            vectorPtr->resize(defaultLength);
-        }
-        return OK;
-    }
-    status_t writeFloatVector(Parcel* parcel, const Vector<float>& vector) const {
-        std::vector<float> v;
-        for (size_t i = 0; i < vector.size(); i++) {
-            v.push_back(vector[i]);
-        }
-        return parcel->writeFloatVector(v);
-    }
-
-    String16 mDeviceId;
+    std::string mDeviceId;
     int32_t mPortId;
     uint32_t mType;
-    String16 mAddress;
+    std::string mAddress;
     int32_t mDeviceLocation;
     int32_t mDeviceGroup;
     int32_t mIndexInTheGroup;
-    Vector<float> mGeometricLocation;
-    Vector<float> mOrientation;
-    Vector<Vector<float>> mFrequencyResponses;
-    Vector<int> mChannelMapping;
+    std::vector<float> mGeometricLocation;
+    std::vector<float> mOrientation;
+    std::vector<std::vector<float>> mFrequencyResponses;
+    std::vector<int> mChannelMapping;
     float mSensitivity;
     float mMaxSpl;
     float mMinSpl;
     int32_t mDirectionality;
 };
 
+#undef VALUE_OR_RETURN_STATUS
+
 } // namespace media
 } // namespace android
 
diff --git a/media/libaudioclient/AidlConversion.cpp b/media/libaudioclient/AidlConversion.cpp
index e844a6e..9a6bfab 100644
--- a/media/libaudioclient/AidlConversion.cpp
+++ b/media/libaudioclient/AidlConversion.cpp
@@ -135,12 +135,6 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-template<typename To, typename From>
-ConversionResult<To> convertReinterpret(From from) {
-    static_assert(sizeof(From) == sizeof(To));
-    return static_cast<To>(from);
-}
-
 enum class Direction {
     INPUT, OUTPUT
 };
diff --git a/media/libaudioclient/Android.bp b/media/libaudioclient/Android.bp
index 5aee64a..5d692e5 100644
--- a/media/libaudioclient/Android.bp
+++ b/media/libaudioclient/Android.bp
@@ -73,7 +73,6 @@
         // AIDL files for audioclient interfaces
         // The headers for these interfaces will be available to any modules that
         // include libaudioclient, at the path "aidl/package/path/BnFoo.h"
-        ":libaudioclient_aidl_private",
         ":libaudioclient_aidl",
 
         "AudioEffect.cpp",
@@ -154,10 +153,14 @@
     },
 }
 
-cc_library_shared {
+cc_library {
     name: "libaudioclient_aidl_conversion",
     srcs: ["AidlConversion.cpp"],
-    local_include_dirs: ["include"],
+    export_include_dirs: ["include"],
+    host_supported: true,
+    vendor_available: true,
+    double_loadable: true,
+    min_sdk_version: "29",
     shared_libs: [
         "audioclient-types-aidl-unstable-cpp",
         "libbase",
@@ -183,6 +186,12 @@
             "signed-integer-overflow",
         ],
     },
+    apex_available: [
+        "//apex_available:platform",
+        "com.android.bluetooth.updatable",
+        "com.android.media",
+        "com.android.media.swcodec",
+    ],
 }
 
 // AIDL interface between libaudioclient and framework.jar
@@ -194,16 +203,6 @@
     path: "aidl",
 }
 
-// Used to strip the "aidl/" from the path, so the build system can predict the
-// output filename.
-filegroup {
-    name: "libaudioclient_aidl_private",
-    srcs: [
-        "aidl/android/media/IAudioRecord.aidl",
-    ],
-    path: "aidl",
-}
-
 aidl_interface {
     name: "capture_state_listener-aidl",
     unstable: true,
@@ -263,7 +262,7 @@
         "aidl/android/media/AudioStreamType.aidl",
         "aidl/android/media/AudioTimestampInternal.aidl",
         "aidl/android/media/AudioUsage.aidl",
-     ],
+    ],
     imports: [
         "audio_common-aidl",
     ],
@@ -291,6 +290,7 @@
         "aidl/android/media/CreateTrackResponse.aidl",
 
         "aidl/android/media/IAudioFlingerClient.aidl",
+        "aidl/android/media/IAudioRecord.aidl",
         "aidl/android/media/IAudioTrack.aidl",
         "aidl/android/media/IAudioTrackCallback.aidl",
     ],
diff --git a/media/libaudioclient/AudioRecord.cpp b/media/libaudioclient/AudioRecord.cpp
index 4d9fbb0..5969f94 100644
--- a/media/libaudioclient/AudioRecord.cpp
+++ b/media/libaudioclient/AudioRecord.cpp
@@ -1531,7 +1531,13 @@
 status_t AudioRecord::getActiveMicrophones(std::vector<media::MicrophoneInfo>* activeMicrophones)
 {
     AutoMutex lock(mLock);
-    return mAudioRecord->getActiveMicrophones(activeMicrophones).transactionError();
+    std::vector<media::MicrophoneInfoData> mics;
+    status_t status = mAudioRecord->getActiveMicrophones(&mics).transactionError();
+    activeMicrophones->resize(mics.size());
+    for (size_t i = 0; status == OK && i < mics.size(); ++i) {
+        status = activeMicrophones->at(i).readFromParcelable(mics[i]);
+    }
+    return status;
 }
 
 status_t AudioRecord::setPreferredMicrophoneDirection(audio_microphone_direction_t direction)
diff --git a/media/libaudioclient/aidl/android/media/IAudioRecord.aidl b/media/libaudioclient/aidl/android/media/IAudioRecord.aidl
index ecf58b6..121034d 100644
--- a/media/libaudioclient/aidl/android/media/IAudioRecord.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioRecord.aidl
@@ -16,7 +16,7 @@
 
 package android.media;
 
-import android.media.MicrophoneInfo;
+import android.media.MicrophoneInfoData;
 
 /* Native code must specify namespace media (media::IAudioRecord) when referring to this class */
 interface IAudioRecord {
@@ -35,7 +35,7 @@
 
   /* Get a list of current active microphones.
    */
-  void getActiveMicrophones(out MicrophoneInfo[] activeMicrophones);
+  void getActiveMicrophones(out MicrophoneInfoData[] activeMicrophones);
 
   /* Set the microphone direction (for processing).
    */
diff --git a/media/libaudioclient/aidl/android/media/MicrophoneInfo.aidl b/media/libaudioclient/aidl/android/media/MicrophoneInfo.aidl
deleted file mode 100644
index d6e46cb..0000000
--- a/media/libaudioclient/aidl/android/media/MicrophoneInfo.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media;
-
-parcelable MicrophoneInfo cpp_header "media/MicrophoneInfo.h";
diff --git a/media/libaudioclient/include/media/AidlConversion.h b/media/libaudioclient/include/media/AidlConversion.h
index e429ea1..62f87a5 100644
--- a/media/libaudioclient/include/media/AidlConversion.h
+++ b/media/libaudioclient/include/media/AidlConversion.h
@@ -85,6 +85,16 @@
     return static_cast<To>(from);
 }
 
+/**
+ * A generic template to safely cast between types, that are intended to be the same size, but
+ * interpreted differently.
+ */
+template<typename To, typename From>
+ConversionResult<To> convertReinterpret(From from) {
+    static_assert(sizeof(From) == sizeof(To));
+    return static_cast<To>(from);
+}
+
 // maxSize is the size of the C-string buffer (including the 0-terminator), NOT the max length of
 // the string.
 status_t aidl2legacy_string(std::string_view aidl, char* dest, size_t maxSize);
diff --git a/media/libaudiohal/Android.bp b/media/libaudiohal/Android.bp
index fab0fea..482f40e 100644
--- a/media/libaudiohal/Android.bp
+++ b/media/libaudiohal/Android.bp
@@ -63,8 +63,6 @@
     export_include_dirs: ["include"],
 
     // This is needed because the stream interface includes media/MicrophoneInfo.h
-    // which is not in any library but has a dependency on headers from libbinder.
-    header_libs: ["libbinder_headers"],
-
-    export_header_lib_headers: ["libbinder_headers"],
+    header_libs: ["av-headers"],
+    export_header_lib_headers: ["av-headers"],
 }
diff --git a/media/libaudiohal/impl/Android.bp b/media/libaudiohal/impl/Android.bp
index df006b5..fe47881 100644
--- a/media/libaudiohal/impl/Android.bp
+++ b/media/libaudiohal/impl/Android.bp
@@ -26,6 +26,7 @@
         "android.hardware.audio.common-util",
         "android.hidl.allocator@1.0",
         "android.hidl.memory@1.0",
+        "av-types-aidl-unstable-cpp",
         "libaudiofoundation",
         "libaudiohal_deathhandler",
         "libaudioutils",
diff --git a/media/libmedia/Android.bp b/media/libmedia/Android.bp
index 1a7eb6f..f68f65d 100644
--- a/media/libmedia/Android.bp
+++ b/media/libmedia/Android.bp
@@ -5,12 +5,14 @@
 
     export_include_dirs: ["include"],
     header_libs: [
+        "av-headers",
         "libbase_headers",
         "libgui_headers",
         "libstagefright_headers",
         "media_plugin_headers",
     ],
     export_header_lib_headers: [
+        "av-headers",
         "libgui_headers",
         "libstagefright_headers",
         "media_plugin_headers",
diff --git a/media/libshmem/Android.bp b/media/libshmem/Android.bp
index b549b5d..0e4ff48 100644
--- a/media/libshmem/Android.bp
+++ b/media/libshmem/Android.bp
@@ -14,6 +14,9 @@
     name: "libshmemcompat",
     export_include_dirs: ["include"],
     srcs: ["ShmemCompat.cpp"],
+    host_supported: true,
+    vendor_available: true,
+    double_loadable: true,
     shared_libs: [
         "libbinder",
         "libshmemutil",
@@ -31,6 +34,9 @@
     name: "libshmemutil",
     export_include_dirs: ["include"],
     srcs: ["ShmemUtil.cpp"],
+    host_supported: true,
+    vendor_available: true,
+    double_loadable: true,
     shared_libs: [
         "shared-file-region-aidl-unstable-cpp",
     ],
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 60d878a..eb9b7e5 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -664,7 +664,7 @@
                 int /*audio_session_t*/ triggerSession);
         virtual binder::Status   stop();
         virtual binder::Status   getActiveMicrophones(
-                std::vector<media::MicrophoneInfo>* activeMicrophones);
+                std::vector<media::MicrophoneInfoData>* activeMicrophones);
         virtual binder::Status   setPreferredMicrophoneDirection(
                 int /*audio_microphone_direction_t*/ direction);
         virtual binder::Status   setPreferredMicrophoneFieldDimension(float zoom);
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 5c4d4b9..68b709f 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -2147,10 +2147,15 @@
 }
 
 binder::Status AudioFlinger::RecordHandle::getActiveMicrophones(
-        std::vector<media::MicrophoneInfo>* activeMicrophones) {
+        std::vector<media::MicrophoneInfoData>* activeMicrophones) {
     ALOGV("%s()", __func__);
-    return binder::Status::fromStatusT(
-            mRecordTrack->getActiveMicrophones(activeMicrophones));
+    std::vector<media::MicrophoneInfo> mics;
+    status_t status = mRecordTrack->getActiveMicrophones(&mics);
+    activeMicrophones->resize(mics.size());
+    for (size_t i = 0; status == OK && i < mics.size(); ++i) {
+       status = mics[i].writeToParcelable(&activeMicrophones->at(i));
+    }
+    return binder::Status::fromStatusT(status);
 }
 
 binder::Status AudioFlinger::RecordHandle::setPreferredMicrophoneDirection(