Merge "Bump android.hardware.graphics.common V4->V5" into main
diff --git a/camera/camera_platform.aconfig b/camera/camera_platform.aconfig
index 074413f..33eb592 100644
--- a/camera/camera_platform.aconfig
+++ b/camera/camera_platform.aconfig
@@ -20,3 +20,10 @@
      description: "Flash brightness level control in manual flash mode"
      bug: "238348881"
 }
+
+flag {
+     namespace: "camera_platform"
+     name: "lazy_aidl_wait_for_service"
+     description: "Use waitForService instead of getService with lazy AIDL HALs"
+     bug: "285546208"
+}
diff --git a/media/aconfig/mediacodec_flags.aconfig b/media/aconfig/mediacodec_flags.aconfig
index 67ba3e5..90ddf27 100644
--- a/media/aconfig/mediacodec_flags.aconfig
+++ b/media/aconfig/mediacodec_flags.aconfig
@@ -6,3 +6,10 @@
   description: "Feature flags for large audio frame support"
   bug: "297219557"
 }
+
+flag {
+  name: "codec_importance"
+  namespace: "codec_fwk"
+  description: "Feature flags for media codec importance"
+  bug: "297929011"
+}
diff --git a/media/codec2/hal/aidl/BufferTypes.cpp b/media/codec2/hal/aidl/BufferTypes.cpp
index 1cd3555..b1af579 100644
--- a/media/codec2/hal/aidl/BufferTypes.cpp
+++ b/media/codec2/hal/aidl/BufferTypes.cpp
@@ -54,8 +54,10 @@
 using ::aidl::android::hardware::media::c2::utils::BufferPoolTypes;
 
 using AidlNativeHandle = ::aidl::android::hardware::common::NativeHandle;
+using AidlHardwareBuffer = ::aidl::android::hardware::HardwareBuffer;
 
 constexpr BaseBlock::Tag NATIVE_BLOCK = BaseBlock::nativeBlock;
+constexpr BaseBlock::Tag HWB_BLOCK = BaseBlock::hwbBlock;
 constexpr BaseBlock::Tag POOLED_BLOCK = BaseBlock::pooledBlock;
 
 // BaseBlock -> C2BaseBlock
@@ -97,6 +99,21 @@
             }
             return false;
         }
+    case HWB_BLOCK: {
+            AHardwareBuffer *pBuf =
+                    const_cast<AidlHardwareBuffer&>(
+                            s.get<HWB_BLOCK>()).release();
+            d->graphic = _C2BlockFactory::CreateGraphicBlock(pBuf);
+            if (pBuf) {
+                AHardwareBuffer_release(pBuf);
+            }
+            if (d->graphic) {
+                d->type = ::android::C2BaseBlock::GRAPHIC;
+                return true;
+            }
+            LOG(ERROR) << "Improper ahwb in BaseBlock::hwbBlock.";
+            return false;
+        }
     case POOLED_BLOCK: {
             const BufferStatusMessage &bpMessage = s.get<POOLED_BLOCK>();
             std::shared_ptr<ClientManager> bp = ClientManager::getInstance();
@@ -188,6 +205,13 @@
 }
 
 template<>
+void SetAHardwareBuffer(BaseBlock *block, AHardwareBuffer *ahwb) {
+    AHardwareBuffer_acquire(ahwb);
+    block->set<HWB_BLOCK>(AidlHardwareBuffer());
+    (block->get<HWB_BLOCK>()).reset(ahwb);
+}
+
+template<>
 void SetPooledBlock<BufferPoolTypes>(
         BaseBlock *baseBlock,
         const typename BufferPoolTypes::BufferStatusMessage &pooledBlock) {
@@ -326,6 +350,28 @@
     return ::android::objcpy(d, s);
 }
 
+void ReturnOutputBlocksToClientIfNeeded(
+        const std::list<std::unique_ptr<C2Work>>& workList) {
+    for (const std::unique_ptr<C2Work>& work : workList) {
+        if (!work) {
+            continue;
+        }
+        for (const std::unique_ptr<C2Worklet>& worklet : work->worklets) {
+            if (worklet) {
+                for (const std::shared_ptr<C2Buffer>& buffer : worklet->output.buffers) {
+                    if (buffer) {
+                        for (const C2ConstGraphicBlock& block : buffer->data().graphicBlocks()) {
+                            std::shared_ptr<_C2BlockPoolData> poolData =
+                                  _C2BlockFactory::GetGraphicBlockPoolData(block);
+                            _C2BlockFactory::DisownIgbaBlock(poolData);
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
 }  // namespace utils
 }  // namespace c2
 }  // namespace media
diff --git a/media/codec2/hal/aidl/Component.cpp b/media/codec2/hal/aidl/Component.cpp
index 9c21a5b..2e0859b 100644
--- a/media/codec2/hal/aidl/Component.cpp
+++ b/media/codec2/hal/aidl/Component.cpp
@@ -113,26 +113,22 @@
             WorkBundle workBundle;
 
             std::shared_ptr<Component> strongComponent = mComponent.lock();
-            // TODO
-            // beginTransferBufferQueueBlocks(c2workItems, true);
             if (!ToAidl(&workBundle, c2workItems, strongComponent ?
                     &strongComponent->mBufferPoolSender : nullptr)) {
                 LOG(ERROR) << "Component::Listener::onWorkDone_nb -- "
                            << "received corrupted work items.";
-                // TODO
-                // endTransferBufferQueueBlocks(c2workItems, false, true);
                 return;
             }
             ScopedAStatus transStatus = listener->onWorkDone(workBundle);
             if (!transStatus.isOk()) {
                 LOG(ERROR) << "Component::Listener::onWorkDone_nb -- "
                            << "transaction failed.";
-                // TODO
-                // endTransferBufferQueueBlocks(c2workItems, false, true);
                 return;
             }
-            // TODO
-            // endTransferBufferQueueBlocks(c2workItems, true, true);
+            // If output blocks are originally owned by the client(not by HAL),
+            // return the ownership to the client. (Since the blocks are
+            // transferred to the client here.)
+            ReturnOutputBlocksToClientIfNeeded(c2workItems);
         }
     }
 
@@ -210,15 +206,15 @@
         }
     }
 
-    // TODO
-    // beginTransferBufferQueueBlocks(c2flushedWorks, true);
     if (c2res == C2_OK) {
         if (!ToAidl(flushedWorkBundle, c2flushedWorks, &mBufferPoolSender)) {
             c2res = C2_CORRUPTED;
         }
     }
-    // TODO
-    // endTransferBufferQueueBlocks(c2flushedWorks, true, true);
+    // If output blocks are originally owned by the client(not by HAL),
+    // return the ownership to the client. (Since the blocks are
+    // transferred to the client here.)
+    ReturnOutputBlocksToClientIfNeeded(c2flushedWorks);
     if (c2res == C2_OK) {
         return ScopedAStatus::ok();
     }
diff --git a/media/codec2/hal/aidl/include/codec2/aidl/BufferTypes.h b/media/codec2/hal/aidl/include/codec2/aidl/BufferTypes.h
index 470863c..87fb855 100644
--- a/media/codec2/hal/aidl/include/codec2/aidl/BufferTypes.h
+++ b/media/codec2/hal/aidl/include/codec2/aidl/BufferTypes.h
@@ -115,6 +115,12 @@
         std::list<std::unique_ptr<C2Work>>* d,
         const WorkBundle& s);
 
