From 573fa0b628f3d9529cedadf0c7e531ef6a2e5f97 Mon Sep 17 00:00:00 2001 From: Kyle Zhang Date: Thu, 26 Jun 2025 22:52:39 -0700 Subject: [PATCH] Check if service is ready before query status Bug: 425974655 Change-Id: I8707b844d65865d409780e1861385d840525390b --- libwvdrmengine/src/Utils.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libwvdrmengine/src/Utils.cpp b/libwvdrmengine/src/Utils.cpp index f517518e..0fb06a8a 100644 --- a/libwvdrmengine/src/Utils.cpp +++ b/libwvdrmengine/src/Utils.cpp @@ -11,6 +11,7 @@ #include "log.h" #include +#include namespace { // Please keep the order stable. @@ -200,6 +201,20 @@ bool matchesSocModelPattern(const std::string& socModel) { } bool checkIfEnableMultiThreadBinder() { + // On first boot, the /data/vendor/mediadrm path may not have been created + // by init yet. Calling QueryStatus at this stage would fail because the L3 + // service cannot initialize its filesystem, leading to a persistent error + // state. This check defers enabling multi-threading until the basic DRM + // filesystem is ready. b/425974655. + const char* kMediaDrmPath = "/data/vendor/mediadrm"; + struct stat sb; + + // check if the MediaDRM path exists and is a directory + if (stat(kMediaDrmPath, &sb) != 0 || !S_ISDIR(sb.st_mode)) { + LOGW("MediaDRM path does not exist, deferring multi-thread binder check."); + return false; + } + android::sp cdm = wvdrm::getCDM(); if (cdm == nullptr) { LOGW("Failed to get CDM when checking if multi-thread binder is enabled.");