Merge "Only use libbinder_ndk for aidl service." into tm-dev

This commit is contained in:
Edwin Wong
2022-05-05 17:53:05 +00:00
committed by Android (Google) Code Review
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.2",
"android.hardware.drm@1.3", "android.hardware.drm@1.3",
"libbase", "libbase",
"libbinder",
"libhidlbase", "libhidlbase",
"liblog", "liblog",
"libutils", "libutils",
"libbinder",
], ],
} }
@@ -131,7 +131,6 @@ cc_defaults {
"libbase", "libbase",
"libbinder_ndk", "libbinder_ndk",
"liblog", "liblog",
"libhwbinder",
"libutils", "libutils",
"libwvaidl", "libwvaidl",
], ],
@@ -261,7 +260,11 @@ cc_binary {
srcs: ["aidl_src/service.cpp"], 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"], init_rc: ["aidl_src/android.hardware.drm-service.widevine.rc"],
vintf_fragments: ["manifest_android.hardware.drm-service.widevine.xml"], vintf_fragments: ["manifest_android.hardware.drm-service.widevine.xml"],
@@ -280,7 +283,11 @@ cc_binary {
srcs: ["aidl_src/serviceLazy.cpp"], 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"], init_rc: ["aidl_src/android.hardware.drm-service-lazy.widevine.rc"],
vintf_fragments: ["manifest_android.hardware.drm-service.widevine.xml"], vintf_fragments: ["manifest_android.hardware.drm-service.widevine.xml"],
@@ -324,7 +331,7 @@ cc_library_static {
], ],
shared_libs: [ shared_libs: [
"libbinder", "libbinder_ndk",
"libcrypto", "libcrypto",
"libhidlbase", "libhidlbase",
"liblog", "liblog",
@@ -358,7 +365,7 @@ cc_library_static {
], ],
shared_libs: [ shared_libs: [
"libbinder", "libbinder_ndk",
"libcrypto", "libcrypto",
"libhidlbase", "libhidlbase",
"liblog", "liblog",
@@ -520,7 +527,6 @@ cc_library_shared {
shared_libs: [ shared_libs: [
"android.hardware.drm-V1-ndk", "android.hardware.drm-V1-ndk",
"libbase", "libbase",
"libbinder",
"libbinder_ndk", "libbinder_ndk",
"libcrypto", "libcrypto",
"libcutils", "libcutils",

View File

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

View File

@@ -19,7 +19,6 @@
#include <android/binder_ibinder_platform.h> #include <android/binder_ibinder_platform.h>
#include <android/binder_manager.h> #include <android/binder_manager.h>
#include <android/binder_process.h> #include <android/binder_process.h>
#include <binder/ProcessState.h>
#include "WVCreatePluginFactories.h" #include "WVCreatePluginFactories.h"
#include "WVDrmFactory.h" #include "WVDrmFactory.h"
@@ -31,6 +30,8 @@ int main(int /* argc */, char** /* argv */) {
ABinderProcess_setThreadPoolMaxThreadCount(8); ABinderProcess_setThreadPoolMaxThreadCount(8);
std::shared_ptr<WVDrmFactory> drmFactory = createDrmFactory(); std::shared_ptr<WVDrmFactory> drmFactory = createDrmFactory();
AIBinder_setRequestingSid(drmFactory->asBinder().get(), true);
const std::string drmInstance = const std::string drmInstance =
std::string(WVDrmFactory::descriptor) + "/widevine"; std::string(WVDrmFactory::descriptor) + "/widevine";
binder_status_t status = AServiceManager_addService( binder_status_t status = AServiceManager_addService(

View File

@@ -19,7 +19,6 @@
#include <android/binder_ibinder_platform.h> #include <android/binder_ibinder_platform.h>
#include <android/binder_manager.h> #include <android/binder_manager.h>
#include <android/binder_process.h> #include <android/binder_process.h>
#include <binder/ProcessState.h>
#include "WVCreatePluginFactories.h" #include "WVCreatePluginFactories.h"
#include "WVDrmFactory.h" #include "WVDrmFactory.h"
@@ -31,6 +30,8 @@ int main(int /* argc */, char** /* argv */) {
ABinderProcess_setThreadPoolMaxThreadCount(8); ABinderProcess_setThreadPoolMaxThreadCount(8);
std::shared_ptr<WVDrmFactory> drmFactory = createDrmFactory(); std::shared_ptr<WVDrmFactory> drmFactory = createDrmFactory();
AIBinder_setRequestingSid(drmFactory->asBinder().get(), true);
const std::string drmInstance = const std::string drmInstance =
std::string(WVDrmFactory::descriptor) + "/widevine"; std::string(WVDrmFactory::descriptor) + "/widevine";
binder_status_t status = AServiceManager_registerLazyService( binder_status_t status = AServiceManager_registerLazyService(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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