+// Return the ownership of output blocks to the client if it is originally
+// created from the client, after C2Work is returned to the client.
+// (e.g. C2BqPool / C2IgbaBlockPool)
+void ReturnOutputBlocksToClientIfNeeded(
+        const std::list<std::unique_ptr<C2Work>>& workList);
+
 /**
  * Converts a BufferPool status value to c2_status_t.
  * \param BufferPool status
diff --git a/media/codec2/hal/client/GraphicsTracker.cpp b/media/codec2/hal/client/GraphicsTracker.cpp
index 2424f7b..573ded8 100644
--- a/media/codec2/hal/client/GraphicsTracker.cpp
+++ b/media/codec2/hal/client/GraphicsTracker.cpp
@@ -20,6 +20,7 @@
 #include <private/android/AHardwareBufferHelpers.h>
 #include <vndk/hardware_buffer.h>
 
+#include <C2BlockInternal.h>
 #include <codec2/aidl/GraphicsTracker.h>
 
 namespace aidl::android::hardware::media::c2::implementation {
@@ -30,10 +31,23 @@
 static constexpr int kMaxDequeueMax = ::android::BufferQueueDefs::NUM_BUFFER_SLOTS - 2;
 
 c2_status_t retrieveAHardwareBufferId(const C2ConstGraphicBlock &blk, uint64_t *bid) {
-    // TODO
-    (void)blk;
-    (void)bid;
-    return C2_OK;
+    std::shared_ptr<const _C2BlockPoolData> bpData = _C2BlockFactory::GetGraphicBlockPoolData(blk);
+    if (bpData->getType() != _C2BlockPoolData::TYPE_AHWBUFFER) {
+        return C2_BAD_VALUE;
+    }
+    if (__builtin_available(android __ANDROID_API_T__, *)) {
+        AHardwareBuffer *pBuf;
+        if (!_C2BlockFactory::GetAHardwareBuffer(bpData, &pBuf)) {
+            return C2_CORRUPTED;
+        }
+        int ret = AHardwareBuffer_getId(pBuf, bid);
+        if (ret != ::android::OK) {
+            return C2_CORRUPTED;
+        }
+        return C2_OK;
+    } else {
+        return C2_OMITTED;
+    }
 }
 
 } // anonymous namespace
@@ -44,16 +58,18 @@
     if (!buf) {
         return;
     }
-    AHardwareBuffer *pBuf = AHardwareBuffer_from_GraphicBuffer(buf.get());
-    int ret = AHardwareBuffer_getId(pBuf, &mId);
-    if (ret != ::android::OK) {
-        return;
+    if (__builtin_available(android __ANDROID_API_T__, *)) {
+        AHardwareBuffer *pBuf = AHardwareBuffer_from_GraphicBuffer(buf.get());
+        int ret = AHardwareBuffer_getId(pBuf, &mId);
+        if (ret != ::android::OK) {
+            return;
+        }
+        mUsage = buf->getUsage();
+        AHardwareBuffer_acquire(pBuf);
+        mBuf = pBuf;
+        mFence = fence;
+        mInit = true;
     }
-    mUsage = buf->getUsage();
-    AHardwareBuffer_acquire(pBuf);
-    mBuf = pBuf;
-    mFence = fence;
-    mInit = true;
 }
 
 GraphicsTracker::BufferItem::BufferItem(
diff --git a/media/codec2/hal/common/include/codec2/common/BufferTypes.h b/media/codec2/hal/common/include/codec2/common/BufferTypes.h
index 8998a6d..afd2db0 100644
--- a/media/codec2/hal/common/include/codec2/common/BufferTypes.h
+++ b/media/codec2/hal/common/include/codec2/common/BufferTypes.h
@@ -63,6 +63,9 @@
 template <typename BaseBlock>
 void SetHandle(BaseBlock *baseBlock, const C2Handle *handle);
 
+template <typename BaseBlock>
+void SetAHardwareBuffer(BaseBlock *baseBlock, AHardwareBuffer *pBuf);
+
 template <typename BufferPoolTypes, typename BaseBlock>
 void SetPooledBlock(
         BaseBlock *baseBlock,
@@ -100,6 +103,31 @@
     return true;
 }
 
+// Find or add a HAL BaseBlock object from a given AHardwareBuffer* to a list and an
+// associated map.
+template <typename BaseBlock>
+bool _addBaseBlock(
+        uint32_t* index,
+        AHardwareBuffer* pBuf,
+        std::list<BaseBlock>* baseBlocks,
+        std::map<const void*, uint32_t>* baseBlockIndices) {
+    if (!pBuf) {
+        LOG(ERROR) << "addBaseBlock called on a null AHardwareBuffer.";
+    }
+    auto it = baseBlockIndices->find(pBuf);
+    if (it != baseBlockIndices->end()) {
+        *index = it->second;
+    } else {
+        *index = baseBlocks->size();
+        baseBlockIndices->emplace(pBuf, *index);
+        baseBlocks->emplace_back();
+
+        BaseBlock &dBaseBlock = baseBlocks->back();
+        SetAHardwareBuffer(&dBaseBlock, pBuf);
+    }
+    return true;
+}
+
 // Find or add a hidl BaseBlock object from a given BufferPoolData to a list and
 // an associated map.
 template <typename BufferPoolTypes, typename BaseBlock>
@@ -179,6 +207,15 @@
         return _addBaseBlock(
                 index, handle,
                 baseBlocks, baseBlockIndices);
+    case _C2BlockPoolData::TYPE_AHWBUFFER:
+        AHardwareBuffer *pBuf;
+        if (!_C2BlockFactory::GetAHardwareBuffer(blockPoolData, &pBuf)) {
+            LOG(ERROR) << "AHardwareBuffer unavailable in a block.";
+            return false;
+        }
+        return _addBaseBlock(
+                index, pBuf,
+                baseBlocks, baseBlockIndices);
     default:
         LOG(ERROR) << "Unknown C2BlockPoolData type.";
         return false;
diff --git a/media/codec2/hal/hidl/1.0/utils/types.cpp b/media/codec2/hal/hidl/1.0/utils/types.cpp
index abe5494..69f664b 100644
--- a/media/codec2/hal/hidl/1.0/utils/types.cpp
+++ b/media/codec2/hal/hidl/1.0/utils/types.cpp
@@ -210,6 +210,13 @@
 }
 
 template<>
+void SetAHardwareBuffer(BaseBlock *block, AHardwareBuffer *pBuf) {
+    (void) block;
+    (void) pBuf;
+    LOG(FATAL) << "This is not used";
+}
+
+template<>
 void SetPooledBlock<BufferPoolTypes>(
         BaseBlock *baseBlock,
         const typename BufferPoolTypes::BufferStatusMessage &pooledBlock) {
diff --git a/media/codec2/vndk/Android.bp b/media/codec2/vndk/Android.bp
index a59bd47..bbe228c 100644
--- a/media/codec2/vndk/Android.bp
+++ b/media/codec2/vndk/Android.bp
@@ -65,6 +65,7 @@
         "C2Store.cpp",
         "platform/C2BqBuffer.cpp",
         "platform/C2SurfaceSyncObj.cpp",
+        "platform/C2IgbaBuffer.cpp",
         "types.cpp",
         "util/C2Debug.cpp",
         "util/C2InterfaceHelper.cpp",
@@ -99,6 +100,7 @@
         "android.hardware.common.fmq-V1-ndk",
         "android.hardware.media.bufferpool@2.0",
         "android.hardware.media.bufferpool2-V1-ndk",
+        "android.hardware.media.c2-V1-ndk",
         "libbase",
         "libbinder_ndk",
         "libcutils",
@@ -154,6 +156,7 @@
         "android.hardware.common-V2-ndk",
         "android.hardware.common.fmq-V1-ndk",
         "android.hardware.media.bufferpool2-V1-ndk",
+        "android.hardware.media.c2-V1-ndk",
     ],
 
     shared_libs: [
diff --git a/media/codec2/vndk/include/C2IgbaBufferPriv.h b/media/codec2/vndk/include/C2IgbaBufferPriv.h
new file mode 100644
index 0000000..a5676b7
--- /dev/null
+++ b/media/codec2/vndk/include/C2IgbaBufferPriv.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+#pragma once
+
+#include <C2Buffer.h>
+
+#include <memory>
+
+namespace aidl::android::hardware::media::c2 {
+    class IGraphicBufferAllocator;
+}
+
+/**
+ * Codec2-AIDL IGraphicBufferAllocator backed C2BlockPool
+ *
+ * Graphic Blocks are created using IGraphicBufferAllocator C2AIDL interface.
+ */
+class C2IgbaBlockPool : public C2BlockPool {
+public:
+    explicit C2IgbaBlockPool(
+            const std::shared_ptr<C2Allocator> &allocator,
+            const std::shared_ptr<
+                    ::aidl::android::hardware::media::c2::IGraphicBufferAllocator> &igba,
+            const local_id_t localId);
+
+    virtual ~C2IgbaBlockPool() = default;
+
+    virtual C2Allocator::id_t getAllocatorId() const override {
+        return mAllocator->getId();
+    }
+
+    virtual local_id_t getLocalId() const override {
+        return mLocalId;
+    }
+
+    /* Note: this is blocking due to H/W fence waiting */
+    virtual c2_status_t fetchGraphicBlock(
+        uint32_t width,
+        uint32_t height,
+        uint32_t format,
+        C2MemoryUsage usage,
+        std::shared_ptr<C2GraphicBlock> *block /* nonnull */) override;
+
+    virtual c2_status_t fetchGraphicBlock(
+        uint32_t width,
+        uint32_t height,
+        uint32_t format,
+        C2MemoryUsage usage,
+        std::shared_ptr<C2GraphicBlock> *block /* nonnull */,
+        C2Fence *fence /* nonnull */) override;
+
+    // Do we need this?
+    void invalidate();
+
+private:
+    c2_status_t _fetchGraphicBlock(
+        uint32_t width,
+        uint32_t height,
+        uint32_t format,
+        C2MemoryUsage usage,
+        c2_nsecs_t timeoutNs,
+        uint64_t *origId /* nonnull */,
+        std::shared_ptr<C2GraphicBlock> *block /* nonnull */,
+        C2Fence *fence /* nonnull */);
+
+    const std::shared_ptr<C2Allocator> mAllocator;
+    const std::shared_ptr<::aidl::android::hardware::media::c2::IGraphicBufferAllocator> mIgba;
+    const local_id_t mLocalId;
+    std::atomic<bool> mValid;
+    C2Fence mWaitFence;
+};
+
+typedef struct AHardwareBuffer AHardwareBuffer;
+
+struct C2IgbaBlockPoolData : public _C2BlockPoolData {
+
+    C2IgbaBlockPoolData(
+            const AHardwareBuffer *buffer,
+            const std::shared_ptr<::aidl::android::hardware::media::c2::IGraphicBufferAllocator>
+                &igba);
+
+    virtual ~C2IgbaBlockPoolData() override;
+
+    virtual type_t getType() const override;
+
+private:
+    friend struct _C2BlockFactory;
+
+    void getAHardwareBuffer(AHardwareBuffer **pBuf) const;
+
+    void disown();
+
+    bool mOwned;
+    const AHardwareBuffer *mBuffer;
+    const std::weak_ptr<::aidl::android::hardware::media::c2::IGraphicBufferAllocator> mIgba;
+};
diff --git a/media/codec2/vndk/include/C2PlatformSupport.h b/media/codec2/vndk/include/C2PlatformSupport.h
index dc82e82..221a799 100644
--- a/media/codec2/vndk/include/C2PlatformSupport.h
+++ b/media/codec2/vndk/include/C2PlatformSupport.h
@@ -86,6 +86,15 @@
         BLOB,
 
         /**
+         * ID of C2AIDL IGraphicBufferAllocator backed platform allocator.
+         *
+         * C2Handle layout is not public. Use C2AllocatorAhwb::UnwrapNativeCodec2AhwbHandle
+         * to get the underlying gralloc handle from a C2Handle, and WrapNativeCodec2AhwbHandle
+         * to create a C2Handle from a gralloc handle - for C2Allocator::priorAllocation.
+         */
+        IGBA,
+
+        /**
          * ID of indicating the end of platform allocator definition.
          *
          * \note always put this macro in the last place.
diff --git a/media/codec2/vndk/internal/C2BlockInternal.h b/media/codec2/vndk/internal/C2BlockInternal.h
index 81cdb43..8198ee1 100644
--- a/media/codec2/vndk/internal/C2BlockInternal.h
+++ b/media/codec2/vndk/internal/C2BlockInternal.h
@@ -39,6 +39,8 @@
 
 }
 
+typedef struct AHardwareBuffer AHardwareBuffer;
+
 using bufferpool_BufferPoolData = android::hardware::media::bufferpool::BufferPoolData;
 using bufferpool2_BufferPoolData = aidl::android::hardware::media::bufferpool2::BufferPoolData;
 
@@ -50,6 +52,7 @@
         TYPE_BUFFERPOOL = 0,
         TYPE_BUFFERQUEUE,
         TYPE_BUFFERPOOL2, // AIDL-BufferPool
+        TYPE_AHWBUFFER, // AHardwareBuffer based block
     };
 
     virtual type_t getType() const = 0;
@@ -174,6 +177,17 @@
             const std::shared_ptr<bufferpool_BufferPoolData> &data);
 
     /**
+     * Create a graphic block from the received AHardwareBuffer.
+     *
+     * \param buffer  AHardwareBuffer
+     *
+     * \return shared pointer to the graphic block. nullptr if there was not enough memory to
+     *         create this block.
+     */
+    static
+    std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(AHardwareBuffer *buffer);
+
+    /**
      * Get bufferpool data from the blockpool data.
      *
      * \param poolData          blockpool data
@@ -433,6 +447,31 @@
     static
     bool DisplayBlockToBufferQueue(
             const std::shared_ptr<_C2BlockPoolData>& poolData);
+
+    /**
+     * Retrieves a AHardwareBuffer from data of a graphic block which was
+     * allocated via IGBA based blockpool. Retrieved AHardwareBuffer handle
+     * does not have the ownership. poolData still has the ownership. Use
+     * AHardwareBuffer_acquire()/AHardwareBuffer_release if independent
+     * life-cycle/ownership is required.
+     *
+     * \param[in]   poolData  blockpool data.
+     * \param[out]  pBuf      ptr to AHardwareBuffer
+     *
+     * \return true if AHardwareBuffer was returned to output parameter, false
+     * otherwise.
+     */
+    static
+    bool GetAHardwareBuffer(
+            const std::shared_ptr<const _C2BlockPoolData>& poolData,
+            AHardwareBuffer **pBuf);
+
+    /**
+     * Mark a graphic block is not owned by the current process anymore.
+     * (Use this method after transfer is being completed.)
+     */
+    static void DisownIgbaBlock(
+            const std::shared_ptr<_C2BlockPoolData>& poolData);
 };
 
 #endif // ANDROID_STAGEFRIGHT_C2BLOCK_INTERNAL_H_
