Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2107e8a5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "codecServiceRegistrant_fuzzer: Bug Fix" into main

parents eec973f9 baf7e055
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ cc_library {
        "com.android.media.swcodec",
    ],

    export_include_dirs: ["include"],

    srcs: [
        "CodecServiceRegistrant.cpp",
    ],
+15 −8
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@
#include <codec2/aidl/ComponentStore.h>
#include <codec2/aidl/ParamTypes.h>

#include <media/CodecServiceRegistrant.h>
#include <codecserviceregistrant/CodecServiceRegistrant.h>

namespace /* unnamed */ {

@@ -775,13 +775,12 @@ static android::sp<c2_hidl_V1_0::IComponentStore> getDeclaredHidlSwcodec(
    return nullptr;
}

extern "C" void RegisterCodecServices() {
/**
 * This function encapsulates the core logic required to register codec services,
 * separated from threadpool management to avoid timeouts when called by the fuzzer.
 */
static void RegisterCodecServicesWithExistingThreadpool() {
    const bool aidlSelected = c2_aidl::utils::IsSelected();
    constexpr int kThreadCount = 64;
    ABinderProcess_setThreadPoolMaxThreadCount(kThreadCount);
    ABinderProcess_startThreadPool();
    ::android::hardware::configureRpcThreadpool(kThreadCount, false);

    LOG(INFO) << "Creating software Codec2 service...";
    std::shared_ptr<C2ComponentStore> store =
        android::GetCodec2PlatformComponentStore();
@@ -880,8 +879,16 @@ extern "C" void RegisterCodecServices() {
    if (registered) {
        LOG(INFO) << "Software Codec2 service created and registered.";
    }
}

extern "C" void RegisterCodecServices() {
    constexpr int kThreadCount = 64;
    ABinderProcess_setThreadPoolMaxThreadCount(kThreadCount);
    ABinderProcess_startThreadPool();
    ::android::hardware::configureRpcThreadpool(kThreadCount, false);

    RegisterCodecServicesWithExistingThreadpool();

    ABinderProcess_joinThreadPool();
    ::android::hardware::joinRpcThreadpool();
}
+6 −3
Original line number Diff line number Diff line
@@ -13,6 +13,9 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <codecserviceregistrant/CodecServiceRegistrant.h>

#include "../CodecServiceRegistrant.cpp"
#include "fuzzer/FuzzedDataProvider.h"
#include <C2Config.h>
@@ -166,9 +169,9 @@ void CodecServiceRegistrantFuzzer::invokeH2C2ComponentStore() {
void CodecServiceRegistrantFuzzer::process(const uint8_t *data, size_t size) {
  mFDP = new FuzzedDataProvider(data, size);
  invokeH2C2ComponentStore();
  /** RegisterCodecServices is called here to improve code coverage */
  /** as currently it is not called by codecServiceRegistrant       */
  RegisterCodecServices();
  /** RegisterCodecServicesWithExistingThreadpool() is called here to improve
   * code coverage as currently it is not called in codecServiceRegistrant.cpp */
  RegisterCodecServicesWithExistingThreadpool();
  delete mFDP;
}

+7 −0
Original line number Diff line number Diff line
@@ -18,6 +18,13 @@

#define CODEC_SERVICE_REGISTRANT_H_

/**
 * This function starts the threadpool, calls the registration logic
 * encapsulated in RegisterCodecServicesWithExistingThreadpool(), and
 * then stops the threadpool.
 */
extern "C" void RegisterCodecServices();

typedef void (*RegisterCodecServicesFunc)();

#endif  // CODEC_SERVICE_REGISTRANT_H_