Only use libbinder_ndk for aidl service.

[ Merged from http://go/wvgerrit/151169 ]

Test: Netflix and Google TV streaming and downloaded playback
Test: unit tests
Test: atest VtsAidlHalDrmTargetTest
Test: adb shell readelf -d /vendor/bin/hw/android.hardware.drm-service.widevine
Test: adb shell readelf -d /vendor/lib64/libwvaidl.so

Bug: 230791937
Change-Id: Ia60d9fc838bf228b40d99b076a837ae789fa2d03
This commit is contained in:
Edwin Wong
2022-04-29 20:31:18 +00:00
parent da1e3c5de2
commit af5f57a46c
13 changed files with 31 additions and 26 deletions

View File

@@ -107,10 +107,10 @@ cc_defaults {
"android.hardware.drm@1.2",
"android.hardware.drm@1.3",
"libbase",
"libbinder",
"libhidlbase",
"liblog",
"libutils",
"libbinder",
],
}
@@ -131,7 +131,6 @@ cc_defaults {
"libbase",
"libbinder_ndk",
"liblog",
"libhwbinder",
"libutils",
"libwvaidl",
],
@@ -261,7 +260,11 @@ cc_binary {
srcs: ["aidl_src/service.cpp"],
shared_libs: ["libbinder"],
include_dirs: [
"frameworks/native/libs/binder/include",
],
shared_libs: ["libbinder_ndk"],
init_rc: ["aidl_src/android.hardware.drm-service.widevine.rc"],
vintf_fragments: ["manifest_android.hardware.drm-service.widevine.xml"],
@@ -280,7 +283,11 @@ cc_binary {
srcs: ["aidl_src/serviceLazy.cpp"],
shared_libs: ["libbinder"],
include_dirs: [
"frameworks/native/libs/binder/include",
],
shared_libs: ["libbinder_ndk"],
init_rc: ["aidl_src/android.hardware.drm-service-lazy.widevine.rc"],
vintf_fragments: ["manifest_android.hardware.drm-service.widevine.xml"],
@@ -324,7 +331,7 @@ cc_library_static {
],
shared_libs: [
"libbinder",
"libbinder_ndk",
"libcrypto",
"libhidlbase",
"liblog",
@@ -358,7 +365,7 @@ cc_library_static {
],
shared_libs: [
"libbinder",
"libbinder_ndk",
"libcrypto",
"libhidlbase",
"liblog",
@@ -520,7 +527,6 @@ cc_library_shared {
shared_libs: [
"android.hardware.drm-V1-ndk",
"libbase",
"libbinder",
"libbinder_ndk",
"libcrypto",
"libcutils",

View File

@@ -49,8 +49,7 @@ bool WVDrmFactory::isCryptoSchemeSupported(const Uuid& in_uuid) {
const std::vector<uint8_t>& in_initData,
std::shared_ptr<::aidl::android::hardware::drm::ICryptoPlugin>*
_aidl_return) {
const auto& self = android::IPCThreadState::self();
const char* sid = self->getCallingSid();
const char* sid = AIBinder_getCallingSid();
sid = sid ? (std::strstr(sid, "mediadrmserver") ? sid : "app") : "nullptr";
ALOGI("[%s] calling %s", sid, __PRETTY_FUNCTION__);
@@ -73,8 +72,7 @@ bool WVDrmFactory::isCryptoSchemeSupported(const Uuid& in_uuid) {
::ndk::ScopedAStatus WVDrmFactory::createDrmPlugin(
const Uuid& in_uuid, const string& in_appPackageName,
std::shared_ptr<::aidl::android::hardware::drm::IDrmPlugin>* _aidl_return) {
const auto& self = ::android::IPCThreadState::self();
const char* sid = self->getCallingSid();
const char* sid = AIBinder_getCallingSid();
sid = sid ? (std::strstr(sid, "mediadrmserver") ? sid : "app") : "nullptr";
ALOGI("[%s][%s] calling %s", sid, in_appPackageName.c_str(),
__PRETTY_FUNCTION__);

View File

@@ -19,7 +19,6 @@
#include <android/binder_ibinder_platform.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <binder/ProcessState.h>
#include "WVCreatePluginFactories.h"
#include "WVDrmFactory.h"
@@ -31,6 +30,8 @@ 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";
binder_status_t status = AServiceManager_addService(

View File

@@ -19,7 +19,6 @@
#include <android/binder_ibinder_platform.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <binder/ProcessState.h>
#include "WVCreatePluginFactories.h"
#include "WVDrmFactory.h"
@@ -31,6 +30,8 @@ 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";
binder_status_t status = AServiceManager_registerLazyService(

View File

@@ -9,7 +9,7 @@ HIDL_EXTENSION := _hidl
LIB_BINDER := libhidlbase
else
HIDL_EXTENSION :=
LIB_BINDER := libbinder
LIB_BINDER := libbinder_ndk
endif
LOCAL_LICENSE_CONDITIONS := by_exception_only

View File

@@ -12,7 +12,7 @@ HIDL_EXTENSION := _hidl
LIB_BINDER := libhidlbase
else
HIDL_EXTENSION :=
LIB_BINDER := libbinder
LIB_BINDER := libbinder_ndk
endif
LOCAL_MODULE := $(test_name)

View File

@@ -12,7 +12,7 @@ HIDL_EXTENSION := _hidl
LIB_BINDER := libhidlbase
else
HIDL_EXTENSION :=
LIB_BINDER := libbinder
LIB_BINDER := libbinder_ndk
endif
LOCAL_MODULE := $(test_name)

View File

@@ -26,7 +26,7 @@
#ifdef IS_HIDL
# include <hwbinder/IPCThreadState.h>
#else // AIDL is the default
# include <binder/IPCThreadState.h>
# include <android/binder_ibinder.h>
#endif
#include <stdarg.h>
#include <stdio.h>
@@ -82,10 +82,10 @@ uint32_t GetLoggingUid() { return tl_logging_uid_; }
uint32_t GetIpcCallingUid() {
#ifdef IS_HIDL
const auto self = android::hardware::IPCThreadState::selfOrNull();
#else // AIDL is the default
const auto self = android::IPCThreadState::selfOrNull();
#endif
return self ? self->getCallingUid() : UNKNOWN_UID;
#else // AIDL is the default
return AIBinder_getCallingUid();
#endif
}
void InitLogging() {}

View File

@@ -102,7 +102,6 @@ cc_library_static {
shared_libs: [
"libbase",
"libbinder",
"libbinder_ndk",
"libcrypto",
"liblog",

View File

@@ -10,6 +10,7 @@
#include "WVDrmPlugin.h"
#include <aidl/android/hardware/drm/DrmMetric.h>
#include <android/binder_ibinder_platform.h>
#include <binder/IPCThreadState.h>
#include <stdlib.h>
#include <utils/Log.h>
@@ -1634,8 +1635,7 @@ Status WVDrmPlugin::unprovisionDevice() {
return toNdkScopedAStatus(Status::BAD_VALUE);
}
const auto& self = android::IPCThreadState::self();
const char* sid = self->getCallingSid();
const char* sid = AIBinder_getCallingSid();
if (!sid ||
(!strstr(sid, ":mediashell_app:") && !strstr(sid, ":mediadrmserver:") &&
!strstr(sid, ":setupwraith_app:"))) {

View File

@@ -39,7 +39,7 @@ LOCAL_SHARED_LIBRARIES := \
android.hardware.drm@1.3 \
android.hardware.drm@1.4 \
android.hidl.memory@1.0 \
libbinder \
libbinder_ndk \
libbase \
libcrypto \
libdl \

View File

@@ -6,7 +6,7 @@ HIDL_EXTENSION := _hidl
LIB_BINDER := libhidlbase
else
HIDL_EXTENSION :=
LIB_BINDER := libbinder
LIB_BINDER := libbinder_ndk
endif
ifeq ($(filter mips mips64, $(TARGET_ARCH)),)

View File

@@ -57,7 +57,7 @@ cc_library_shared {
shared_libs: [
"libbase",
"libbinder",
"libbinder_ndk",
"libcrypto",
"liblog",
"libssl",