diff --git a/media/codec2/vndk/platform/C2IgbaBuffer.cpp b/media/codec2/vndk/platform/C2IgbaBuffer.cpp
new file mode 100644
index 0000000..853d5a3
--- /dev/null
+++ b/media/codec2/vndk/platform/C2IgbaBuffer.cpp
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+//#define LOG_NDEBUG 0
+#define LOG_TAG "C2IgbaBuffer"
+#include <android-base/logging.h>
+#include <aidl/android/hardware/media/c2/IGraphicBufferAllocator.h>
+#include <vndk/hardware_buffer.h>
+#include <utils/Log.h>
+
+#include <C2AllocatorGralloc.h>
+#include <C2BlockInternal.h>
+#include <C2FenceFactory.h>
+#include <C2IgbaBufferPriv.h>
+#include <C2PlatformSupport.h>
+
+using ::android::C2AllocatorAhwb;
+using C2IGBA = ::aidl::android::hardware::media::c2::IGraphicBufferAllocator;
+
+namespace {
+int32_t static inline ToAidl(uint32_t u) {return static_cast<int32_t>(u);}
+int64_t static inline ToAidl(uint64_t u) {return static_cast<int64_t>(u);}
+
+c2_nsecs_t static constexpr kBlockingFetchTimeoutNs = 5000000000LL; // 5 secs
+c2_nsecs_t static constexpr kSyncFenceWaitNs = (1000000000LL / 60LL); // 60 fps frame secs
+
+c2_status_t static CreateGraphicBlockFromAhwb(AHardwareBuffer *ahwb,
+                                            const std::shared_ptr<C2Allocator> &allocator,
+                                            const std::shared_ptr<C2IGBA> &igba,
+                                            std::shared_ptr<C2GraphicBlock> *block) {
+    if (__builtin_available(android __ANDROID_API_T__, *)) {
+        uint64_t origId = 0;
+        CHECK(AHardwareBuffer_getId(ahwb, &origId) == ::android::OK);
+
+        AHardwareBuffer_Desc desc;
+        AHardwareBuffer_describe(ahwb, &desc);
+        const native_handle_t *handle = AHardwareBuffer_getNativeHandle(ahwb);
+        // cloned handle with wrapped data.(independent lifecycle with Ahwb)
+        C2Handle *c2Handle = android::WrapNativeCodec2AhwbHandle(
+                handle,
+                desc.width,
+                desc.height,
+                desc.format,
+                desc.usage,
+                desc.stride,
+                origId);
+        if (!c2Handle) {
+            return C2_NO_MEMORY;
+        }
+        std::shared_ptr<C2GraphicAllocation> alloc;
+        c2_status_t err = allocator->priorGraphicAllocation(c2Handle, &alloc);
+        if (err != C2_OK) {
+            native_handle_close(c2Handle);
+            native_handle_delete(c2Handle);
+            return err;
+        }
+        std::shared_ptr<C2IgbaBlockPoolData> poolData =
+                std::make_shared<C2IgbaBlockPoolData>(ahwb, igba);
+        *block = _C2BlockFactory::CreateGraphicBlock(alloc, poolData);
+        return C2_OK;
+    } else {
+        return C2_OMITTED;
+    }
+}
+
+} // anonymous namespace
+
+C2IgbaBlockPoolData::C2IgbaBlockPoolData(
+        const AHardwareBuffer *buffer,
+        const std::shared_ptr<C2IGBA> &igba) : mOwned(true), mBuffer(buffer), mIgba(igba) {
+    CHECK(mBuffer);
+    AHardwareBuffer_acquire(const_cast<AHardwareBuffer *>(mBuffer));
+}
+
+C2IgbaBlockPoolData::~C2IgbaBlockPoolData() {
+    CHECK(mBuffer);
+    if (mOwned) {
+        if (__builtin_available(android __ANDROID_API_T__, *)) {
+            auto igba = mIgba.lock();
+            if (igba) {
+                uint64_t origId;
+                CHECK(AHardwareBuffer_getId(mBuffer, &origId) == ::android::OK);
+                bool aidlRet = true;
+                ::ndk::ScopedAStatus status = igba->deallocate(origId, &aidlRet);
+                if (!status.isOk() || !aidlRet) {
+                    ALOGW("AHwb destruction notifying failure %d(%d)", status.isOk(), aidlRet);
+                }
+            }
+        }
+    }
+    AHardwareBuffer_release(const_cast<AHardwareBuffer *>(mBuffer));
+}
+
+C2IgbaBlockPoolData::type_t C2IgbaBlockPoolData::getType() const {
+    return TYPE_AHWBUFFER;
+}
+
+void C2IgbaBlockPoolData::getAHardwareBuffer(AHardwareBuffer **pBuf) const {
+    *pBuf = const_cast<AHardwareBuffer *>(mBuffer);
+}
+
+void C2IgbaBlockPoolData::disown() {
+    mOwned = false;
+}
+
+std::shared_ptr<C2GraphicBlock> _C2BlockFactory::CreateGraphicBlock(AHardwareBuffer *ahwb) {
+    // TODO: get proper allocator? and synchronization? or allocator-less?
+    static std::shared_ptr<C2AllocatorAhwb> sAllocator = std::make_shared<C2AllocatorAhwb>(0);
+    std::shared_ptr<C2GraphicBlock> block;
+    c2_status_t res = CreateGraphicBlockFromAhwb(
+            ahwb, std::static_pointer_cast<C2Allocator>(sAllocator), nullptr, &block);
+    if (res != C2_OK) {
+        return nullptr;
+    }
+    return block;
+}
+
+bool _C2BlockFactory::GetAHardwareBuffer(
+        const std::shared_ptr<const _C2BlockPoolData>& data,
+        AHardwareBuffer **pBuf) {
+    if (data && data->getType() == _C2BlockPoolData::TYPE_AHWBUFFER) {
+        const std::shared_ptr<const C2IgbaBlockPoolData> poolData =
+                std::static_pointer_cast<const C2IgbaBlockPoolData>(data);
+        poolData->getAHardwareBuffer(pBuf);
+        return true;
+    }
+    return false;
+}
+
+void _C2BlockFactory::DisownIgbaBlock(
+        const std::shared_ptr<_C2BlockPoolData>& data) {
+    if (data && data->getType() == _C2BlockPoolData::TYPE_AHWBUFFER) {
+        const std::shared_ptr<C2IgbaBlockPoolData> poolData =
+                std::static_pointer_cast<C2IgbaBlockPoolData>(data);
+        poolData->disown();
+    }
+}
+
+C2IgbaBlockPool::C2IgbaBlockPool(
+        const std::shared_ptr<C2Allocator> &allocator,
+        const std::shared_ptr<C2IGBA> &igba,
+        const local_id_t localId) : mAllocator(allocator), mIgba(igba), mLocalId(localId) {
+    if (!mIgba) {
+        mValid = false;
+        return;
+    }
+    // TODO: Remove IPC (This is a nested IPC call during c2aidl creatBlockPool().
+    ::ndk::ScopedFileDescriptor fd;
+    ::ndk::ScopedAStatus status = mIgba->getWaitableFd(&fd);
+    if (!status.isOk()) {
+        mValid = false;
+        return;
+    }
+    mWaitFence = _C2FenceFactory::CreatePipeFence(fd.release());
+    if (!mWaitFence.valid()) {
+        mValid = false;
+        return;
+    }
+    mValid = true;
+}
+
+c2_status_t C2IgbaBlockPool::fetchGraphicBlock(
+        uint32_t width, uint32_t height, uint32_t format,
+        C2MemoryUsage usage, std::shared_ptr<C2GraphicBlock> *block) {
+    uint64_t origId;
+    C2Fence fence;
+    c2_status_t res = _fetchGraphicBlock(
+            width, height, format, usage, kBlockingFetchTimeoutNs, &origId, block, &fence);
+
+    if (res == C2_BLOCKING) {
+        return C2_TIMED_OUT;
+    }
+    if (res != C2_OK) {
+        return res;
+    }
+    // TODO: bundle the fence to the block. Are API changes required?
+    res = fence.wait(kSyncFenceWaitNs);
+    if (res != C2_OK) {
+        bool aidlRet = true;
+        ::ndk::ScopedAStatus status = mIgba->deallocate(origId, &aidlRet);
+        ALOGE("Waiting a sync fence failed %d aidl(%d: %d)",
+              res, status.isOk(), aidlRet);
+    }
+    return C2_OK;
+}
+
+c2_status_t C2IgbaBlockPool::fetchGraphicBlock(
+        uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
+        std::shared_ptr<C2GraphicBlock> *block, C2Fence *fence) {
+    uint64_t origId;
+    return _fetchGraphicBlock(width, height, format, usage, 0LL, &origId, block, fence);
+}
+
+c2_status_t C2IgbaBlockPool::_fetchGraphicBlock(
+        uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
+        c2_nsecs_t timeoutNs,
+        uint64_t *origId,
+        std::shared_ptr<C2GraphicBlock> *block,
+        C2Fence *fence) {
+    if (!mValid) {
+        return C2_BAD_STATE;
+    }
+    if (__builtin_available(android __ANDROID_API_T__, *)) {
+        c2_status_t waitRes = mWaitFence.wait(timeoutNs);
+        switch (waitRes) {
+            case C2_CANCELED: {
+                *fence = mWaitFence;
+                return C2_BLOCKING;
+            }
+            case C2_TIMED_OUT: {
+                *fence = mWaitFence;
+                return C2_BLOCKING;
+            }
+            case C2_OK:
+                break;
+            default: { // C2_BAD_STATE
+                mValid = false;
+                return C2_BAD_STATE;
+            }
+        }
+
+        ::android::C2AndroidMemoryUsage memUsage{usage};
+        C2IGBA::Description desc{
+            ToAidl(width), ToAidl(height), ToAidl(format), ToAidl(memUsage.asGrallocUsage())};
+        C2IGBA::Allocation allocation;
+        ::ndk::ScopedAStatus status = mIgba->allocate(desc, &allocation);
+        if (!status.isOk()) {
+            binder_exception_t ex = status.getExceptionCode();
+            if (ex == EX_SERVICE_SPECIFIC) {
+                c2_status_t err = static_cast<c2_status_t>(status.getServiceSpecificError());
+                if (err == C2_BLOCKING) {
+                    *fence = mWaitFence;
+                }
+                return err;
+            } else {
+                ALOGW("igba::allocate transaction failed: %d", ex);
+                return C2_CORRUPTED;
+            }
+        }
+
+        *fence = _C2FenceFactory::CreateSyncFence(allocation.fence.release());
+        AHardwareBuffer *ahwb = allocation.buffer.release(); // This is acquired.
+        CHECK(AHardwareBuffer_getId(ahwb, origId) == ::android::OK);
+        c2_status_t res = CreateGraphicBlockFromAhwb(ahwb, mAllocator, mIgba, block);
+        AHardwareBuffer_release(ahwb);
+        if (res != C2_OK) {
+            bool aidlRet = true;
+            ::ndk::ScopedAStatus status = mIgba->deallocate(*origId, &aidlRet);
+            ALOGE("We got AHWB via AIDL but failed to created C2GraphicBlock err(%d) aidl(%d, %d)",
+                  res, status.isOk(), aidlRet);
+        }
+        return res;
+    } else {
+        return C2_OMITTED;
+    }
+}
+
+void C2IgbaBlockPool::invalidate() {
+    mValid = false;
+}
diff --git a/media/libaaudio/fuzzer/Android.bp b/media/libaaudio/fuzzer/Android.bp
index 3393930..ee53717 100644
--- a/media/libaaudio/fuzzer/Android.bp
+++ b/media/libaaudio/fuzzer/Android.bp
@@ -68,8 +68,16 @@
     ],
     fuzz_config: {
         cc: [
-            "android-media-fuzzing-reports@google.com",
+            "android-audio-fuzzing-reports@google.com",
         ],
         componentid: 155276,
+        hotlists: [
+            "4593311",
+        ],
+        description: "The fuzzer targets the APIs of libaaudio",
+        vector: "local_no_privileges_required",
+        service_privilege: "privileged",
+        users: "multi_user",
+        fuzzed_code_usage: "shipped",
     },
 }
