Call AIBinder_setRequestingSid from createBinder override function

AIBinder_setRequestingSid must be called first upon creation of a
binder object before AIBinder_getCallingSid is called. Call
AIBinder_setRequestingSid in the createBinder override function
for WVDrmFactory, WVDrmPlugin and WVCryptoPlugin classes.

Test: Play TV streaming
Test: adb shell dumpsys android.hardware.drm.IDrmFactory/widevine -a

Bug: 237613676
Change-Id: I9dde4715ba2003deb463bd75b23e1ebc2f22a764
This commit is contained in:
Edwin Wong
2022-07-30 01:50:48 +00:00
parent 6a0d1ce668
commit 6797b8eb8a
8 changed files with 26 additions and 4 deletions

View File

@@ -49,6 +49,8 @@ class WVDrmFactory : public ::aidl::android::hardware::drm::BnDrmFactory {
private:
WVDRM_DISALLOW_COPY_AND_ASSIGN(WVDrmFactory);
::ndk::SpAIBinder createBinder() override;
static WVGenericCryptoInterface sOemCryptoInterface;
static bool areSpoidsEnabled();

View File

@@ -46,6 +46,13 @@ bool WVDrmFactory::isCryptoSchemeSupported(const Uuid& in_uuid) {
return isWidevineUUID(in_uuid.uuid.data());
}
::ndk::SpAIBinder WVDrmFactory::createBinder() {
auto binder = BnDrmFactory::createBinder();
AIBinder_setRequestingSid(binder.get(), true);
return binder;
}
::ndk::ScopedAStatus WVDrmFactory::createCryptoPlugin(
const ::aidl::android::hardware::drm::Uuid& in_uuid,
const std::vector<uint8_t>& in_initData,
@@ -66,7 +73,6 @@ bool WVDrmFactory::isCryptoSchemeSupported(const Uuid& in_uuid) {
std::shared_ptr<WVCryptoPlugin> plugin =
::ndk::SharedRefBase::make<WVCryptoPlugin>(in_initData.data(),
in_initData.size(), getCDM());
AIBinder_setRequestingSid(plugin->asBinder().get(), true);
*_aidl_return = std::move(plugin);
return toNdkScopedAStatus(Status::OK);
}
@@ -99,7 +105,6 @@ bool WVDrmFactory::isCryptoSchemeSupported(const Uuid& in_uuid) {
getCDM(), in_appPackageName.c_str(), &sOemCryptoInterface,
areSpoidsEnabled());
AIBinder_setRequestingSid(plugin->asBinder().get(), true);
*_aidl_return = plugin;
return toNdkScopedAStatus(Status::OK);
}

View File

@@ -30,7 +30,6 @@ int main(int /* argc */, char** /* argv */) {
ABinderProcess_setThreadPoolMaxThreadCount(8);
std::shared_ptr<WVDrmFactory> drmFactory = createDrmFactory();
AIBinder_setRequestingSid(drmFactory->asBinder().get(), true);
const std::string drmInstance =
std::string(WVDrmFactory::descriptor) + "/widevine";

View File

@@ -30,7 +30,6 @@ int main(int /* argc */, char** /* argv */) {
ABinderProcess_setThreadPoolMaxThreadCount(8);
std::shared_ptr<WVDrmFactory> drmFactory = createDrmFactory();
AIBinder_setRequestingSid(drmFactory->asBinder().get(), true);
const std::string drmInstance =
std::string(WVDrmFactory::descriptor) + "/widevine";

View File

@@ -76,6 +76,8 @@ class WVCryptoPlugin : public ::aidl::android::hardware::drm::BnCryptoPlugin {
::android::sp<wvcdm::WvContentDecryptionModule> const mCDM;
uint32_t mUserId;
::ndk::SpAIBinder createBinder() override;
::aidl::android::hardware::drm::Status attemptDecrypt(
const wvcdm::CdmDecryptionParametersV16& params,
bool haveEncryptedSubsamples, std::string* errorDetailMsg);

View File

@@ -9,6 +9,7 @@
#include "WVCryptoPlugin.h"
#include <aidlcommonsupport/NativeHandle.h>
#include <android/binder_ibinder_platform.h>
#include <sys/mman.h>
#include <utils/Log.h>
@@ -289,6 +290,12 @@ SharedBufferBase::~SharedBufferBase() {
return toNdkScopedAStatus(Status::OK, detailedError);
}
::ndk::SpAIBinder WVCryptoPlugin::createBinder() {
auto binder = BnCryptoPlugin::createBinder();
AIBinder_setRequestingSid(binder.get(), true);
return binder;
}
Status WVCryptoPlugin::attemptDecrypt(const CdmDecryptionParametersV16& params,
bool hasProtectedData,
std::string* errorDetailMsg) {

View File

@@ -407,6 +407,8 @@ class WVDrmPlugin : public ::aidl::android::hardware::drm::BnDrmPlugin,
std::string mAppPackageName;
::ndk::SpAIBinder createBinder() override;
Status queryProperty(const std::string& property,
std::string& stringValue) const;

View File

@@ -1851,6 +1851,12 @@ Status WVDrmPlugin::queryProperty(RequestedSecurityLevel securityLevel,
return mapCdmResponseType(res);
}
::ndk::SpAIBinder WVDrmPlugin::createBinder() {
auto binder = BnDrmPlugin::createBinder();
AIBinder_setRequestingSid(binder.get(), true);
return binder;
}
Status WVDrmPlugin::queryProperty(const std::string& property,
vector<uint8_t>& vector_value) const {
std::string string_value;