aidl plugin: add error details to return status
Merged from http://go/wvgerrit/163639 Bug: 253271674 Test: Google TV Test: atest MediaDrmParameterizedTests Test: atest DrmSessionManagerTest Change-Id: I9f0e83774d405466a389d2fd90d693830682dde4
This commit is contained in:
@@ -95,6 +95,7 @@ cc_defaults {
|
||||
proprietary: true,
|
||||
relative_install_path: "hw",
|
||||
include_dirs: [
|
||||
"vendor/widevine/libwvdrmengine/cdm/core/include/",
|
||||
"vendor/widevine/libwvdrmengine/include",
|
||||
"vendor/widevine/libwvdrmengine/mediadrm/include",
|
||||
"vendor/widevine/libwvdrmengine/oemcrypto/include",
|
||||
@@ -209,6 +210,7 @@ cc_library_shared {
|
||||
"src/WVCDMSingleton.cpp",
|
||||
"src/WVUUID.cpp",
|
||||
"src/wv_metrics.cpp",
|
||||
"src/Utils.cpp",
|
||||
"src/WVCreatePluginFactories.cpp",
|
||||
"src/WVDrmFactory.cpp",
|
||||
],
|
||||
@@ -233,6 +235,7 @@ cc_library_shared {
|
||||
"libcdm_protos",
|
||||
"libcdm_utils",
|
||||
"libjsmn",
|
||||
"libjsoncpp",
|
||||
"libwvdrmcryptoplugin_aidl",
|
||||
"libwvdrmdrmplugin_aidl",
|
||||
"libwvlevel3",
|
||||
@@ -272,89 +275,11 @@ phony {
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
name: "libwvaidl_fuzz",
|
||||
|
||||
srcs: [
|
||||
"src/WVCDMSingleton.cpp",
|
||||
"src/WVUUID.cpp",
|
||||
"src/wv_metrics.cpp",
|
||||
"src/WVCreatePluginFactories.cpp",
|
||||
"src/WVDrmFactory.cpp",
|
||||
],
|
||||
|
||||
include_dirs: [
|
||||
"frameworks/av/include",
|
||||
"frameworks/native/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/core/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/metrics/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/util/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/include",
|
||||
"vendor/widevine/libwvdrmengine/include",
|
||||
"vendor/widevine/libwvdrmengine/mediacrypto/include",
|
||||
"vendor/widevine/libwvdrmengine/mediadrm/include",
|
||||
"vendor/widevine/libwvdrmengine/oemcrypto/include",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"android.hardware.common-V2-ndk",
|
||||
"libaidlcommonsupport",
|
||||
"libcdm",
|
||||
"libcdm_protos",
|
||||
"libcdm_utils",
|
||||
"libjsmn",
|
||||
"libwvdrmcryptoplugin_aidl_fuzz",
|
||||
"libwvdrmdrmplugin_aidl_fuzz",
|
||||
"libwvlevel3",
|
||||
"libwv_odk",
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"android.hardware.drm-V1-ndk",
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"libcrypto",
|
||||
"libcutils",
|
||||
"libdl",
|
||||
"liblog",
|
||||
"libprotobuf-cpp-lite",
|
||||
"libutils",
|
||||
],
|
||||
|
||||
header_libs: ["libstagefright_foundation_headers"],
|
||||
|
||||
owner: "widevine",
|
||||
|
||||
proprietary: true,
|
||||
}
|
||||
|
||||
cc_defaults {
|
||||
name: "common_widevine_service-multilib-defaults-aidl_fuzz",
|
||||
owner: "widevine",
|
||||
proprietary: true,
|
||||
relative_install_path: "hw",
|
||||
include_dirs: [
|
||||
"vendor/widevine/libwvdrmengine/include",
|
||||
"vendor/widevine/libwvdrmengine/mediadrm/include",
|
||||
"vendor/widevine/libwvdrmengine/oemcrypto/include",
|
||||
],
|
||||
header_libs: ["libstagefright_foundation_headers"],
|
||||
|
||||
shared_libs: [
|
||||
"android.hardware.drm-V1-ndk",
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libwvaidl_fuzz",
|
||||
],
|
||||
}
|
||||
|
||||
cc_fuzz {
|
||||
name: "android.hardware.drm-service.widevine.aidl_fuzzer",
|
||||
defaults: [
|
||||
"common_widevine_service-multilib-first",
|
||||
"common_widevine_service-multilib-defaults-aidl_fuzz",
|
||||
"common_widevine_service-multilib-defaults-aidl",
|
||||
"service_fuzzer_defaults",
|
||||
],
|
||||
static_libs: [
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
#ifndef WV_UTILS_H_
|
||||
#define WV_UTILS_H_
|
||||
|
||||
#include <aidl/android/hardware/drm/LogPriority.h>
|
||||
#include <aidl/android/hardware/drm/Status.h>
|
||||
#include <android/binder_auto_utils.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "WVTypes.h"
|
||||
#include "log.h"
|
||||
|
||||
namespace wvdrm {
|
||||
@@ -35,19 +34,12 @@ inline ::aidl::android::hardware::drm::LogPriority toAidlLogPriority(
|
||||
}
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus toNdkScopedAStatus(::wvdrm::WvStatus status,
|
||||
const char* msg = nullptr);
|
||||
|
||||
inline ::ndk::ScopedAStatus toNdkScopedAStatus(
|
||||
::aidl::android::hardware::drm::Status status, const char* msg = nullptr) {
|
||||
if (::aidl::android::hardware::drm::Status::OK == status)
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
else {
|
||||
auto err = static_cast<int32_t>(status);
|
||||
if (msg) {
|
||||
return ::ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(err,
|
||||
msg);
|
||||
} else {
|
||||
return ::ndk::ScopedAStatus::fromServiceSpecificError(err);
|
||||
}
|
||||
}
|
||||
return toNdkScopedAStatus(::wvdrm::WvStatus(status), msg);
|
||||
}
|
||||
|
||||
} // namespace wvdrm
|
||||
|
||||
@@ -7,8 +7,14 @@
|
||||
#ifndef WV_TYPES_H_
|
||||
#define WV_TYPES_H_
|
||||
|
||||
#include <aidl/android/hardware/drm/Status.h>
|
||||
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvdrm {
|
||||
|
||||
using AidlDrmStatus = ::aidl::android::hardware::drm::Status;
|
||||
|
||||
#define WVDRM_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&) = delete; \
|
||||
void operator=(const TypeName&) = delete;
|
||||
@@ -18,6 +24,33 @@ namespace wvdrm {
|
||||
TypeName(const TypeName&) = delete; \
|
||||
void operator=(const TypeName&) = delete;
|
||||
|
||||
struct WvStatus {
|
||||
public:
|
||||
explicit WvStatus(AidlDrmStatus status) : mStatus(status) {}
|
||||
WvStatus() : mStatus(AidlDrmStatus::OK) {}
|
||||
WvStatus(AidlDrmStatus status, wvcdm::CdmResponseType cdmErr)
|
||||
: mStatus(status), mCdmErr(cdmErr) {}
|
||||
|
||||
explicit operator AidlDrmStatus() const { return mStatus; }
|
||||
explicit operator int32_t() const { return static_cast<int32_t>(mStatus); }
|
||||
|
||||
AidlDrmStatus get() const { return mStatus; }
|
||||
|
||||
bool operator==(const AidlDrmStatus other) const { return mStatus == other; }
|
||||
bool operator!=(const AidlDrmStatus other) const { return mStatus != other; }
|
||||
|
||||
WvStatus &setCdmErr(wvcdm::CdmResponseType cdmErr) {
|
||||
mCdmErr = cdmErr;
|
||||
return *this;
|
||||
}
|
||||
wvcdm::CdmResponseType getCdmErr() const { return mCdmErr; }
|
||||
|
||||
private:
|
||||
AidlDrmStatus mStatus{};
|
||||
wvcdm::CdmResponseType mCdmErr{};
|
||||
// WVDRM_DISALLOW_COPY_AND_ASSIGN_AND_NEW(WvStatus);
|
||||
};
|
||||
|
||||
} // namespace wvdrm
|
||||
|
||||
#endif // WV_TYPES_H_
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define WV_MAP_ERRORS_INL_H_
|
||||
|
||||
#include "WVErrors.h"
|
||||
#include "WVTypes.h"
|
||||
#include "media/stagefright/MediaErrors.h"
|
||||
#include "utils/Errors.h"
|
||||
#include "wv_cdm_types.h"
|
||||
@@ -16,10 +17,9 @@ namespace wvdrm {
|
||||
|
||||
using ::aidl::android::hardware::drm::Status;
|
||||
|
||||
template <typename S = Status>
|
||||
static S mapCdmResponseType(wvcdm::CdmResponseEnum res) {
|
||||
static inline WvStatus mapCdmResponseType(wvcdm::CdmResponseType res) {
|
||||
Status err = Status::ERROR_DRM_UNKNOWN;
|
||||
switch (res) {
|
||||
switch (res.Enum()) {
|
||||
case wvcdm::KEY_ADDED:
|
||||
case wvcdm::KEY_MESSAGE:
|
||||
case wvcdm::KEY_CANCELED:
|
||||
@@ -37,21 +37,26 @@ static S mapCdmResponseType(wvcdm::CdmResponseEnum res) {
|
||||
// that should probably all turn into NO_LICENSE. Here, and below, and
|
||||
// everywhere.
|
||||
case wvcdm::NO_CONTENT_KEY_3:
|
||||
return Status::ERROR_DRM_NO_LICENSE;
|
||||
err = Status::ERROR_DRM_NO_LICENSE;
|
||||
break;
|
||||
|
||||
case wvcdm::NEED_PROVISIONING:
|
||||
return Status::ERROR_DRM_NOT_PROVISIONED;
|
||||
err = Status::ERROR_DRM_NOT_PROVISIONED;
|
||||
break;
|
||||
|
||||
case wvcdm::DEVICE_REVOKED:
|
||||
return Status::ERROR_DRM_DEVICE_REVOKED;
|
||||
err = Status::ERROR_DRM_DEVICE_REVOKED;
|
||||
break;
|
||||
|
||||
case wvcdm::INSUFFICIENT_CRYPTO_RESOURCES:
|
||||
return Status::ERROR_DRM_RESOURCE_BUSY;
|
||||
err = Status::ERROR_DRM_RESOURCE_BUSY;
|
||||
break;
|
||||
|
||||
case wvcdm::RELEASE_USAGE_INFO_ERROR:
|
||||
case wvcdm::RELEASE_USAGE_INFO_FAILED:
|
||||
case wvcdm::SYSTEM_INVALIDATED_ERROR:
|
||||
return Status::ERROR_DRM_INVALID_STATE;
|
||||
err = Status::ERROR_DRM_INVALID_STATE;
|
||||
break;
|
||||
|
||||
case wvcdm::SESSION_NOT_FOUND_FOR_DECRYPT:
|
||||
case wvcdm::SESSION_NOT_FOUND_1:
|
||||
@@ -70,18 +75,22 @@ static S mapCdmResponseType(wvcdm::CdmResponseEnum res) {
|
||||
case wvcdm::SESSION_NOT_FOUND_21:
|
||||
case wvcdm::SESSION_NOT_FOUND_22:
|
||||
case wvcdm::SESSION_NOT_FOUND_23:
|
||||
return Status::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
err = Status::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
break;
|
||||
|
||||
case wvcdm::DECRYPT_ERROR:
|
||||
case wvcdm::SECURE_BUFFER_REQUIRED:
|
||||
return Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
err = Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
break;
|
||||
|
||||
case wvcdm::ANALOG_OUTPUT_ERROR:
|
||||
case wvcdm::INSUFFICIENT_OUTPUT_PROTECTION:
|
||||
return Status::ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION;
|
||||
err = Status::ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION;
|
||||
break;
|
||||
|
||||
case wvcdm::KEYSET_ID_NOT_FOUND_4:
|
||||
return Status::BAD_VALUE;
|
||||
err = Status::BAD_VALUE;
|
||||
break;
|
||||
|
||||
// The following cases follow the order in wv_cdm_types.h
|
||||
// to make it easier to keep track of newly defined errors.
|
||||
@@ -108,20 +117,25 @@ static S mapCdmResponseType(wvcdm::CdmResponseEnum res) {
|
||||
case wvcdm::PARSE_OKP_RESPONSE_ERROR:
|
||||
case wvcdm::OKP_ALREADY_PROVISIONED:
|
||||
ALOGW("Returns UNKNOWN error for legacy status: %d", res);
|
||||
return Status::ERROR_DRM_UNKNOWN;
|
||||
err = Status::ERROR_DRM_UNKNOWN;
|
||||
break;
|
||||
|
||||
case wvcdm::KEY_PROHIBITED_FOR_SECURITY_LEVEL:
|
||||
return Status::ERROR_DRM_INSUFFICIENT_SECURITY;
|
||||
err = Status::ERROR_DRM_INSUFFICIENT_SECURITY;
|
||||
break;
|
||||
case wvcdm::OUTPUT_TOO_LARGE_ERROR:
|
||||
return Status::ERROR_DRM_FRAME_TOO_LARGE;
|
||||
err = Status::ERROR_DRM_FRAME_TOO_LARGE;
|
||||
break;
|
||||
case wvcdm::SESSION_LOST_STATE_ERROR:
|
||||
return Status::ERROR_DRM_SESSION_LOST_STATE;
|
||||
err = Status::ERROR_DRM_SESSION_LOST_STATE;
|
||||
break;
|
||||
case wvcdm::LICENSE_REQUEST_NONCE_GENERATION_ERROR:
|
||||
case wvcdm::LICENSE_RENEWAL_NONCE_GENERATION_ERROR:
|
||||
case wvcdm::CERT_PROVISIONING_NONCE_GENERATION_ERROR:
|
||||
case wvcdm::NONCE_GENERATION_ERROR:
|
||||
// These are likely nonce flood errors
|
||||
return Status::ERROR_DRM_RESOURCE_CONTENTION;
|
||||
err = Status::ERROR_DRM_RESOURCE_CONTENTION;
|
||||
break;
|
||||
|
||||
case wvcdm::CANNOT_DECRYPT_ZERO_SUBSAMPLES:
|
||||
err = Status::CANNOT_DECRYPT_ZERO_SUBSAMPLES;
|
||||
@@ -429,14 +443,13 @@ static S mapCdmResponseType(wvcdm::CdmResponseEnum res) {
|
||||
err = Status::STORAGE_WRITE_FAILURE;
|
||||
break;
|
||||
default:
|
||||
return Status::ERROR_DRM_UNKNOWN;
|
||||
err = Status::ERROR_DRM_UNKNOWN;
|
||||
}
|
||||
return static_cast<S>(err);
|
||||
return WvStatus(err, res);
|
||||
}
|
||||
|
||||
template <typename S = Status>
|
||||
static S mapCdmResponseType(wvcdm::CdmResponseType res) {
|
||||
return mapCdmResponseType(static_cast<wvcdm::CdmResponseEnum>(res));
|
||||
static inline WvStatus mapCdmResponseType(wvcdm::CdmResponseEnum res) {
|
||||
return mapCdmResponseType(wvcdm::CdmResponseType(res));
|
||||
}
|
||||
|
||||
static inline bool isCdmResponseTypeSuccess(wvcdm::CdmResponseType res) {
|
||||
|
||||
@@ -64,46 +64,3 @@ cc_library_static {
|
||||
|
||||
proprietary: true,
|
||||
}
|
||||
|
||||
// Builds libwvdrmcryptoplugin_aidl_fuzz
|
||||
//
|
||||
cc_library_static {
|
||||
name: "libwvdrmcryptoplugin_aidl_fuzz",
|
||||
|
||||
srcs: ["src/WVCryptoPlugin.cpp"],
|
||||
|
||||
include_dirs: [
|
||||
"frameworks/av/include",
|
||||
"frameworks/native/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/core/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/metrics/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/util/include",
|
||||
"vendor/widevine/libwvdrmengine/include",
|
||||
"vendor/widevine/libwvdrmengine/mediacrypto/include",
|
||||
"vendor/widevine/libwvdrmengine/oemcrypto/include",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"libstagefright_headers",
|
||||
"libutils_headers",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"android.hardware.common-V2-ndk",
|
||||
"libaidlcommonsupport",
|
||||
"libcdm_protos",
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"android.hardware.drm-V1-ndk",
|
||||
"libbase",
|
||||
"libcrypto",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
],
|
||||
|
||||
cflags: ["-Wthread-safety"],
|
||||
|
||||
proprietary: true,
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class WVCryptoPlugin : public ::aidl::android::hardware::drm::BnCryptoPlugin {
|
||||
|
||||
::ndk::SpAIBinder createBinder() override;
|
||||
|
||||
::aidl::android::hardware::drm::Status attemptDecrypt(
|
||||
::wvdrm::WvStatus attemptDecrypt(
|
||||
const wvcdm::CdmDecryptionParametersV16& params,
|
||||
bool haveEncryptedSubsamples, std::string* errorDetailMsg);
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ SharedBufferBase::~SharedBufferBase() {
|
||||
|
||||
// Decrypt
|
||||
std::string errorDetailMsg;
|
||||
Status res = attemptDecrypt(params, hasProtectedData, &errorDetailMsg);
|
||||
auto res = attemptDecrypt(params, hasProtectedData, &errorDetailMsg);
|
||||
native_handle_delete(handle);
|
||||
if (res != Status::OK) {
|
||||
detailedError = errorDetailMsg.data();
|
||||
@@ -296,13 +296,13 @@ SharedBufferBase::~SharedBufferBase() {
|
||||
return binder;
|
||||
}
|
||||
|
||||
Status WVCryptoPlugin::attemptDecrypt(const CdmDecryptionParametersV16& params,
|
||||
bool hasProtectedData,
|
||||
std::string* errorDetailMsg) {
|
||||
::wvdrm::WvStatus WVCryptoPlugin::attemptDecrypt(
|
||||
const CdmDecryptionParametersV16& params, bool hasProtectedData,
|
||||
std::string* errorDetailMsg) {
|
||||
CdmResponseType res = mCDM->DecryptV16(mSessionId, hasProtectedData, params);
|
||||
|
||||
if (::wvdrm::isCdmResponseTypeSuccess(res)) {
|
||||
return Status::OK;
|
||||
return ::wvdrm::WvStatus(Status::OK);
|
||||
} else {
|
||||
ALOGE("Decrypt error in session %s during a sample %s protected data: %d",
|
||||
mSessionId.c_str(), hasProtectedData ? "with" : "without", static_cast<int>(res));
|
||||
@@ -340,7 +340,7 @@ Status WVCryptoPlugin::attemptDecrypt(const CdmDecryptionParametersV16& params,
|
||||
break;
|
||||
}
|
||||
|
||||
return ::wvdrm::mapCdmResponseType<Status>(res);
|
||||
return ::wvdrm::mapCdmResponseType(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ LOCAL_STATIC_LIBRARIES := \
|
||||
libgmock_main \
|
||||
libgtest \
|
||||
libwvlevel3 \
|
||||
libwvdrmcryptoplugin_aidl \
|
||||
libwv_odk \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
@@ -42,6 +41,7 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
liblog \
|
||||
libprotobuf-cpp-lite \
|
||||
libutils \
|
||||
libwvaidl \
|
||||
|
||||
LOCAL_HEADER_LIBRARIES := \
|
||||
libstagefright_headers \
|
||||
|
||||
@@ -63,45 +63,3 @@ cc_library_static {
|
||||
|
||||
proprietary: true,
|
||||
}
|
||||
|
||||
// Builds libwvdrmdrmplugin_aidl_fuzz
|
||||
//
|
||||
cc_library_static {
|
||||
name: "libwvdrmdrmplugin_aidl_fuzz",
|
||||
|
||||
srcs: [
|
||||
"src/WVDrmPlugin.cpp",
|
||||
"src/WVGenericCryptoInterface.cpp",
|
||||
"src/wv_metrics_adapter.cpp",
|
||||
],
|
||||
|
||||
include_dirs: [
|
||||
"frameworks/av/include",
|
||||
"frameworks/native/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/core/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/metrics/include",
|
||||
"vendor/widevine/libwvdrmengine/cdm/util/include",
|
||||
"vendor/widevine/libwvdrmengine/include",
|
||||
"vendor/widevine/libwvdrmengine/mediadrm/include",
|
||||
"vendor/widevine/libwvdrmengine/oemcrypto/include",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"libstagefright_headers",
|
||||
"libstagefright_foundation_headers",
|
||||
"libutils_headers",
|
||||
],
|
||||
|
||||
static_libs: ["libcdm_protos"],
|
||||
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"libcrypto",
|
||||
"liblog",
|
||||
"android.hardware.drm-V1-ndk",
|
||||
],
|
||||
|
||||
proprietary: true,
|
||||
}
|
||||
|
||||
@@ -308,14 +308,14 @@ class WVDrmPlugin : public ::aidl::android::hardware::drm::BnDrmPlugin,
|
||||
// calls into the CDM in order to identify which CDM instance should receive
|
||||
// the call. Calling this will seal the CDM Identifier Builder, thus making
|
||||
// it an error to change the origin.
|
||||
Status getCdmIdentifier(CdmIdentifier* identifier);
|
||||
WvStatus getCdmIdentifier(CdmIdentifier* identifier);
|
||||
|
||||
// Gets the application-safe device-unique ID. On non-SPOID devices, this is
|
||||
// the device-unique ID from OEMCrypto. On SPOID devices, this is the SPOID.
|
||||
// On SPOID devices, calling this will seal the CDM Identifier Builder, thus
|
||||
// making it an error to change the origin.
|
||||
Status getDeviceUniqueId(std::string* id);
|
||||
Status getProvisioningUniqueId(std::string* id);
|
||||
WvStatus getDeviceUniqueId(std::string* id);
|
||||
WvStatus getProvisioningUniqueId(std::string* id);
|
||||
|
||||
const std::string& origin() const { return mCdmIdentifier.origin; }
|
||||
bool set_origin(const std::string& id);
|
||||
@@ -339,16 +339,16 @@ class WVDrmPlugin : public ::aidl::android::hardware::drm::BnDrmPlugin,
|
||||
std::string mAppPackageName;
|
||||
const WVDrmPlugin& mParent;
|
||||
|
||||
Status calculateSpoid();
|
||||
WvStatus calculateSpoid();
|
||||
Status calculateSpoid(const std::string& deviceID, std::string* spoid);
|
||||
|
||||
// Gets the device-unique ID from OEMCrypto. This must be private, since
|
||||
// this value must not be exposed to applications on SPOID devices. Code
|
||||
// outside this class should use getDeviceUniqueId() to get the
|
||||
// application-safe device-unique ID.
|
||||
Status getOemcryptoDeviceId(std::string* id);
|
||||
Status getOemcryptoDeviceId(wvcdm::RequestedSecurityLevel securityLevel,
|
||||
std::string* id);
|
||||
WvStatus getOemcryptoDeviceId(std::string* id);
|
||||
WvStatus getOemcryptoDeviceId(wvcdm::RequestedSecurityLevel securityLevel,
|
||||
std::string* id);
|
||||
|
||||
// The unique identifier is meant to ensure that two clients with the
|
||||
// same spoid, origin and app package name still get different cdm engine
|
||||
@@ -409,22 +409,22 @@ class WVDrmPlugin : public ::aidl::android::hardware::drm::BnDrmPlugin,
|
||||
|
||||
::ndk::SpAIBinder createBinder() override;
|
||||
|
||||
Status queryProperty(const std::string& property,
|
||||
std::string& stringValue) const;
|
||||
WvStatus queryProperty(const std::string& property,
|
||||
std::string& stringValue) const;
|
||||
|
||||
Status queryProperty(wvcdm::RequestedSecurityLevel securityLevel,
|
||||
const std::string& property,
|
||||
std::string& stringValue) const;
|
||||
WvStatus queryProperty(wvcdm::RequestedSecurityLevel securityLevel,
|
||||
const std::string& property,
|
||||
std::string& stringValue) const;
|
||||
|
||||
Status queryProperty(const std::string& property,
|
||||
std::vector<uint8_t>& vector_value) const;
|
||||
WvStatus queryProperty(const std::string& property,
|
||||
std::vector<uint8_t>& vector_value) const;
|
||||
|
||||
bool isProvisioned(wvcdm::CdmSecurityLevel securityLevel,
|
||||
const std::string& origin, const std::string& spoid,
|
||||
bool atsc_mode_enabled) const;
|
||||
|
||||
Status mapAndNotifyOfCdmResponseType(const std::vector<uint8_t>& sessionId,
|
||||
CdmResponseType res);
|
||||
WvStatus mapAndNotifyOfCdmResponseType(const std::vector<uint8_t>& sessionId,
|
||||
CdmResponseType res);
|
||||
|
||||
void notifyOfCdmResponseType(const std::vector<uint8_t>& sessionId,
|
||||
CdmResponseType res);
|
||||
@@ -439,11 +439,11 @@ class WVDrmPlugin : public ::aidl::android::hardware::drm::BnDrmPlugin,
|
||||
|
||||
wvcdm::RequestedSecurityLevel getRequestedSecurityLevel() const;
|
||||
|
||||
Status openSessionCommon(std::vector<uint8_t>& sessionId);
|
||||
WvStatus openSessionCommon(std::vector<uint8_t>& sessionId);
|
||||
|
||||
bool initDataResemblesPSSH(const std::vector<uint8_t>& initData);
|
||||
|
||||
Status unprovision(const CdmIdentifier& identifier);
|
||||
WvStatus unprovision(const CdmIdentifier& identifier);
|
||||
|
||||
void sendEvent(::aidl::android::hardware::drm::EventType in_eventType,
|
||||
const std::vector<uint8_t>& in_sessionId,
|
||||
|
||||
@@ -181,20 +181,20 @@ void WVDrmPlugin::Close() {
|
||||
mCryptoSessions.clear();
|
||||
if (mCdmIdentifierBuilder.is_sealed()) {
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
ALOGE("Failed to get cdm identifier %d", status);
|
||||
ALOGE("Failed to get cdm identifier %d", status.get());
|
||||
} else {
|
||||
status = mapCdmResponseType(mCDM->CloseCdm(identifier));
|
||||
if (status != Status::OK) {
|
||||
ALOGE("Failed to close cdm. status %d", status);
|
||||
ALOGE("Failed to close cdm. status %d", status.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::openSessionCommon(vector<uint8_t>& sessionId) {
|
||||
Status status = Status::OK;
|
||||
WvStatus WVDrmPlugin::openSessionCommon(vector<uint8_t>& sessionId) {
|
||||
WvStatus status(Status::OK);
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
@@ -207,8 +207,7 @@ Status WVDrmPlugin::openSessionCommon(vector<uint8_t>& sessionId) {
|
||||
identifier, this, &cdmSessionId);
|
||||
|
||||
if (!isCdmResponseTypeSuccess(res)) {
|
||||
status = mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
return status;
|
||||
return mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
@@ -230,21 +229,20 @@ Status WVDrmPlugin::openSessionCommon(vector<uint8_t>& sessionId) {
|
||||
if (success) {
|
||||
// Marshal Session ID
|
||||
sessionId = StrToVector(cdmSessionId);
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
} else {
|
||||
mCDM->CloseSession(cdmSessionId);
|
||||
|
||||
if (!isCdmResponseTypeSuccess(res)) {
|
||||
// We got an error code we can return.
|
||||
status = mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
return mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
} else {
|
||||
// We got a failure that did not give us an error code, such as a failure
|
||||
// of AttachEventListener() or the key being missing from the map.
|
||||
ALOGW("Returns UNKNOWN error for legacy status kErrorCDMGeneric");
|
||||
status = Status::ERROR_DRM_UNKNOWN;
|
||||
return WvStatus(Status::ERROR_DRM_UNKNOWN);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
@@ -276,10 +274,10 @@ SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
}
|
||||
|
||||
std::string native_security_level;
|
||||
Status status =
|
||||
auto status =
|
||||
queryProperty(wvcdm::kLevelDefault, wvcdm::QUERY_KEY_SECURITY_LEVEL,
|
||||
native_security_level);
|
||||
if (Status::OK != status) {
|
||||
if (status != Status::OK) {
|
||||
*_aidl_return = sessionId;
|
||||
return toNdkScopedAStatus(status);
|
||||
}
|
||||
@@ -298,7 +296,7 @@ SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
setPropertyString("securityLevel", std::string(wvcdm_security_level));
|
||||
|
||||
status = openSessionCommon(sessionId);
|
||||
if (Status::OK == status) {
|
||||
if (status == Status::OK) {
|
||||
SecurityLevel currentSecurityLevel = SecurityLevel::UNKNOWN;
|
||||
const auto ret = getSecurityLevel(sessionId, ¤tSecurityLevel);
|
||||
if (!ret.isOk() || in_securityLevel != currentSecurityLevel) {
|
||||
@@ -306,7 +304,7 @@ SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
in_securityLevel);
|
||||
closeSession(sessionId);
|
||||
sessionId.clear();
|
||||
status = Status::ERROR_DRM_INVALID_STATE;
|
||||
status = WvStatus(Status::ERROR_DRM_INVALID_STATE);
|
||||
}
|
||||
}
|
||||
*_aidl_return = sessionId;
|
||||
@@ -341,13 +339,12 @@ SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
return toNdkScopedAStatus(Status::BAD_VALUE);
|
||||
}
|
||||
KeyRequestType requestType = KeyRequestType::UNKNOWN;
|
||||
Status status = Status::OK;
|
||||
WvStatus status(Status::OK);
|
||||
std::string defaultUrl;
|
||||
vector<uint8_t> request;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status =
|
||||
static_cast<Status>(mCdmIdentifierBuilder.getCdmIdentifier(&identifier));
|
||||
status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
_aidl_return->request = request;
|
||||
_aidl_return->requestType = KeyRequestType::UNKNOWN;
|
||||
@@ -491,7 +488,7 @@ SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
keySetId = StrToVector(cdmKeySetId);
|
||||
}
|
||||
|
||||
Status status = Status::OK;
|
||||
WvStatus status(Status::OK);
|
||||
if (isRelease) {
|
||||
// When releasing keys, we do not have a session ID.
|
||||
status = mapCdmResponseType(res);
|
||||
@@ -502,7 +499,7 @@ SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
// don't return the error. This is because "NEED_KEY" from AddKey() is an
|
||||
// expected behavior when sending a privacy certificate.
|
||||
if (res == wvcdm::NEED_KEY && mPropertySet.use_privacy_mode()) {
|
||||
status = Status::OK;
|
||||
status = WvStatus(Status::OK);
|
||||
}
|
||||
}
|
||||
_aidl_return->keySetId = keySetId;
|
||||
@@ -571,7 +568,7 @@ SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
const std::string& in_certificateType,
|
||||
const std::string& in_certificateAuthority,
|
||||
::aidl::android::hardware::drm::ProvisionRequest* _aidl_return) {
|
||||
Status status = Status::OK;
|
||||
WvStatus status(Status::OK);
|
||||
std::string defaultUrl;
|
||||
vector<uint8_t> request;
|
||||
|
||||
@@ -629,7 +626,7 @@ SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
vector<uint8_t> wrappedKey;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
_aidl_return->certificate = certificate;
|
||||
_aidl_return->wrappedKey = wrappedKey;
|
||||
@@ -664,7 +661,7 @@ SecurityLevel WVDrmPlugin::mapSecurityLevel(const std::string& level) {
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::unprovisionDevice() {
|
||||
return unprovision(kDefaultCdmIdentifier);
|
||||
return unprovision(kDefaultCdmIdentifier).get();
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmPlugin::getSecureStop(
|
||||
@@ -679,7 +676,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
SecureStop secureStop;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
*_aidl_return = SecureStop();
|
||||
return toNdkScopedAStatus(status);
|
||||
@@ -710,7 +707,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
vector<SecureStop> secureStopsVec;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
*_aidl_return = secureStopsVec;
|
||||
return toNdkScopedAStatus(status);
|
||||
@@ -756,7 +753,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
}
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
return toNdkScopedAStatus(status);
|
||||
}
|
||||
@@ -770,7 +767,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
::ndk::ScopedAStatus WVDrmPlugin::getMetrics(
|
||||
vector<::aidl::android::hardware::drm::DrmMetricGroup>* _aidl_return) {
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
*_aidl_return = vector<DrmMetricGroup>();
|
||||
return toNdkScopedAStatus(status);
|
||||
@@ -795,7 +792,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
vector<SecureStopId> secureStopIds;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
*_aidl_return = secureStopIds;
|
||||
return toNdkScopedAStatus(status);
|
||||
@@ -825,7 +822,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
}
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
return toNdkScopedAStatus(status);
|
||||
}
|
||||
@@ -843,7 +840,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
}
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
return toNdkScopedAStatus(status);
|
||||
}
|
||||
@@ -857,7 +854,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
|
||||
::ndk::ScopedAStatus WVDrmPlugin::removeAllSecureStops() {
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
return toNdkScopedAStatus(status);
|
||||
}
|
||||
@@ -873,7 +870,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
HdcpLevel maxLevel = HdcpLevel::HDCP_NO_OUTPUT;
|
||||
|
||||
std::string level;
|
||||
Status status = queryProperty(wvcdm::QUERY_KEY_CURRENT_HDCP_LEVEL, level);
|
||||
auto status = queryProperty(wvcdm::QUERY_KEY_CURRENT_HDCP_LEVEL, level);
|
||||
if (status == Status::OK) {
|
||||
connectedLevel = mapHdcpLevel(level);
|
||||
} else {
|
||||
@@ -904,8 +901,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
uint32_t maxSessions = 1;
|
||||
|
||||
std::string value;
|
||||
Status status =
|
||||
queryProperty(wvcdm::QUERY_KEY_NUMBER_OF_OPEN_SESSIONS, value);
|
||||
auto status = queryProperty(wvcdm::QUERY_KEY_NUMBER_OF_OPEN_SESSIONS, value);
|
||||
if (status == Status::OK) {
|
||||
currentSessions = std::strtoul(value.c_str(), nullptr, 10);
|
||||
} else {
|
||||
@@ -963,7 +959,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
vector<KeySetId> keySetIdsVec;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
*_aidl_return = keySetIdsVec;
|
||||
return toNdkScopedAStatus(status);
|
||||
@@ -1005,7 +1001,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
}
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
*_aidl_return = licenseState;
|
||||
return toNdkScopedAStatus(status);
|
||||
@@ -1052,7 +1048,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
}
|
||||
|
||||
CdmIdentifier identifier;
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
return toNdkScopedAStatus(status);
|
||||
}
|
||||
@@ -1066,15 +1062,15 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
CdmResponseType res = mCDM->RemoveOfflineLicense(
|
||||
std::string(in_keySetId.keySetId.begin(), in_keySetId.keySetId.end()),
|
||||
wvcdm::kSecurityLevelL3, identifier);
|
||||
status = mapCdmResponseType(res);
|
||||
return toNdkScopedAStatus(mapCdmResponseType(res));
|
||||
}
|
||||
|
||||
return toNdkScopedAStatus(status);
|
||||
return toNdkScopedAStatus(Status::OK);
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmPlugin::getPropertyString(
|
||||
const std::string& in_propertyName, std::string* _aidl_return) {
|
||||
Status status = Status::OK;
|
||||
WvStatus status(Status::OK);
|
||||
std::string name(in_propertyName.c_str());
|
||||
std::string value;
|
||||
|
||||
@@ -1169,7 +1165,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
|
||||
::ndk::ScopedAStatus WVDrmPlugin::getPropertyByteArray(
|
||||
const std::string& in_propertyName, vector<uint8_t>* _aidl_return) {
|
||||
Status status = Status::OK;
|
||||
WvStatus status(Status::OK);
|
||||
std::string name(in_propertyName.c_str());
|
||||
vector<uint8_t> value;
|
||||
|
||||
@@ -1198,7 +1194,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
CdmIdentifier identifier;
|
||||
status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
ALOGE("Unexpected error retrieving cdm identifier: %d", status);
|
||||
ALOGE("Unexpected error retrieving cdm identifier: %d", status.get());
|
||||
} else {
|
||||
status = mapCdmResponseType(mCDM->GetMetrics(identifier, &metrics));
|
||||
}
|
||||
@@ -1206,14 +1202,14 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
if (status == Status::OK) {
|
||||
std::string serialized_metrics;
|
||||
if (!metrics.SerializeToString(&serialized_metrics)) {
|
||||
status = Status::ERROR_DRM_UNKNOWN;
|
||||
status = WvStatus(Status::ERROR_DRM_UNKNOWN);
|
||||
} else {
|
||||
value = StrToVector(serialized_metrics);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ALOGE("App requested unknown byte array property %s", name.c_str());
|
||||
status = Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
status = WvStatus(Status::ERROR_DRM_CANNOT_HANDLE);
|
||||
}
|
||||
|
||||
*_aidl_return = value;
|
||||
@@ -1232,7 +1228,7 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
} else if (_value == wvcdm::QUERY_VALUE_SECURITY_LEVEL_L1.c_str()) {
|
||||
// We must be sure we CAN set the security level to L1.
|
||||
std::string current_security_level;
|
||||
Status status =
|
||||
auto status =
|
||||
queryProperty(wvcdm::kLevelDefault, wvcdm::QUERY_KEY_SECURITY_LEVEL,
|
||||
current_security_level);
|
||||
if (status != Status::OK) {
|
||||
@@ -1836,14 +1832,14 @@ void WVDrmPlugin::OnSessionLostState(const CdmSessionId& cdmSessionId) {
|
||||
sendSessionLostState(sessionId);
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::queryProperty(const std::string& property,
|
||||
std::string& stringValue) const {
|
||||
WvStatus WVDrmPlugin::queryProperty(const std::string& property,
|
||||
std::string& stringValue) const {
|
||||
return queryProperty(getRequestedSecurityLevel(), property, stringValue);
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::queryProperty(RequestedSecurityLevel securityLevel,
|
||||
const std::string& property,
|
||||
std::string& stringValue) const {
|
||||
WvStatus WVDrmPlugin::queryProperty(RequestedSecurityLevel securityLevel,
|
||||
const std::string& property,
|
||||
std::string& stringValue) const {
|
||||
CdmResponseType res =
|
||||
mCDM->QueryStatus(securityLevel, property, &stringValue);
|
||||
|
||||
@@ -1859,13 +1855,13 @@ Status WVDrmPlugin::queryProperty(RequestedSecurityLevel securityLevel,
|
||||
return binder;
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::queryProperty(const std::string& property,
|
||||
vector<uint8_t>& vector_value) const {
|
||||
WvStatus WVDrmPlugin::queryProperty(const std::string& property,
|
||||
vector<uint8_t>& vector_value) const {
|
||||
std::string string_value;
|
||||
Status status = queryProperty(property, string_value);
|
||||
auto status = queryProperty(property, string_value);
|
||||
if (status != Status::OK) return status;
|
||||
vector_value = StrToVector(string_value);
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
}
|
||||
|
||||
bool WVDrmPlugin::isProvisioned(wvcdm::CdmSecurityLevel securityLevel,
|
||||
@@ -1875,7 +1871,7 @@ bool WVDrmPlugin::isProvisioned(wvcdm::CdmSecurityLevel securityLevel,
|
||||
return mCDM->IsProvisioned(securityLevel, origin, spoid, atsc_mode_enabled);
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::mapAndNotifyOfCdmResponseType(
|
||||
WvStatus WVDrmPlugin::mapAndNotifyOfCdmResponseType(
|
||||
const vector<uint8_t>& sessionId, CdmResponseType res) {
|
||||
notifyOfCdmResponseType(sessionId, res);
|
||||
return mapCdmResponseType(res);
|
||||
@@ -1964,7 +1960,7 @@ bool WVDrmPlugin::initDataResemblesPSSH(const vector<uint8_t>& initData) {
|
||||
return id == kPsshTag;
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::unprovision(const CdmIdentifier& identifier) {
|
||||
WvStatus WVDrmPlugin::unprovision(const CdmIdentifier& identifier) {
|
||||
if (mPropertySet.use_atsc_mode())
|
||||
return mapCdmResponseType(wvcdm::PROVISIONING_NOT_ALLOWED_FOR_ATSC);
|
||||
|
||||
@@ -1990,44 +1986,44 @@ WVDrmPlugin::CdmIdentifierBuilder::CdmIdentifierBuilder(
|
||||
mCdmIdentifier.user_id = wvutil::GetIpcCallingUid();
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::getCdmIdentifier(
|
||||
WvStatus WVDrmPlugin::CdmIdentifierBuilder::getCdmIdentifier(
|
||||
CdmIdentifier* identifier) {
|
||||
if (!mIsIdentifierSealed) {
|
||||
Status res = calculateSpoid();
|
||||
auto res = calculateSpoid();
|
||||
if (res != Status::OK) return res;
|
||||
mIsIdentifierSealed = true;
|
||||
}
|
||||
*identifier = mCdmIdentifier;
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::getDeviceUniqueId(std::string* id) {
|
||||
WvStatus WVDrmPlugin::CdmIdentifierBuilder::getDeviceUniqueId(std::string* id) {
|
||||
if (mUseSpoid) {
|
||||
CdmIdentifier identifier;
|
||||
Status res = getCdmIdentifier(&identifier);
|
||||
auto res = getCdmIdentifier(&identifier);
|
||||
if (res != Status::OK) return res;
|
||||
|
||||
*id = identifier.spoid;
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
} else {
|
||||
return getOemcryptoDeviceId(id);
|
||||
}
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::getProvisioningUniqueId(
|
||||
WvStatus WVDrmPlugin::CdmIdentifierBuilder::getProvisioningUniqueId(
|
||||
std::string* id) {
|
||||
if (mUseSpoid) {
|
||||
// To fake a provisioning-unique ID on SPOID devices where we can't expose
|
||||
// the real provisioning-unique ID, we just use the SPOID and invert all
|
||||
// the bits.
|
||||
Status res = getDeviceUniqueId(id);
|
||||
auto res = getDeviceUniqueId(id);
|
||||
if (res != Status::OK) return res;
|
||||
|
||||
for (char& c : *id) {
|
||||
c = ~c;
|
||||
}
|
||||
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
} else {
|
||||
return mParent.queryProperty(wvcdm::QUERY_KEY_PROVISIONING_ID, *id);
|
||||
}
|
||||
@@ -2046,16 +2042,16 @@ bool WVDrmPlugin::CdmIdentifierBuilder::set_use_atsc_mode(bool enable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid() {
|
||||
if (!mUseSpoid) return Status::OK;
|
||||
WvStatus WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid() {
|
||||
if (!mUseSpoid) return WvStatus(Status::OK);
|
||||
|
||||
// Calculate SPOID for default security level if appropriate
|
||||
std::string deviceId;
|
||||
if (mParent.getRequestedSecurityLevel() == wvcdm::kLevelDefault) {
|
||||
Status res = getOemcryptoDeviceId(&deviceId);
|
||||
auto res = getOemcryptoDeviceId(&deviceId);
|
||||
if (res != Status::OK) return res;
|
||||
|
||||
return calculateSpoid(deviceId, &mCdmIdentifier.spoid);
|
||||
return WvStatus(calculateSpoid(deviceId, &mCdmIdentifier.spoid));
|
||||
}
|
||||
|
||||
// If requested security level is L3, possibilities are
|
||||
@@ -2066,12 +2062,12 @@ Status WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid() {
|
||||
// provisioned with this SPOID, return this SPOID. Check (c) next. Get L1
|
||||
// device ID, calculate SPOID and if provisioned with this SPOID, return
|
||||
// this SPOID. On any errors in (c) or not provisioned return L3 SPOID.
|
||||
Status res = getOemcryptoDeviceId(wvcdm::kLevel3, &deviceId);
|
||||
auto res = getOemcryptoDeviceId(wvcdm::kLevel3, &deviceId);
|
||||
if (res != Status::OK) return res;
|
||||
|
||||
std::string spoidL3;
|
||||
res = calculateSpoid(deviceId, &spoidL3);
|
||||
if (res != Status::OK) return res;
|
||||
auto status = calculateSpoid(deviceId, &spoidL3);
|
||||
if (status != Status::OK) return WvStatus(status);
|
||||
|
||||
bool atsc_mode_enabled =
|
||||
mCdmIdentifier.app_package_name == wvcdm::ATSC_APP_PACKAGE_NAME;
|
||||
@@ -2079,7 +2075,7 @@ Status WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid() {
|
||||
if (mParent.isProvisioned(wvcdm::kSecurityLevelL3, origin(), spoidL3,
|
||||
atsc_mode_enabled)) {
|
||||
mCdmIdentifier.spoid = spoidL3;
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
}
|
||||
|
||||
// Not provisioned with CdmIdentifier containing SPOID with L3 device ID.
|
||||
@@ -2088,33 +2084,33 @@ Status WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid() {
|
||||
res = getOemcryptoDeviceId(wvcdm::kLevelDefault, &deviceIdLevelDefault);
|
||||
if (res != Status::OK) {
|
||||
mCdmIdentifier.spoid = spoidL3;
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
}
|
||||
|
||||
// If the L3 and default security level IDs are identical then the
|
||||
// device does not support L1.
|
||||
if (deviceId == deviceIdLevelDefault) {
|
||||
mCdmIdentifier.spoid = spoidL3;
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
}
|
||||
|
||||
std::string spoidLevelDefault;
|
||||
res = calculateSpoid(deviceIdLevelDefault, &spoidLevelDefault);
|
||||
if (res != Status::OK) {
|
||||
status = calculateSpoid(deviceIdLevelDefault, &spoidLevelDefault);
|
||||
if (status != Status::OK) {
|
||||
mCdmIdentifier.spoid = spoidL3;
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
}
|
||||
|
||||
if (mParent.isProvisioned(wvcdm::kSecurityLevelL1, origin(),
|
||||
spoidLevelDefault, atsc_mode_enabled)) {
|
||||
mCdmIdentifier.spoid = spoidLevelDefault;
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
}
|
||||
|
||||
// Not provisioned with CdmIdentifier containing SPOID with L1 or L3
|
||||
// device ID. Return L3 SPOID.
|
||||
mCdmIdentifier.spoid = spoidL3;
|
||||
return Status::OK;
|
||||
return WvStatus(Status::OK);
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid(
|
||||
@@ -2138,12 +2134,12 @@ Status WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid(
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::getOemcryptoDeviceId(
|
||||
WvStatus WVDrmPlugin::CdmIdentifierBuilder::getOemcryptoDeviceId(
|
||||
std::string* id) {
|
||||
return mParent.queryProperty(wvcdm::QUERY_KEY_DEVICE_ID, *id);
|
||||
}
|
||||
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::getOemcryptoDeviceId(
|
||||
WvStatus WVDrmPlugin::CdmIdentifierBuilder::getOemcryptoDeviceId(
|
||||
wvcdm::RequestedSecurityLevel securityLevel, std::string* id) {
|
||||
return mParent.queryProperty(securityLevel, wvcdm::QUERY_KEY_DEVICE_ID, *id);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ LOCAL_STATIC_LIBRARIES := \
|
||||
libgmock_main \
|
||||
libgtest \
|
||||
libwvlevel3 \
|
||||
libwvdrmdrmplugin_aidl \
|
||||
libwv_odk \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
@@ -41,6 +40,7 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
liblog \
|
||||
libprotobuf-cpp-lite \
|
||||
libutils \
|
||||
libwvaidl \
|
||||
|
||||
LOCAL_HEADER_LIBRARIES := \
|
||||
libstagefright_headers \
|
||||
@@ -91,7 +91,6 @@ LOCAL_STATIC_LIBRARIES := \
|
||||
libgtest \
|
||||
libgtest_main \
|
||||
libjsmn \
|
||||
libwvdrmdrmplugin_aidl \
|
||||
libwvlevel3 \
|
||||
libwv_odk \
|
||||
|
||||
@@ -101,6 +100,7 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
liblog \
|
||||
libprotobuf-cpp-lite \
|
||||
libutils \
|
||||
libwvaidl \
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
external/protobuf/src \
|
||||
|
||||
168
libwvdrmengine/src/Utils.cpp
Normal file
168
libwvdrmengine/src/Utils.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
//
|
||||
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
//
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
namespace {
|
||||
// Please keep the order stable.
|
||||
// If APIs are renamed please keep the old enum and add new enum to bottom.
|
||||
enum CryptoSessionApi : int32_t {
|
||||
API_UNKNOWN = 0,
|
||||
GET_PROVISIONING_METHOD = 1,
|
||||
GET_TOKEN_FROM_KEYBOX = 2,
|
||||
GET_TOKEN_FROM_OEM_CERT = 3,
|
||||
GET_PROVISIONING_TOKEN = 4,
|
||||
GET_INTERNAL_DEVICE_UNIQUE_ID = 5,
|
||||
GET_EXTERNAL_DEVICE_UNIQUE_ID = 6,
|
||||
GET_PROVISIONING_ID = 7,
|
||||
OPEN = 8,
|
||||
PREPARE_AND_SIGN_LICENSE_REQUEST = 9,
|
||||
USE_SECONDARY_KEY = 10,
|
||||
LOAD_LICENSE = 11,
|
||||
PREPARE_AND_SIGN_RENEWAL_REQUEST = 12,
|
||||
LOAD_RENEWAL = 13,
|
||||
PREPARE_AND_SIGN_PROVISIONING_REQUEST = 14,
|
||||
LOAD_ENTITLED_CONTENT_KEYS = 15,
|
||||
LOAD_CERTIFICATE_PRIVATE_KEY = 16,
|
||||
GET_BOOT_CERTIFICATE_CHAIN = 17,
|
||||
GENERATE_CERTIFICATE_KEY_PAIR = 18,
|
||||
LOAD_OEM_CERTIFICATE_PRIVATE_KEY = 19,
|
||||
SELECT_KEY = 20,
|
||||
GENERATE_DERIVED_KEYS = 21,
|
||||
GENERATE_RSA_SIGNATURE = 22,
|
||||
DECRYPT = 23,
|
||||
DEACTIVATE_USAGE_INFORMATION = 24,
|
||||
GENERATE_USAGE_REPORT = 25,
|
||||
GENERATE_NONCE = 26,
|
||||
LOAD_PROVISIONING = 27,
|
||||
GET_HDCP_CAPABILITIES = 28,
|
||||
GET_RANDOM = 29,
|
||||
GET_NUMBER_OF_OPEN_SESSIONS = 30,
|
||||
GET_MAX_NUMBER_OF_SESSIONS = 31,
|
||||
GET_SRM_VERSION = 32,
|
||||
SET_DECRYPT_HASH = 33,
|
||||
GET_DECRYPT_HASH_ERROR = 34,
|
||||
GENERIC_ENCRYPT = 35,
|
||||
GENERIC_DECRYPT = 36,
|
||||
GENERIC_SIGN = 37,
|
||||
GENERIC_VERIFY = 38,
|
||||
CREATE_USAGE_TABLE_HEADER = 39,
|
||||
LOAD_USAGE_TABLE_HEADER = 40,
|
||||
SHRINK_USAGE_TABLE_HEADER = 41,
|
||||
CREATE_USAGE_ENTRY = 42,
|
||||
LOAD_USAGE_ENTRY = 43,
|
||||
UPDATE_USAGE_ENTRY = 44,
|
||||
MOVE_USAGE_ENTRY = 45,
|
||||
SET_DEBUG_IGNORE_KEYBOX_COUNT = 46,
|
||||
SET_ALLOW_TEST_KEYBOX = 47,
|
||||
PREPARE_OTA_PROVISIONING_REQUEST = 48,
|
||||
LOAD_OTA_PROVISIONING = 49,
|
||||
// insert new or renamed methods' enum below
|
||||
};
|
||||
|
||||
static std::unordered_map<std::string, CryptoSessionApi> const table = {
|
||||
{"ApiUnknown", API_UNKNOWN},
|
||||
{"GetProvisioningMethod", GET_PROVISIONING_METHOD},
|
||||
{"GetTokenFromKeybox", GET_TOKEN_FROM_KEYBOX},
|
||||
{"GetTokenFromOemCert", GET_TOKEN_FROM_OEM_CERT},
|
||||
{"GetProvisioningToken", GET_PROVISIONING_TOKEN},
|
||||
{"GetInternalDeviceUniqueId", GET_INTERNAL_DEVICE_UNIQUE_ID},
|
||||
{"GetExternalDeviceUniqueId", GET_EXTERNAL_DEVICE_UNIQUE_ID},
|
||||
{"GetProvisioningId", GET_PROVISIONING_ID},
|
||||
{"Open", OPEN},
|
||||
{"PrepareAndSignLicenseRequest", PREPARE_AND_SIGN_LICENSE_REQUEST},
|
||||
{"UseSecondaryKey", USE_SECONDARY_KEY},
|
||||
{"LoadLicense", LOAD_LICENSE},
|
||||
{"PrepareAndSignLicenseRequest", PREPARE_AND_SIGN_LICENSE_REQUEST},
|
||||
{"LoadRenewal", LOAD_RENEWAL},
|
||||
{"PrepareAndSignProvisioningRequest", PREPARE_AND_SIGN_PROVISIONING_REQUEST},
|
||||
{"LoadEntitledContentKeys", LOAD_ENTITLED_CONTENT_KEYS},
|
||||
{"LoadCertificatePrivateKey", LOAD_CERTIFICATE_PRIVATE_KEY},
|
||||
{"GetBootCertificateChain", GET_BOOT_CERTIFICATE_CHAIN},
|
||||
{"GenerateCertificateKeyPair", GENERATE_CERTIFICATE_KEY_PAIR},
|
||||
{"LoadOemCertificatePrivateKey", LOAD_OEM_CERTIFICATE_PRIVATE_KEY},
|
||||
{"SelectKey", SELECT_KEY},
|
||||
{"GenerateDerivedKeys", GENERATE_DERIVED_KEYS},
|
||||
{"GenerateRsaSignature", GENERATE_RSA_SIGNATURE},
|
||||
{"Decrypt", DECRYPT},
|
||||
{"DeactivateUsageInformation", DEACTIVATE_USAGE_INFORMATION},
|
||||
{"GenerateUsageReport", GENERATE_USAGE_REPORT},
|
||||
{"GenerateNonce", GENERATE_NONCE},
|
||||
{"LoadProvisioning", LOAD_PROVISIONING},
|
||||
{"GetHdcpCapabilities", GET_HDCP_CAPABILITIES},
|
||||
{"GetRandom", GET_RANDOM},
|
||||
{"GetNumberOfOpenSessions", GET_NUMBER_OF_OPEN_SESSIONS},
|
||||
{"GetMaxNumberOfSessions", GET_MAX_NUMBER_OF_SESSIONS},
|
||||
{"GetSrmVersion", GET_SRM_VERSION},
|
||||
{"SetDecryptHash", SET_DECRYPT_HASH},
|
||||
{"GetDecryptHashError", GET_DECRYPT_HASH_ERROR},
|
||||
{"GenericEncrypt", GENERIC_ENCRYPT},
|
||||
{"GenericDecrypt", GENERIC_DECRYPT},
|
||||
{"GenericSign", GENERIC_SIGN},
|
||||
{"GenericVerify", GENERIC_VERIFY},
|
||||
{"CreateUsageTableHeader", CREATE_USAGE_TABLE_HEADER},
|
||||
{"LoadUsageTableHeader", LOAD_USAGE_TABLE_HEADER},
|
||||
{"ShrinkUsageTableHeader", SHRINK_USAGE_TABLE_HEADER},
|
||||
{"CreateUsageEntry", CREATE_USAGE_ENTRY},
|
||||
{"LoadUsageEntry", LOAD_USAGE_ENTRY},
|
||||
{"UpdateUsageEntry", UPDATE_USAGE_ENTRY},
|
||||
{"MoveUsageEntry", MOVE_USAGE_ENTRY},
|
||||
{"SetDebugIgnoreKeyboxCount", SET_DEBUG_IGNORE_KEYBOX_COUNT},
|
||||
{"SetAllowTestKeybox", SET_ALLOW_TEST_KEYBOX},
|
||||
{"PrepareOtaProvisioningRequest", PREPARE_OTA_PROVISIONING_REQUEST},
|
||||
{"LoadOtaProvisioning", LOAD_OTA_PROVISIONING},
|
||||
// insert new or renamed methods below
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace wvdrm {
|
||||
|
||||
CryptoSessionApi getCryptoSessionMethodEnum(const std::string& method) {
|
||||
if (!method.empty()) {
|
||||
auto it = table.find(method);
|
||||
if (it != table.end()) {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
return API_UNKNOWN;
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus toNdkScopedAStatus(::wvdrm::WvStatus status,
|
||||
const char* msg) {
|
||||
if (status == ::aidl::android::hardware::drm::Status::OK) {
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
} else {
|
||||
auto err = static_cast<int32_t>(status);
|
||||
Json::Value jsonMsg(Json::objectValue);
|
||||
auto cdmErr = status.getCdmErr();
|
||||
auto cdmStatus = cdmErr.Enum();
|
||||
if (cdmStatus) {
|
||||
jsonMsg["cdmError"] = cdmStatus;
|
||||
}
|
||||
auto oemErr = cdmErr.getOEMCryptoResult();
|
||||
if (oemErr) {
|
||||
jsonMsg["oemError"] = oemErr;
|
||||
}
|
||||
auto cryptoSessionMethod = cdmErr.getCryptoSessionMethod();
|
||||
if (cryptoSessionMethod != nullptr) {
|
||||
jsonMsg["context"] =
|
||||
getCryptoSessionMethodEnum(std::string(cryptoSessionMethod));
|
||||
}
|
||||
if (msg) {
|
||||
jsonMsg["errorMessage"] = msg;
|
||||
}
|
||||
Json::FastWriter writer;
|
||||
return ::ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
err, writer.write(jsonMsg).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace wvdrm
|
||||
@@ -17,7 +17,7 @@ adb push $(OUT)/data/fuzz/arm64/lib/ /data/fuzz/arm64/lib/
|
||||
|
||||
adb shell<br>
|
||||
cd /data/fuzz/arm64<br>
|
||||
`LD_LIBRARY_PATH=/data/fuzz/arm65/lib /data/fuzz/arm64/android.hardware.drm-service.widevine.aidl_fuzzer/vendor/hw/android.hardware.drm-service.widevine.aidl_fuzzer`
|
||||
`LD_LIBRARY_PATH=/data/fuzz/arm64/lib /data/fuzz/arm64/android.hardware.drm-service.widevine.aidl_fuzzer/vendor/hw/android.hardware.drm-service.widevine.aidl_fuzzer`
|
||||
|
||||
## Monitoring
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ LOCAL_SRC_FILES := \
|
||||
LOCAL_C_INCLUDES := \
|
||||
frameworks/av/include \
|
||||
frameworks/native/include \
|
||||
vendor/widevine/libwvdrmengine/cdm/core/include \
|
||||
vendor/widevine/libwvdrmengine/include \
|
||||
vendor/widevine/libwvdrmengine/mediadrm/include \
|
||||
vendor/widevine/libwvdrmengine/oemcrypto/include \
|
||||
|
||||
Reference in New Issue
Block a user