diff --git a/media/libaudioclient/aidl/fuzzer/Android.bp b/media/libaudioclient/aidl/fuzzer/Android.bp
index 67258d9..6093933 100644
--- a/media/libaudioclient/aidl/fuzzer/Android.bp
+++ b/media/libaudioclient/aidl/fuzzer/Android.bp
@@ -19,63 +19,57 @@
     static_libs: [
         "android.hardware.audio.common@7.0-enums",
         "effect-aidl-cpp",
-        "liblog",
         "libcgrouprc",
         "libcgrouprc_format",
+        "libfakeservicemanager",
         "libjsoncpp",
+        "liblog",
         "libmediametricsservice",
         "libmedia_helper",
         "libprocessgroup",
         "shared-file-region-aidl-cpp",
-        "libfakeservicemanager"
     ],
     shared_libs: [
-        "libaudioclient",
-        "libaudioflinger",
-        "libmediautils",
-        "libnblog",
-        "libaudioprocessing",
-        "libnbaio",
-        "libpowermanager",
-        "libvibrator",
-        "packagemanager_aidl-cpp",
         "android.hardware.audio.common-util",
         "audioclient-types-aidl-cpp",
-        "audioflinger-aidl-cpp",
         "audiopolicy-aidl-cpp",
         "audiopolicy-types-aidl-cpp",
         "av-types-aidl-cpp",
         "capture_state_listener-aidl-cpp",
+        "framework-permission-aidl-cpp",
+        "libaudioclient",
+        "audioflinger-aidl-cpp",
+        "libaudioflinger",
         "libaudioclient_aidl_conversion",
         "libaudiofoundation",
         "libaudiomanager",
         "libaudiopolicy",
         "libaudioutils",
-        "libdl",
-        "libxml2",
-        "mediametricsservice-aidl-cpp",
-        "framework-permission-aidl-cpp",
-        "libvndksupport",
-        "libmediametrics",
-        "libfakeservicemanager",
-        "libactivitymanager_aidl",
-        "libheadtracking",
         "libaudiopolicyservice",
-        "libsensorprivacy",
         "libaudiopolicymanagerdefault",
         "libaudiohal",
-        "libhidlbase",
-        "libpermission",
-        "libaudiohal@7.0",
+        "libaudioprocessing",
+        "libactivitymanager_aidl",
+        "libdl",
+        "libheadtracking",
+        "libmediautils",
+        "libmediametrics",
+        "libnblog",
+        "libnbaio",
+        "libpowermanager",
+        "libvibrator",
+        "libvndksupport",
+        "libxml2",
+        "mediametricsservice-aidl-cpp",
+        "packagemanager_aidl-cpp",
     ],
     header_libs: [
         "libaudiopolicymanager_interface_headers",
-        "libbinder_headers",
         "libaudiofoundation_headers",
-        "libmedia_headers",
         "libaudiohal_headers",
         "libaudioflinger_headers",
-        "mediautils_headers",
+        "libbinder_headers",
+        "libmedia_headers",
     ],
      fuzz_config: {
         cc: [
diff --git a/media/libaudioclient/aidl/fuzzer/audioflinger_aidl_fuzzer.cpp b/media/libaudioclient/aidl/fuzzer/audioflinger_aidl_fuzzer.cpp
index fac5f53..f99cc3b 100644
--- a/media/libaudioclient/aidl/fuzzer/audioflinger_aidl_fuzzer.cpp
+++ b/media/libaudioclient/aidl/fuzzer/audioflinger_aidl_fuzzer.cpp
@@ -15,204 +15,74 @@
  *
  */
 #include <AudioFlinger.h>
-#include <ISchedulingPolicyService.h>
-#include <fakeservicemanager/FakeServiceManager.h>
 #include <android-base/logging.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_process.h>
 #include <android/media/IAudioPolicyService.h>
-#include <binder/IActivityManager.h>
-#include <binder/IPermissionController.h>
-#include <binder/IServiceManager.h>
-#include <binder/PermissionController.h>
+#include <fakeservicemanager/FakeServiceManager.h>
 #include <fuzzbinder/libbinder_driver.h>
+#include <fuzzbinder/random_binder.h>
 #include <fuzzer/FuzzedDataProvider.h>
 #include <media/IAudioFlinger.h>
-#include <mediautils/SchedulingPolicyService.h>
-#include <sensorprivacy/SensorPrivacyManager.h>
 #include <service/AudioPolicyService.h>
 
 using namespace android;
 using namespace android::binder;
 using android::fuzzService;
 
-static sp<media::IAudioFlingerService> gAudioFlingerService;
+[[clang::no_destroy]] static std::once_flag gSmOnce;
+sp<FakeServiceManager> gFakeServiceManager;
 
-class FuzzerSchedulingPolicyService : public BnInterface<ISchedulingPolicyService> {
-    int32_t requestPriority(int32_t /*pid_t*/, int32_t /*tid*/, int32_t /*prio*/, bool /*isForApp*/,
-                            bool /*asynchronous*/) {
-        return 0;
+bool addService(const String16& serviceName, const sp<FakeServiceManager>& fakeServiceManager,
+                FuzzedDataProvider& fdp) {
+    sp<IBinder> binder = getRandomBinder(&fdp);
+    if (binder == nullptr) {
+        return false;
     }
-
-    int32_t requestCpusetBoost(bool /*enable*/, const sp<IBinder>& /*client*/) { return 0; }
-};
-
-class FuzzerPermissionController : public BnInterface<IPermissionController> {
-  public:
-    bool checkPermission(const String16& /*permission*/, int32_t /*pid*/, int32_t /*uid*/) {
-        return true;
-    }
-    int32_t noteOp(const String16& /*op*/, int32_t /*uid*/, const String16& /*packageName*/) {
-        return 0;
-    }
-    void getPackagesForUid(const uid_t /*uid*/, Vector<String16>& /*packages*/) {}
-    bool isRuntimePermission(const String16& /*permission*/) { return true; }
-    int32_t getPackageUid(const String16& /*package*/, int /*flags*/) { return 0; }
-};
-
-class FuzzerSensorPrivacyManager : public BnInterface<hardware::ISensorPrivacyManager> {
-  public:
-    Status supportsSensorToggle(int32_t /*toggleType*/, int32_t /*sensor*/,
-                                bool* /*_aidl_return*/) override {
-        return Status::fromStatusT(UNKNOWN_TRANSACTION);
-    }
-    Status addSensorPrivacyListener(
-            const sp<hardware::ISensorPrivacyListener>& /*listener*/) override {
-        return Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-    }
-    Status addToggleSensorPrivacyListener(
-            const sp<hardware::ISensorPrivacyListener>& /*listener*/) override {
-        return Status::fromStatusT(UNKNOWN_TRANSACTION);
-    }
-    Status removeSensorPrivacyListener(
-            const sp<hardware::ISensorPrivacyListener>& /*listener*/) override {
-        return Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-    }
-    Status removeToggleSensorPrivacyListener(
-            const sp<hardware::ISensorPrivacyListener>& /*listener*/) override {
-        return Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-    }
-    Status isSensorPrivacyEnabled(bool* /*_aidl_return*/) override {
-        return Status::fromStatusT(UNKNOWN_TRANSACTION);
-    }
-    Status isCombinedToggleSensorPrivacyEnabled(int32_t /*sensor*/,
-                                                bool* /*_aidl_return*/) override {
-        return Status::fromStatusT(UNKNOWN_TRANSACTION);
-    }
-    Status isToggleSensorPrivacyEnabled(int32_t /*toggleType*/, int32_t /*sensor*/,
-                                        bool* /*_aidl_return*/) override {
-        return Status::fromStatusT(UNKNOWN_TRANSACTION);
-    }
-    Status setSensorPrivacy(bool /*enable*/) override {
-        return Status::fromStatusT(UNKNOWN_TRANSACTION);
-    }
-    Status setToggleSensorPrivacy(int32_t /*userId*/, int32_t /*source*/, int32_t /*sensor*/,
-                                  bool /*enable*/) override {
-        return Status::fromStatusT(UNKNOWN_TRANSACTION);
-    }
-    Status setToggleSensorPrivacyForProfileGroup(int32_t /*userId*/, int32_t /*source*/,
-                                                 int32_t /*sensor*/, bool /*enable*/) override {
-        return Status::fromStatusT(UNKNOWN_TRANSACTION);
-    }
-};
-
-class FuzzerActivityManager : public BnInterface<IActivityManager> {
-  public:
-    int32_t openContentUri(const String16& /*stringUri*/) override { return 0; }
-
-    status_t registerUidObserver(const sp<IUidObserver>& /*observer*/, const int32_t /*event*/,
-                                 const int32_t /*cutpoint*/,
-                                 const String16& /*callingPackage*/) override {
-        return OK;
-    }
-
-    status_t unregisterUidObserver(const sp<IUidObserver>& /*observer*/) override { return OK; }
-
-    bool isUidActive(const uid_t /*uid*/, const String16& /*callingPackage*/) override {
-        return true;
-    }
-
-    int32_t getUidProcessState(const uid_t /*uid*/, const String16& /*callingPackage*/) override {
-        return ActivityManager::PROCESS_STATE_UNKNOWN;
-    }
-
-    status_t checkPermission(const String16& /*permission*/, const pid_t /*pid*/,
-                             const uid_t /*uid*/, int32_t* /*outResult*/) override {
-        return NO_ERROR;
-    }
-
-    status_t registerUidObserverForUids(const sp<IUidObserver>& /*observer*/ ,
-                                        const int32_t /*event*/ ,
-                                        const int32_t /*cutpoint*/ ,
-                                        const String16& /*callingPackage*/ ,
-                                        const int32_t uids[] ,
-                                        size_t /*nUids*/ ,
-                                        /*out*/ sp<IBinder>& /*observerToken*/ ) {
-        (void)uids;
-        return OK;
-    }
-
-    status_t addUidToObserver(const sp<IBinder>& /*observerToken*/ ,
-                              const String16& /*callingPackage*/ ,
-                              int32_t /*uid*/ ) override {
-        return NO_ERROR;
-    }
-
-    status_t removeUidFromObserver(const sp<IBinder>& /*observerToken*/ ,
-                                   const String16& /*callingPackage*/ ,
-                                   int32_t /*uid*/ ) override {
-        return NO_ERROR;
-    }
-
-    status_t logFgsApiBegin(int32_t /*apiType*/ , int32_t /*appUid*/ ,
-                            int32_t /*appPid*/ ) override {
-        return NO_ERROR;
-    }
-    status_t logFgsApiEnd(int32_t /*apiType*/ , int32_t /*appUid*/ ,
-                          int32_t /*appPid*/ ) override {
-        return NO_ERROR;
-    }
-    status_t logFgsApiStateChanged(int32_t /*apiType*/ , int32_t /*state*/ ,
-                                   int32_t /*appUid*/ ,
-                                   int32_t /*appPid*/ ) override {
-        return NO_ERROR;
-    }
-};
-
-extern "C" int LLVMFuzzerInitialize(int* /* argc */, char*** /* argv */) {
-    /* Create a FakeServiceManager instance and add required services */
-    sp<FakeServiceManager> fakeServiceManager = new FakeServiceManager();
-    setDefaultServiceManager(fakeServiceManager);
-    ABinderProcess_setThreadPoolMaxThreadCount(0);
-    sp<FuzzerActivityManager> am = new FuzzerActivityManager();
-    fakeServiceManager->addService(String16("activity"), IInterface::asBinder(am));
-
-    sp<FuzzerSensorPrivacyManager> sensorPrivacyManager = new FuzzerSensorPrivacyManager();
-    fakeServiceManager->addService(String16("sensor_privacy"),
-                                   IInterface::asBinder(sensorPrivacyManager));
-    sp<FuzzerPermissionController> permissionController = new FuzzerPermissionController();
-    fakeServiceManager->addService(String16("permission"),
-                                   IInterface::asBinder(permissionController));
-
-    sp<FuzzerSchedulingPolicyService> schedulingService = new FuzzerSchedulingPolicyService();
-    fakeServiceManager->addService(String16("scheduling_policy"),
-                                   IInterface::asBinder(schedulingService));
-
-    const auto audioFlingerObj = sp<AudioFlinger>::make();
-    const auto afAdapter = sp<AudioFlingerServerAdapter>::make(audioFlingerObj);
-
-    fakeServiceManager->addService(String16(IAudioFlinger::DEFAULT_SERVICE_NAME),
-                                   IInterface::asBinder(afAdapter), false /* allowIsolated */,
-                                   IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT);
-
-    const auto audioPolicyService = sp<AudioPolicyService>::make();
-    fakeServiceManager->addService(String16("media.audio_policy"), audioPolicyService,
-                                   false /* allowIsolated */,
-                                   IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT);
-
-    sp<IBinder> binder =
-            fakeServiceManager->getService(String16(IAudioFlinger::DEFAULT_SERVICE_NAME));
-    gAudioFlingerService = interface_cast<media::IAudioFlingerService>(binder);
-    return 0;
+    CHECK_EQ(NO_ERROR, fakeServiceManager->addService(serviceName, binder));
+    return true;
 }
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
-    if (!gAudioFlingerService) {
-        return 0;
+    FuzzedDataProvider fdp(data, size);
+
+    std::call_once(gSmOnce, [&] {
+        /* Create a FakeServiceManager instance and add required services */
+        gFakeServiceManager = sp<FakeServiceManager>::make();
+        setDefaultServiceManager(gFakeServiceManager);
+    });
+    gFakeServiceManager->clear();
+
+    for (const char* service :
+         {"activity", "sensor_privacy", "permission", "scheduling_policy",
+          "android.hardware.audio.core.IConfig", "batterystats", "media.metrics"}) {
+        if (!addService(String16(service), gFakeServiceManager, fdp)) {
+            return 0;
+        }
     }
 
-    fuzzService(media::IAudioFlingerService::asBinder(gAudioFlingerService),
-                FuzzedDataProvider(data, size));
+    const auto audioFlinger = sp<AudioFlinger>::make();
+    const auto afAdapter = sp<AudioFlingerServerAdapter>::make(audioFlinger);
+
+    CHECK_EQ(NO_ERROR,
+             gFakeServiceManager->addService(
+                     String16(IAudioFlinger::DEFAULT_SERVICE_NAME), IInterface::asBinder(afAdapter),
+                     false /* allowIsolated */, IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT));
+
+    AudioSystem::get_audio_flinger_for_fuzzer();
+    const auto audioPolicyService = sp<AudioPolicyService>::make();
+
+    CHECK_EQ(NO_ERROR,
+             gFakeServiceManager->addService(String16("media.audio_policy"), audioPolicyService,
+                                             false /* allowIsolated */,
+                                             IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT));
+
+    sp<IBinder> audioFlingerServiceBinder =
+            gFakeServiceManager->getService(String16(IAudioFlinger::DEFAULT_SERVICE_NAME));
+    sp<media::IAudioFlingerService> audioFlingerService =
+            interface_cast<media::IAudioFlingerService>(audioFlingerServiceBinder);
+
+    fuzzService(media::IAudioFlingerService::asBinder(audioFlingerService), std::move(fdp));
 
     return 0;
 }
diff --git a/media/libaudioclient/fuzzer/Android.bp b/media/libaudioclient/fuzzer/Android.bp
index 6080314..fd3b0a8 100644
--- a/media/libaudioclient/fuzzer/Android.bp
+++ b/media/libaudioclient/fuzzer/Android.bp
@@ -77,7 +77,7 @@
     ],
     fuzz_config: {
         cc: [
-            "android-media-fuzzing-reports@google.com",
+            "android-audio-fuzzing-reports@google.com",
         ],
         componentid: 155276,
         hotlists: [
diff --git a/media/libmedia/include/media/mediametadataretriever.h b/media/libmedia/include/media/mediametadataretriever.h
index 9074574..116ed9a 100644
--- a/media/libmedia/include/media/mediametadataretriever.h
+++ b/media/libmedia/include/media/mediametadataretriever.h
@@ -97,18 +97,12 @@
             const sp<IDataSource>& dataSource, const char *mime = NULL);
     sp<IMemory> getFrameAtTime(int64_t timeUs, int option,
             int colorFormat, bool metaOnly = false);
-    sp<IMemory> getFrameAtTime(int64_t timeUs, int option,
-            bool metaOnly = false);
     sp<IMemory> getImageAtIndex(int index,
             int colorFormat, bool metaOnly = false, bool thumbnail = false);
-    sp<IMemory> getImageAtIndex(int index,
-            bool metaOnly = false, bool thumbnail = false);
     sp<IMemory> getImageRectAtIndex(
             int index, int colorFormat, int left, int top, int right, int bottom);
     sp<IMemory>  getFrameAtIndex(
             int index, int colorFormat, bool metaOnly = false);
-    sp<IMemory>  getFrameAtIndex(
-            int index, bool metaOnly = false);
     sp<IMemory> extractAlbumArt();
     const char* extractMetadata(int keyCode);
 
diff --git a/media/libmedia/mediametadataretriever.cpp b/media/libmedia/mediametadataretriever.cpp
index 9731ea4..40fd022 100644
--- a/media/libmedia/mediametadataretriever.cpp
+++ b/media/libmedia/mediametadataretriever.cpp
@@ -138,11 +138,6 @@
 }
 
 sp<IMemory> MediaMetadataRetriever::getFrameAtTime(
-        int64_t timeUs, int option, bool metaOnly) {
-    return getFrameAtTime(timeUs, option, HAL_PIXEL_FORMAT_RGB_565, metaOnly);
-}
-
-sp<IMemory> MediaMetadataRetriever::getFrameAtTime(
         int64_t timeUs, int option, int colorFormat, bool metaOnly)
 {
     ALOGV("getFrameAtTime: time(%" PRId64 " us) option(%d) colorFormat(%d) metaOnly(%d)",
@@ -156,11 +151,6 @@
 }
 
 sp<IMemory> MediaMetadataRetriever::getImageAtIndex(
-        int index, bool metaOnly, bool thumbnail) {
-    return getImageAtIndex(index, HAL_PIXEL_FORMAT_RGB_565, metaOnly, thumbnail);
-}
-
-sp<IMemory> MediaMetadataRetriever::getImageAtIndex(
         int index, int colorFormat, bool metaOnly, bool thumbnail) {
     ALOGV("getImageAtIndex: index(%d) colorFormat(%d) metaOnly(%d) thumbnail(%d)",
             index, colorFormat, metaOnly, thumbnail);
@@ -186,11 +176,6 @@
 }
 
 sp<IMemory>  MediaMetadataRetriever::getFrameAtIndex(
-        int index, bool metaOnly) {
-    return getFrameAtIndex(index, HAL_PIXEL_FORMAT_RGB_565, metaOnly);
-}
-
-sp<IMemory>  MediaMetadataRetriever::getFrameAtIndex(
         int index, int colorFormat, bool metaOnly) {
     ALOGV("getFrameAtIndex: index(%d), colorFormat(%d) metaOnly(%d)",
             index, colorFormat, metaOnly);
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 6765a6f..98400b3 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -2212,7 +2212,9 @@
         mediametrics_setInt32(nextMetricsHandle, kCodecEncoder,
                               (flags & CONFIGURE_FLAG_ENCODE) ? 1 : 0);
 
-        mediametrics_setCString(nextMetricsHandle, kCodecLogSessionId, mLogSessionId.c_str());
+        if (!mLogSessionId.empty()) {
+            mediametrics_setCString(nextMetricsHandle, kCodecLogSessionId, mLogSessionId.c_str());
+        }
 
         // moved here from ::init()
         mediametrics_setCString(nextMetricsHandle, kCodecCodec, mInitName.c_str());
diff --git a/media/libstagefright/rtsp/JitterCalculator.cpp b/media/libstagefright/rtsp/JitterCalculator.cpp
index 93afe9c..5411a22 100644
--- a/media/libstagefright/rtsp/JitterCalculator.cpp
+++ b/media/libstagefright/rtsp/JitterCalculator.cpp
@@ -47,7 +47,14 @@
     int64_t scheduledTimeUs = ((int32_t)diff) * 1000000ll / mClockRate;
     int64_t elapsedTimeUs = arrivalTimeUs - mFirstArrivalTimeUs;
     int64_t correctionTimeUs = elapsedTimeUs - scheduledTimeUs; // additional propagation delay;
-    mBaseJitterUs = (mBaseJitterUs * 15 + correctionTimeUs) / 16;
+
+    // We want to approximate correctionTimeUs by slowly (1:15) averaging into jitter base, but
+    // both correction time and base jitter can roll over. Adjust correctionTime to be close to
+    // base jitter. Accomplish this by calculating the closest 32-bit delta (positive or
+    // negative) and applying 1/16th of it to the base jitter.
+    int32_t correctionDiff;
+    (void)__builtin_sub_overflow(correctionTimeUs, mBaseJitterUs, &correctionDiff);
+    mBaseJitterUs = int32_t(int64_t(mBaseJitterUs) + correctionDiff / 16);
     ALOGV("BaseJitterUs : %lld \t\t correctionTimeUs : %lld",
             (long long)mBaseJitterUs, (long long)correctionTimeUs);
 }
diff --git a/media/ndk/fuzzer/ndk_async_codec_fuzzer.cpp b/media/ndk/fuzzer/ndk_async_codec_fuzzer.cpp
index 28a38fe..5c860a8 100644
--- a/media/ndk/fuzzer/ndk_async_codec_fuzzer.cpp
+++ b/media/ndk/fuzzer/ndk_async_codec_fuzzer.cpp
@@ -15,6 +15,7 @@
  */
 #include <NdkMediaCodecFuzzerBase.h>
 #include <media/NdkMediaFormatPriv.h>
+#include <functional>
 #include <mutex>
 #include <queue>
 #include <thread>
diff --git a/media/ndk/fuzzer/ndk_crypto_fuzzer.cpp b/media/ndk/fuzzer/ndk_crypto_fuzzer.cpp
index a759ae7..304879d 100644
--- a/media/ndk/fuzzer/ndk_crypto_fuzzer.cpp
+++ b/media/ndk/fuzzer/ndk_crypto_fuzzer.cpp
@@ -16,6 +16,7 @@
 
 #include <fuzzer/FuzzedDataProvider.h>
 #include <media/NdkMediaCrypto.h>
+#include <functional>
 
 constexpr size_t kMaxString = 256;
 constexpr size_t kMinBytes = 0;
diff --git a/media/ndk/fuzzer/ndk_image_reader_fuzzer.cpp b/media/ndk/fuzzer/ndk_image_reader_fuzzer.cpp
index 6c11798..6450742 100644
--- a/media/ndk/fuzzer/ndk_image_reader_fuzzer.cpp
+++ b/media/ndk/fuzzer/ndk_image_reader_fuzzer.cpp
@@ -18,6 +18,7 @@
 #include <fuzzer/FuzzedDataProvider.h>
 #include <gui/BufferQueue.h>
 #include <media/NdkImageReader.h>
+#include <functional>
 
 constexpr int32_t kMaxSize = INT_MAX;
 constexpr int32_t kMinSize = 1;
diff --git a/media/utils/include/mediautils/ExtendedAccumulator.h b/media/utils/include/mediautils/ExtendedAccumulator.h
index 7e3e170..30045f3 100644
--- a/media/utils/include/mediautils/ExtendedAccumulator.h
+++ b/media/utils/include/mediautils/ExtendedAccumulator.h
@@ -48,9 +48,9 @@
 
   public:
     enum class Wrap {
-        NORMAL = 0,
-        UNDERFLOW = 1,
-        OVERFLOW = 2,
+        Normal = 0,
+        Underflow = 1,
+        Overflow = 2,
     };
 
     using UnsignedInt = Integral;
@@ -63,11 +63,11 @@
     std::pair<SignedInt, Wrap> poll(UnsignedInt value) {
         auto acc = mAccumulated.load(std::memory_order_relaxed);
         const auto bottom_bits = static_cast<UnsignedInt>(acc);
-        std::pair<SignedInt, Wrap> res = {0, Wrap::NORMAL};
+        std::pair<SignedInt, Wrap> res = {0, Wrap::Normal};
         const bool overflow = __builtin_sub_overflow(value, bottom_bits, &res.first);
 
         if (overflow) {
-            res.second = (res.first > 0) ? Wrap::OVERFLOW : Wrap::UNDERFLOW;
+            res.second = (res.first > 0) ? Wrap::Overflow : Wrap::Underflow;
         }
 
         const bool acc_overflow = __builtin_add_overflow(acc, res.first, &acc);
diff --git a/media/utils/tests/extended_accumulator_tests.cpp b/media/utils/tests/extended_accumulator_tests.cpp
index e243e7e..2591df0 100644
--- a/media/utils/tests/extended_accumulator_tests.cpp
+++ b/media/utils/tests/extended_accumulator_tests.cpp
@@ -68,10 +68,10 @@
     EXPECT_EQ(result, delta);
 
     // Test overflow/underflow event reporting.
-    if (next < base) EXPECT_EQ(TestDetect::Wrap::UNDERFLOW, status);
+    if (next < base) EXPECT_EQ(TestDetect::Wrap::Underflow, status);
     else if (next > base + std::numeric_limits<TestUInt>::max())
-        EXPECT_EQ(TestDetect::Wrap::OVERFLOW, status);
-    else EXPECT_EQ(TestDetect::Wrap::NORMAL, status);
+        EXPECT_EQ(TestDetect::Wrap::Overflow, status);
+    else EXPECT_EQ(TestDetect::Wrap::Normal, status);
 }
 
 // Test this utility on every combination of prior and update value for the
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index e506ca6..b72f12b 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3899,6 +3899,18 @@
 {
     aflog::setThreadWriter(mNBLogWriter.get());
 
+    if (mType == SPATIALIZER) {
+        const pid_t tid = getTid();
+        if (tid == -1) {  // odd: we are here, we must be a running thread.
+            ALOGW("%s: Cannot update Spatializer mixer thread priority, no tid", __func__);
+        } else {
+            const int priorityBoost = requestSpatializerPriority(getpid(), tid);
+            if (priorityBoost > 0) {
+                stream()->setHalThreadPriority(priorityBoost);
+            }
+        }
+    }
+
     Vector<sp<IAfTrack>> tracksToRemove;
 
     mStandbyTimeNs = systemTime();
@@ -7767,21 +7779,6 @@
 {
 }
 
-void SpatializerThread::onFirstRef() {
-    MixerThread::onFirstRef();
-
-    const pid_t tid = getTid();
-    if (tid == -1) {
-        // Unusual: PlaybackThread::onFirstRef() should set the threadLoop running.
-        ALOGW("%s: Cannot update Spatializer mixer thread priority, not running", __func__);
-    } else {
-        const int priorityBoost = requestSpatializerPriority(getpid(), tid);
-        if (priorityBoost > 0) {
-            stream()->setHalThreadPriority(priorityBoost);
-        }
-    }
-}
-
 void SpatializerThread::setHalLatencyMode_l() {
     // if mSupportedLatencyModes is empty, the HAL stream does not support
     // latency mode control and we can exit.
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 724a46d..6a4add4 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -1891,9 +1891,6 @@
 
     bool hasFastMixer() const final { return false; }
 
-            // RefBase
-    void onFirstRef() final;
-
     status_t setRequestedLatencyMode(audio_latency_mode_t mode) final EXCLUDES_ThreadBase_Mutex;
 
 protected:
diff --git a/services/audiopolicy/fuzzer/Android.bp b/services/audiopolicy/fuzzer/Android.bp
index c4b3751..fd240e3 100644
--- a/services/audiopolicy/fuzzer/Android.bp
+++ b/services/audiopolicy/fuzzer/Android.bp
@@ -63,7 +63,7 @@
     ],
     data: [":audiopolicyfuzzer_configuration_files"],
     fuzz_config: {
-        cc: ["mnaganov@google.com"],
+        cc: ["android-audio-fuzzing-reports@google.com"],
         componentid: 155276,
         hotlists: [
             "4593311",
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index 6ce4d3a..937d755 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -35,6 +35,7 @@
 #include <android/binder_manager.h>
 #include <android/hidl/manager/1.2/IServiceManager.h>
 #include <hidl/ServiceManagement.h>
+#include <com_android_internal_camera_flags.h>
 #include <functional>
 #include <camera_metadata_hidden.h>
 #include <android-base/parseint.h>
@@ -57,6 +58,8 @@
 using std::literals::chrono_literals::operator""s;
 using hardware::camera2::utils::CameraIdAndSessionConfiguration;
 
+namespace flags = com::android::internal::camera::flags;
+
 namespace {
 const bool kEnableLazyHal(property_get_bool("ro.camera.enableLazyHal", false));
 const std::string kExternalProviderName = "external/0";
@@ -1968,9 +1971,15 @@
 status_t CameraProviderManager::tryToInitializeAidlProviderLocked(
         const std::string& providerName, const sp<ProviderInfo>& providerInfo) {
     using aidl::android::hardware::camera::provider::ICameraProvider;
+
+    AIBinder *binder = nullptr;
+    if (flags::lazy_aidl_wait_for_service()) {
+        binder = AServiceManager_waitForService(providerName.c_str());
+    } else {
+        binder = AServiceManager_getService(providerName.c_str());
+    }
     std::shared_ptr<ICameraProvider> interface =
-            ICameraProvider::fromBinder(ndk::SpAIBinder(
-                    AServiceManager_getService(providerName.c_str())));
+            ICameraProvider::fromBinder(ndk::SpAIBinder(binder));
 
     if (interface == nullptr) {
         ALOGW("%s: AIDL Camera provider HAL '%s' is not actually available", __FUNCTION__,
@@ -2006,15 +2015,18 @@
     bool providerPresent = false;
     bool preexisting =
             (mAidlProviderWithBinders.find(newProvider) != mAidlProviderWithBinders.end());
-
-    // We need to use the extracted provider name here since 'newProvider' has
-    // the fully qualified name of the provider service in case of AIDL. We want
-    // just instance name.
     using aidl::android::hardware::camera::provider::ICameraProvider;
-    std::string extractedProviderName =
+    std::string providerNameUsed  =
             newProvider.substr(std::string(ICameraProvider::descriptor).size() + 1);
+    if (flags::lazy_aidl_wait_for_service()) {
+        // 'newProvider' has the fully qualified name of the provider service in case of AIDL.
+        // ProviderInfo::mProviderName also has the fully qualified name - so we just compare them
+        // here.
+        providerNameUsed = newProvider;
+    }
+
     for (const auto& providerInfo : mProviders) {
-        if (providerInfo->mProviderName == extractedProviderName) {
+        if (providerInfo->mProviderName == providerNameUsed) {
             ALOGW("%s: Camera provider HAL with name '%s' already registered",
                     __FUNCTION__, newProvider.c_str());
             // Do not add new instances for lazy HAL external provider or aidl
@@ -2031,7 +2043,7 @@
     }
 
     sp<AidlProviderInfo> providerInfo =
-            new AidlProviderInfo(extractedProviderName, providerInstance, this);
+            new AidlProviderInfo(providerNameUsed, providerInstance, this);
 
     if (!providerPresent) {
         status_t res = tryToInitializeAidlProviderLocked(newProvider, providerInfo);
@@ -2111,6 +2123,9 @@
             if (providerInfo->mProviderName == removedProviderName) {
                 IPCTransport providerTransport = providerInfo->getIPCTransport();
                 std::string removedAidlProviderName = getFullAidlProviderName(removedProviderName);
+                if (flags::lazy_aidl_wait_for_service()) {
+                    removedAidlProviderName = removedProviderName;
+                }
                 switch(providerTransport) {
                     case IPCTransport::HIDL:
                         return tryToInitializeHidlProviderLocked(removedProviderName, providerInfo);
@@ -2280,7 +2295,13 @@
 }
 
 bool CameraProviderManager::ProviderInfo::isExternalLazyHAL() const {
-    return kEnableLazyHal && (mProviderName == kExternalProviderName);
+    std::string providerName = mProviderName;
+    if (flags::lazy_aidl_wait_for_service() && getIPCTransport() == IPCTransport::AIDL) {
+        using aidl::android::hardware::camera::provider::ICameraProvider;
+        providerName =
+                mProviderName.substr(std::string(ICameraProvider::descriptor).size() + 1);
+    }
+    return kEnableLazyHal && (providerName == kExternalProviderName);
 }
 
 status_t CameraProviderManager::ProviderInfo::dump(int fd, const Vector<String16>&) const {
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.h b/services/camera/libcameraservice/common/CameraProviderManager.h
index 48c1134..37a9ccb 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.h
+++ b/services/camera/libcameraservice/common/CameraProviderManager.h
@@ -489,7 +489,7 @@
                 CameraProviderManager *manager);
         ~ProviderInfo();
 
-        virtual IPCTransport getIPCTransport() = 0;
+        virtual IPCTransport getIPCTransport() const = 0;
 
         const std::string& getType() const;
 
diff --git a/services/camera/libcameraservice/common/aidl/AidlProviderInfo.cpp b/services/camera/libcameraservice/common/aidl/AidlProviderInfo.cpp
index 085b012..f5279aa 100644
--- a/services/camera/libcameraservice/common/aidl/AidlProviderInfo.cpp
+++ b/services/camera/libcameraservice/common/aidl/AidlProviderInfo.cpp
@@ -17,6 +17,7 @@
 #include "common/HalConversionsTemplated.h"
 #include "common/CameraProviderInfoTemplated.h"
 
+#include <com_android_internal_camera_flags.h>
 #include <cutils/properties.h>
 
 #include <aidlcommonsupport/NativeHandle.h>
@@ -34,7 +35,9 @@
 
 namespace android {
 
+namespace flags = com::android::internal::camera::flags;
 namespace SessionConfigurationUtils = ::android::camera3::SessionConfigurationUtils;
+namespace flags = com::android::internal::camera::flags;
 
 using namespace aidl::android::hardware;
 using namespace hardware::camera;
@@ -99,7 +102,14 @@
 status_t AidlProviderInfo::initializeAidlProvider(
         std::shared_ptr<ICameraProvider>& interface, int64_t currentDeviceState) {
 
-    status_t res = parseProviderName(mProviderName, &mType, &mId);
+    using aidl::android::hardware::camera::provider::ICameraProvider;
+    std::string parsedProviderName = mProviderName;
+    if (flags::lazy_aidl_wait_for_service()) {
+        parsedProviderName =
+                mProviderName.substr(std::string(ICameraProvider::descriptor).size() + 1);
+    }
+
+    status_t res = parseProviderName(parsedProviderName, &mType, &mId);
     if (res != OK) {
         ALOGE("%s: Invalid provider name, ignoring", __FUNCTION__);
         return BAD_VALUE;
@@ -274,10 +284,13 @@
         if (interface == nullptr) {
             ALOGV("Camera provider actually needs restart, calling getService(%s)",
                   mProviderName.c_str());
-            interface =
-                            ICameraProvider::fromBinder(
-                                    ndk::SpAIBinder(
-                                                AServiceManager_getService(mProviderName.c_str())));
+            AIBinder * binder = nullptr;
+            if (flags::lazy_aidl_wait_for_service()) {
+                binder = AServiceManager_waitForService(mProviderName.c_str());
+            } else {
+                binder = AServiceManager_getService(mProviderName.c_str());
+            }
+            interface = ICameraProvider::fromBinder(ndk::SpAIBinder(binder));
 
             // Set all devices as ENUMERATING, provider should update status
             // to PRESENT after initializing.
@@ -494,12 +507,15 @@
                 __FUNCTION__, strerror(-res), res);
         return;
     }
-    res = fixupManualFlashStrengthControlTags();
-    if (OK != res) {
-        ALOGE("%s: Unable to fix up manual flash strength control tags: %s (%d)",
-                __FUNCTION__, strerror(-res), res);
-        return;
+    if (flags::camera_manual_flash_strength_control()) {
+        res = fixupManualFlashStrengthControlTags();
+        if (OK != res) {
+            ALOGE("%s: Unable to fix up manual flash strength control tags: %s (%d)",
+                    __FUNCTION__, strerror(-res), res);
+            return;
+        }
     }
+
     auto stat = addDynamicDepthTags();
     if (OK != stat) {
         ALOGE("%s: Failed appending dynamic depth tags: %s (%d)", __FUNCTION__, strerror(-stat),
diff --git a/services/camera/libcameraservice/common/aidl/AidlProviderInfo.h b/services/camera/libcameraservice/common/aidl/AidlProviderInfo.h
index 97a8fed..90bc627 100644
--- a/services/camera/libcameraservice/common/aidl/AidlProviderInfo.h
+++ b/services/camera/libcameraservice/common/aidl/AidlProviderInfo.h
@@ -49,7 +49,7 @@
 
     static void binderDied(void *cookie);
 
-    virtual IPCTransport getIPCTransport() override {return IPCTransport::AIDL;}
+    virtual IPCTransport getIPCTransport() const override {return IPCTransport::AIDL;}
 
     const std::shared_ptr<aidl::android::hardware::camera::provider::ICameraProvider>
     startProviderInterface();
diff --git a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
index 56c0c90..4197358 100644
--- a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
+++ b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
@@ -17,6 +17,7 @@
 #include "common/HalConversionsTemplated.h"
 #include "common/CameraProviderInfoTemplated.h"
 
+#include <com_android_internal_camera_flags.h>
 #include <cutils/properties.h>
 
 #include <android/hardware/ICameraService.h>
@@ -44,6 +45,7 @@
 
 using StatusListener = CameraProviderManager::StatusListener;
 using HalDeviceStatusType = android::hardware::camera::common::V1_0::CameraDeviceStatus;
+namespace flags = com::android::internal::camera::flags;
 
 using hardware::camera::provider::V2_5::DeviceState;
 using hardware::ICameraService;
@@ -613,12 +615,13 @@
                 __FUNCTION__, strerror(-res), res);
         return;
     }
-
-    res = fixupManualFlashStrengthControlTags();
-    if (OK != res) {
-        ALOGE("%s: Unable to fix up manual flash strength control tags: %s (%d)",
-                __FUNCTION__, strerror(-res), res);
-        return;
+    if (flags::camera_manual_flash_strength_control()) {
+        res = fixupManualFlashStrengthControlTags();
+        if (OK != res) {
+            ALOGE("%s: Unable to fix up manual flash strength control tags: %s (%d)",
+                    __FUNCTION__, strerror(-res), res);
+            return;
+        }
     }
 
     auto stat = addDynamicDepthTags();
diff --git a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.h b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.h
index e0f1646..fa6f4d4 100644
--- a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.h
+++ b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.h
@@ -45,7 +45,7 @@
             sp<hardware::camera::provider::V2_4::ICameraProvider>& interface,
             int64_t currentDeviceState);
 
-    IPCTransport getIPCTransport() override {return IPCTransport::HIDL;}
+    IPCTransport getIPCTransport() const override {return IPCTransport::HIDL;}
 
     const sp<hardware::camera::provider::V2_4::ICameraProvider> startProviderInterface();
 
diff --git a/services/oboeservice/fuzzer/Android.bp b/services/oboeservice/fuzzer/Android.bp
index 91ae511..0230935 100644
--- a/services/oboeservice/fuzzer/Android.bp
+++ b/services/oboeservice/fuzzer/Android.bp
@@ -68,8 +68,16 @@
     ],
     fuzz_config: {
         cc: [
-            "android-media-fuzzing-reports@google.com",
+            "android-audio-fuzzing-reports@google.com",
         ],
         componentid: 155276,
+        hotlists: [
+            "4593311",
+        ],
+        description: "The fuzzer targets the APIs of libaaudioservice",
+        vector: "local_no_privileges_required",
+        service_privilege: "privileged",
+        users: "multi_user",
+        fuzzed_code_usage: "shipped",
     },
 }