Remove dependencies from frameworks C++ containers.
Replace AString, KeyedVector, List, String8 and Vector with stl containers. Remove corresponding frameworks libraries. Test: Play Movies & TV (streaming and pinning) Test: Netflix Test: unit tests bug: 34677927 Change-Id: I125f45054987d69bbca59c1ffdcbe8add38c3c13
This commit is contained in:
@@ -219,7 +219,6 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
libhwbinder \
|
||||
liblog \
|
||||
libprotobuf-cpp-lite \
|
||||
libstagefright_foundation \
|
||||
libutils \
|
||||
|
||||
LOCAL_MODULE := libwvhidl
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
#ifndef WVDRM_ANDROID_HARDWARE_DRM_V1_0_TYPECONVERT
|
||||
#define WVDRM_ANDROID_HARDWARE_DRM_V1_0_TYPECONVERT
|
||||
#include "utils/Errors.h"
|
||||
#include <utils/Vector.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <android/hardware/drm/1.0/types.h>
|
||||
#include <media/stagefright/MediaErrors.h>
|
||||
@@ -31,42 +32,42 @@ namespace widevine {
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_vec;
|
||||
|
||||
template<typename T> const hidl_vec<T> toHidlVec(const Vector<T> &Vector) {
|
||||
hidl_vec<T> vec;
|
||||
vec.setToExternal(const_cast<T *>(Vector.array()), Vector.size());
|
||||
template<typename T> const hidl_vec<T> toHidlVec(const std::vector<T> &vec) {
|
||||
hidl_vec<T> hVec;
|
||||
hVec.setToExternal(const_cast<T *>(vec.data()), vec.size());
|
||||
return hVec;
|
||||
}
|
||||
|
||||
template<typename T> hidl_vec<T> toHidlVec(std::vector<T> &vec) {
|
||||
hidl_vec<T> hVec;
|
||||
hVec.setToExternal(vec.data(), vec.size());
|
||||
return hVec;
|
||||
}
|
||||
|
||||
template<typename T> const std::vector<T> toVector(const hidl_vec<T> &hVec) {
|
||||
std::vector<T> vec;
|
||||
vec.assign(hVec.data(), hVec.data() + hVec.size());
|
||||
return *const_cast<const std::vector<T> *>(&vec);
|
||||
}
|
||||
|
||||
template<typename T> std::vector<T> toVector(hidl_vec<T> &hVec) {
|
||||
std::vector<T> vec;
|
||||
vec.assign(hVec.data(), hVec.data() + hVec.size());
|
||||
return vec;
|
||||
}
|
||||
|
||||
template<typename T> hidl_vec<T> toHidlVec(Vector<T> &Vector) {
|
||||
hidl_vec<T> vec;
|
||||
vec.setToExternal(Vector.editArray(), Vector.size());
|
||||
template<typename T, size_t SIZE> const std::vector<T> toVector(
|
||||
const hidl_array<T, SIZE> &hArray) {
|
||||
std::vector<T> vec;
|
||||
vec.assign(hArray.data(), hArray.data() + hArray.size());
|
||||
return vec;
|
||||
}
|
||||
|
||||
template<typename T> const Vector<T> toVector(const hidl_vec<T> &vec) {
|
||||
Vector<T> vector;
|
||||
vector.appendArray(vec.data(), vec.size());
|
||||
return *const_cast<const Vector<T> *>(&vector);
|
||||
}
|
||||
|
||||
template<typename T> Vector<T> toVector(hidl_vec<T> &vec) {
|
||||
Vector<T> vector;
|
||||
vector.appendArray(vec.data(), vec.size());
|
||||
return vector;
|
||||
}
|
||||
|
||||
template<typename T, size_t SIZE> const Vector<T> toVector(
|
||||
const hidl_array<T, SIZE> &array) {
|
||||
Vector<T> vector;
|
||||
vector.appendArray(array.data(), array.size());
|
||||
return vector;
|
||||
}
|
||||
|
||||
template<typename T, size_t SIZE> Vector<T> toVector(
|
||||
hidl_array<T, SIZE> &array) {
|
||||
Vector<T> vector;
|
||||
vector.appendArray(array.data(), array.size());
|
||||
return vector;
|
||||
template<typename T, size_t SIZE> std::vector<T> toVector(
|
||||
hidl_array<T, SIZE> &hArray) {
|
||||
std::vector<T> vec;
|
||||
vec.assign(hArray.data(), hArray.data() + hArray.size());
|
||||
return vec;
|
||||
}
|
||||
|
||||
Status toStatus(status_t mediaError);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <android/hardware/drm/1.0/ICryptoPlugin.h>
|
||||
#include <android/hidl/memory/1.0/IMemory.h>
|
||||
#include <media/stagefright/foundation/AString.h>
|
||||
|
||||
#include "wv_content_decryption_module.h"
|
||||
#include "WVTypes.h"
|
||||
@@ -71,7 +70,7 @@ struct WVCryptoPlugin : public ICryptoPlugin {
|
||||
|
||||
android::status_t attemptDecrypt(
|
||||
const wvcdm::CdmDecryptionParameters& params,
|
||||
bool haveEncryptedSubsamples, android::AString* errorDetailMsg);
|
||||
bool haveEncryptedSubsamples, std::string* errorDetailMsg);
|
||||
static wvcdm::CdmResponseType countEncryptedBlocksInPatternedRange(
|
||||
size_t range, const Pattern& pattern, uint64_t* result);
|
||||
static void incrementIV(uint64_t increaseBy, std::vector<uint8_t>* ivPtr);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
//#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "WVCdm"
|
||||
#include <utils/Log.h>
|
||||
#include <utils/String8.h>
|
||||
|
||||
#include "WVCryptoPlugin.h"
|
||||
#include "TypeConvert.h"
|
||||
@@ -35,7 +34,6 @@ using ::android::hardware::drm::V1_0::widevine::toStatus;
|
||||
using ::android::hardware::drm::V1_0::widevine::toVector;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
using android::AString;
|
||||
using android::status_t;
|
||||
|
||||
using wvcdm::CdmDecryptionParameters;
|
||||
@@ -85,7 +83,7 @@ Return<void> WVCryptoPlugin::notifyResolution(
|
||||
|
||||
Return<Status> WVCryptoPlugin::setMediaDrmSession(
|
||||
const hidl_vec<uint8_t>& sessionId) {
|
||||
const android::Vector<uint8_t> sId = toVector(sessionId);
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
if (!mCDM->IsOpenSession(cdmSessionId)) {
|
||||
return Status::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
@@ -141,7 +139,7 @@ Return<void> WVCryptoPlugin::decrypt(
|
||||
reinterpret_cast<const char*>(keyId.data()), wvcdm::KEY_ID_SIZE);
|
||||
std::vector<uint8_t> ivVector(iv.data(), iv.data() + wvcdm::KEY_IV_SIZE);
|
||||
|
||||
AString errorDetailMsg;
|
||||
std::string errorDetailMsg;
|
||||
sp<IMemory> sourceBase = mSharedBufferMap[source.bufferId];
|
||||
|
||||
if (source.offset + offset + source.size > sourceBase->getSize()) {
|
||||
@@ -319,7 +317,7 @@ Return<void> WVCryptoPlugin::decrypt(
|
||||
|
||||
status_t WVCryptoPlugin::attemptDecrypt(const CdmDecryptionParameters& params,
|
||||
bool haveEncryptedSubsamples,
|
||||
AString* errorDetailMsg) {
|
||||
std::string* errorDetailMsg) {
|
||||
CdmResponseType res = mCDM->Decrypt(mSessionId, haveEncryptedSubsamples,
|
||||
params);
|
||||
|
||||
@@ -331,27 +329,27 @@ status_t WVCryptoPlugin::attemptDecrypt(const CdmDecryptionParameters& params,
|
||||
params.is_encrypted ? "encrypted" : "unencrypted",
|
||||
res);
|
||||
if (res == wvcdm::INSUFFICIENT_CRYPTO_RESOURCES) {
|
||||
errorDetailMsg->setTo(
|
||||
errorDetailMsg->assign(
|
||||
"Error decrypting data: insufficient crypto resources");
|
||||
// This error is actionable by the app and should be passed up.
|
||||
return mapCdmResponseType(res);
|
||||
} else if (res == wvcdm::NEED_KEY) {
|
||||
errorDetailMsg->setTo(
|
||||
errorDetailMsg->assign(
|
||||
"Error decrypting data: requested key has not been loaded");
|
||||
// This error is actionable by the app and should be passed up.
|
||||
return mapCdmResponseType(res);
|
||||
} else if (res == wvcdm::SESSION_NOT_FOUND_FOR_DECRYPT) {
|
||||
errorDetailMsg->setTo(
|
||||
errorDetailMsg->assign(
|
||||
"Error decrypting data: session not found, possibly reclaimed");
|
||||
// This error is actionable by the app and should be passed up.
|
||||
return mapCdmResponseType(res);
|
||||
} else if (res == wvcdm::DECRYPT_ERROR) {
|
||||
errorDetailMsg->setTo(
|
||||
errorDetailMsg->assign(
|
||||
"Error decrypting data: unspecified error");
|
||||
// This error is actionable by the app and should be passed up.
|
||||
return mapCdmResponseType(res);
|
||||
} else if (res == wvcdm::INSUFFICIENT_OUTPUT_PROTECTION) {
|
||||
errorDetailMsg->setTo(
|
||||
errorDetailMsg->assign(
|
||||
"Error decrypting data: insufficient output protection");
|
||||
// This error is actionable by the app and should be passed up.
|
||||
return mapCdmResponseType(res);
|
||||
|
||||
@@ -33,7 +33,6 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
libcutils \
|
||||
libdl \
|
||||
liblog \
|
||||
libmedia \
|
||||
libprotobuf-cpp-lite \
|
||||
libstagefright_foundation \
|
||||
libutils \
|
||||
@@ -100,9 +99,7 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
libhidlbase \
|
||||
libhidlmemory \
|
||||
liblog \
|
||||
libmedia \
|
||||
libprotobuf-cpp-lite \
|
||||
libstagefright_foundation \
|
||||
libutils \
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
|
||||
@@ -31,8 +31,8 @@ include $(BUILD_STATIC_LIBRARY)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
src/WVGenericCryptoInterface.cpp \
|
||||
src_hidl/WVDrmPlugin.cpp \
|
||||
src_hidl/WVGenericCryptoInterface.cpp \
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
frameworks/av/include \
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include "cdm_client_property_set.h"
|
||||
#include "cdm_identifier.h"
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "utils/String8.h"
|
||||
#include "utils/Vector.h"
|
||||
#include "wv_cdm_event_listener.h"
|
||||
#include "wv_content_decryption_module.h"
|
||||
#include "WVGenericCryptoInterface.h"
|
||||
@@ -42,8 +40,6 @@ using ::android::hardware::Return;
|
||||
using ::android::sp;
|
||||
|
||||
using android::status_t;
|
||||
using android::String8;
|
||||
using android::Vector;
|
||||
using std::map;
|
||||
using wvcdm::CdmIdentifier;
|
||||
using wvcdm::CdmKeyStatusMap;
|
||||
@@ -350,20 +346,17 @@ struct WVDrmPlugin : public IDrmPlugin, IDrmPluginListener,
|
||||
std::string& stringValue) const;
|
||||
|
||||
status_t queryProperty(const std::string& property,
|
||||
String8& string8_value) const;
|
||||
std::vector<uint8_t>& vector_value) const;
|
||||
|
||||
status_t queryProperty(const std::string& property,
|
||||
Vector<uint8_t>& vector_value) const;
|
||||
|
||||
status_t mapAndNotifyOfCdmResponseType(const Vector<uint8_t>& sessionId,
|
||||
status_t mapAndNotifyOfCdmResponseType(const std::vector<uint8_t>& sessionId,
|
||||
CdmResponseType res);
|
||||
|
||||
status_t mapAndNotifyOfOEMCryptoResult(const Vector<uint8_t>& sessionId,
|
||||
status_t mapAndNotifyOfOEMCryptoResult(const std::vector<uint8_t>& sessionId,
|
||||
OEMCryptoResult res);
|
||||
|
||||
status_t mapOEMCryptoResult(OEMCryptoResult res);
|
||||
|
||||
bool initDataResemblesPSSH(const Vector<uint8_t>& initData);
|
||||
bool initDataResemblesPSSH(const std::vector<uint8_t>& initData);
|
||||
|
||||
status_t unprovision(const CdmIdentifier& identifier);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
|
||||
#ifndef WV_GENERIC_CRYPTO_INTERFACE_H_
|
||||
#define WV_GENERIC_CRYPTO_INTERFACE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "media/stagefright/foundation/ABase.h"
|
||||
|
||||
namespace wvdrm {
|
||||
|
||||
class WVGenericCryptoInterface {
|
||||
public:
|
||||
WVGenericCryptoInterface() {}
|
||||
virtual ~WVGenericCryptoInterface() {}
|
||||
|
||||
virtual OEMCryptoResult selectKey(const OEMCrypto_SESSION session,
|
||||
const uint8_t* key_id,
|
||||
size_t key_id_length) {
|
||||
return OEMCrypto_SelectKey(session, key_id, key_id_length);
|
||||
}
|
||||
|
||||
virtual OEMCryptoResult encrypt(OEMCrypto_SESSION session,
|
||||
const uint8_t* in_buffer,
|
||||
size_t buffer_length, const uint8_t* iv,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
uint8_t* out_buffer) {
|
||||
return OEMCrypto_Generic_Encrypt(session, in_buffer, buffer_length, iv,
|
||||
algorithm, out_buffer);
|
||||
}
|
||||
|
||||
virtual OEMCryptoResult decrypt(OEMCrypto_SESSION session,
|
||||
const uint8_t* in_buffer,
|
||||
size_t buffer_length, const uint8_t* iv,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
uint8_t* out_buffer) {
|
||||
return OEMCrypto_Generic_Decrypt(session, in_buffer, buffer_length, iv,
|
||||
algorithm, out_buffer);
|
||||
}
|
||||
|
||||
virtual OEMCryptoResult sign(OEMCrypto_SESSION session,
|
||||
const uint8_t* in_buffer, size_t buffer_length,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
uint8_t* signature, size_t* signature_length) {
|
||||
return OEMCrypto_Generic_Sign(session, in_buffer, buffer_length, algorithm,
|
||||
signature, signature_length);
|
||||
}
|
||||
|
||||
virtual OEMCryptoResult verify(OEMCrypto_SESSION session,
|
||||
const uint8_t* in_buffer, size_t buffer_length,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
const uint8_t* signature,
|
||||
size_t signature_length) {
|
||||
return OEMCrypto_Generic_Verify(session, in_buffer, buffer_length,
|
||||
algorithm, signature, signature_length);
|
||||
}
|
||||
|
||||
virtual OEMCryptoResult signRSA(const uint8_t* wrapped_rsa_key,
|
||||
size_t wrapped_rsa_key_length,
|
||||
const uint8_t* message,
|
||||
size_t message_length,
|
||||
std::vector<uint8_t>& signature,
|
||||
RSA_Padding_Scheme padding_scheme);
|
||||
|
||||
|
||||
virtual OEMCryptoResult loadDeviceRSAKey(OEMCrypto_SESSION session,
|
||||
const uint8_t* wrapped_rsa_key,
|
||||
size_t wrapped_rsa_key_length) {
|
||||
return OEMCrypto_LoadDeviceRSAKey(session, wrapped_rsa_key,
|
||||
wrapped_rsa_key_length);
|
||||
}
|
||||
|
||||
virtual OEMCryptoResult generateRSASignature(
|
||||
OEMCrypto_SESSION session,
|
||||
const uint8_t* message,
|
||||
size_t message_length,
|
||||
uint8_t* signature,
|
||||
size_t* signature_length,
|
||||
RSA_Padding_Scheme padding_scheme) {
|
||||
return OEMCrypto_GenerateRSASignature(session, message, message_length,
|
||||
signature, signature_length,
|
||||
padding_scheme);
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_EVIL_CONSTRUCTORS(WVGenericCryptoInterface);
|
||||
};
|
||||
|
||||
} // namespace wvdrm
|
||||
|
||||
#endif // WV_GENERIC_CRYPTO_INTERFACE_H_
|
||||
@@ -6,6 +6,8 @@
|
||||
#define LOG_TAG "WVCdm"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "WVDrmPlugin.h"
|
||||
#include "TypeConvert.h"
|
||||
|
||||
@@ -13,7 +15,6 @@
|
||||
#include "mapErrors-inl.h"
|
||||
#include "media/stagefright/MediaErrors.h"
|
||||
#include "openssl/sha.h"
|
||||
#include "utils/List.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
|
||||
namespace {
|
||||
@@ -42,8 +43,6 @@ using ::android::hardware::drm::V1_0::widevine::toStatus;
|
||||
using ::android::hardware::drm::V1_0::widevine::toVector;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
using android::List;
|
||||
|
||||
using wvcdm::kDefaultCdmIdentifier;
|
||||
using wvcdm::CdmAppParameterMap;
|
||||
using wvcdm::CdmCertificateType;
|
||||
@@ -65,10 +64,9 @@ using wvcdm::SecurityLevel;
|
||||
|
||||
namespace {
|
||||
|
||||
Vector<uint8_t> StrToVector(const std::string& str) {
|
||||
Vector<uint8_t> vector;
|
||||
vector.appendArray(reinterpret_cast<const uint8_t*>(str.data()), str.size());
|
||||
return vector;
|
||||
std::vector<uint8_t> StrToVector(const std::string& str) {
|
||||
std::vector<uint8_t> vec(str.begin(), str.end());
|
||||
return vec;
|
||||
}
|
||||
|
||||
KeyRequestType ConvertFromCdmKeyRequestType(
|
||||
@@ -131,7 +129,7 @@ WVDrmPlugin::~WVDrmPlugin() {
|
||||
|
||||
Return<void> WVDrmPlugin::openSession(openSession_cb _hidl_cb) {
|
||||
status_t status = android::OK;
|
||||
Vector<uint8_t> sessionId;
|
||||
std::vector<uint8_t> sessionId;
|
||||
|
||||
CdmSessionId cdmSessionId;
|
||||
CdmResponseType res =
|
||||
@@ -185,7 +183,7 @@ Return<void> WVDrmPlugin::openSession(openSession_cb _hidl_cb) {
|
||||
|
||||
Return<Status> WVDrmPlugin::closeSession(const hidl_vec<uint8_t>& sessionId) {
|
||||
|
||||
const Vector<uint8_t> sId = toVector(sessionId);
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
mCDM->CloseSession(cdmSessionId);
|
||||
mCryptoSessions.erase(cdmSessionId);
|
||||
@@ -202,9 +200,9 @@ Return<void> WVDrmPlugin::getKeyRequest(
|
||||
|
||||
KeyRequestType requestType = KeyRequestType::UNKNOWN;
|
||||
status_t status = android::OK;
|
||||
String8 defaultUrl;
|
||||
Vector<uint8_t> request;
|
||||
const Vector<uint8_t> scopeId = toVector(scope);
|
||||
std::string defaultUrl;
|
||||
std::vector<uint8_t> request;
|
||||
const std::vector<uint8_t> scopeId = toVector(scope);
|
||||
|
||||
CdmLicenseType cdmLicenseType;
|
||||
CdmSessionId cdmSessionId;
|
||||
@@ -220,7 +218,7 @@ Return<void> WVDrmPlugin::getKeyRequest(
|
||||
cdmKeySetId.assign(scopeId.begin(), scopeId.end());
|
||||
} else {
|
||||
_hidl_cb(Status::BAD_VALUE, toHidlVec(request), KeyRequestType::UNKNOWN,
|
||||
defaultUrl.string());
|
||||
defaultUrl.c_str());
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -266,11 +264,11 @@ Return<void> WVDrmPlugin::getKeyRequest(
|
||||
|
||||
CdmAppParameterMap cdmParameters;
|
||||
for (size_t i = 0; i < optionalParameters.size(); ++i) {
|
||||
const String8& key = String8(optionalParameters[i].key);
|
||||
const String8& value = String8(optionalParameters[i].value);
|
||||
const std::string& key(optionalParameters[i].key);
|
||||
const std::string& value(optionalParameters[i].value);
|
||||
|
||||
std::string cdmKey(key.string(), key.size());
|
||||
std::string cdmValue(value.string(), value.size());
|
||||
std::string cdmKey(key.c_str(), key.size());
|
||||
std::string cdmValue(value.c_str(), value.size());
|
||||
|
||||
cdmParameters[cdmKey] = cdmValue;
|
||||
}
|
||||
@@ -285,7 +283,7 @@ Return<void> WVDrmPlugin::getKeyRequest(
|
||||
|
||||
if (isCdmResponseTypeSuccess(res)) {
|
||||
defaultUrl.clear();
|
||||
defaultUrl.setTo(keyRequest.url.data(), keyRequest.url.size());
|
||||
defaultUrl.assign(keyRequest.url.data(), keyRequest.url.size());
|
||||
|
||||
request = StrToVector(keyRequest.message);
|
||||
}
|
||||
@@ -298,7 +296,7 @@ Return<void> WVDrmPlugin::getKeyRequest(
|
||||
status = mapAndNotifyOfCdmResponseType(scopeId, res);
|
||||
}
|
||||
_hidl_cb(toStatus(status), toHidlVec(request), requestType,
|
||||
defaultUrl.string());
|
||||
defaultUrl.c_str());
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -307,19 +305,19 @@ Return<void> WVDrmPlugin::provideKeyResponse(
|
||||
const hidl_vec<uint8_t>& response,
|
||||
provideKeyResponse_cb _hidl_cb) {
|
||||
|
||||
const Vector<uint8_t> resp = toVector(response);
|
||||
const Vector<uint8_t> scopeId = toVector(scope);
|
||||
const std::vector<uint8_t> resp = toVector(response);
|
||||
const std::vector<uint8_t> scopeId = toVector(scope);
|
||||
|
||||
CdmKeySetId cdmKeySetId;
|
||||
CdmSessionId cdmSessionId;
|
||||
CdmKeyResponse cdmResponse(resp.begin(), resp.end());
|
||||
|
||||
bool isRequest = (memcmp(scopeId.array(), wvcdm::SESSION_ID_PREFIX,
|
||||
bool isRequest = (memcmp(scopeId.data(), wvcdm::SESSION_ID_PREFIX,
|
||||
sizeof(wvcdm::SESSION_ID_PREFIX) - 1) == 0);
|
||||
bool isRelease = (memcmp(scopeId.array(), wvcdm::KEY_SET_ID_PREFIX,
|
||||
bool isRelease = (memcmp(scopeId.data(), wvcdm::KEY_SET_ID_PREFIX,
|
||||
sizeof(wvcdm::KEY_SET_ID_PREFIX) - 1) == 0);
|
||||
|
||||
Vector<uint8_t> keySetId;
|
||||
std::vector<uint8_t> keySetId;
|
||||
|
||||
if (isRequest) {
|
||||
cdmSessionId.assign(scopeId.begin(), scopeId.end());
|
||||
@@ -356,7 +354,7 @@ Return<void> WVDrmPlugin::provideKeyResponse(
|
||||
|
||||
Return<Status> WVDrmPlugin::removeKeys(const hidl_vec<uint8_t>& sessionId) {
|
||||
|
||||
const Vector<uint8_t> sId = toVector(sessionId);
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
|
||||
CdmResponseType res = mCDM->RemoveKeys(cdmSessionId);
|
||||
@@ -367,8 +365,8 @@ Return<Status> WVDrmPlugin::removeKeys(const hidl_vec<uint8_t>& sessionId) {
|
||||
Return<Status> WVDrmPlugin::restoreKeys(const hidl_vec<uint8_t>& sessionId,
|
||||
const hidl_vec<uint8_t>& keySetId) {
|
||||
|
||||
const Vector<uint8_t> kId = toVector(keySetId);
|
||||
const Vector<uint8_t> sId = toVector(sessionId);
|
||||
const std::vector<uint8_t> kId = toVector(keySetId);
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
CdmKeySetId cdmKeySetId(kId.begin(), kId.end());
|
||||
|
||||
@@ -380,13 +378,13 @@ Return<Status> WVDrmPlugin::restoreKeys(const hidl_vec<uint8_t>& sessionId,
|
||||
Return<void> WVDrmPlugin::queryKeyStatus(const hidl_vec<uint8_t>& sessionId,
|
||||
queryKeyStatus_cb _hidl_cb) {
|
||||
|
||||
const Vector<uint8_t> sId = toVector(sessionId);
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
CdmQueryMap cdmLicenseInfo;
|
||||
|
||||
CdmResponseType res = mCDM->QueryKeyStatus(cdmSessionId, &cdmLicenseInfo);
|
||||
|
||||
Vector<KeyValue> infoMapVec;
|
||||
std::vector<KeyValue> infoMapVec;
|
||||
if (isCdmResponseTypeSuccess(res)) {
|
||||
infoMapVec.clear();
|
||||
|
||||
@@ -396,8 +394,8 @@ Return<Status> WVDrmPlugin::restoreKeys(const hidl_vec<uint8_t>& sessionId,
|
||||
++iter) {
|
||||
const std::string& cdmKey = iter->first;
|
||||
const std::string& cdmValue = iter->second;
|
||||
keyValuePair.key = String8(cdmKey.data(), cdmKey.size());
|
||||
keyValuePair.value = String8(cdmValue.data(), cdmValue.size());
|
||||
keyValuePair.key = std::string(cdmKey.data(), cdmKey.size());
|
||||
keyValuePair.value = std::string(cdmValue.data(), cdmValue.size());
|
||||
infoMapVec.push_back(keyValuePair);
|
||||
}
|
||||
}
|
||||
@@ -424,12 +422,12 @@ Return<Status> WVDrmPlugin::restoreKeys(const hidl_vec<uint8_t>& sessionId,
|
||||
CdmResponseType res = mCDM->GetProvisioningRequest(
|
||||
cdmCertType, cdmCertAuthority, mCdmIdentifierBuilder.get_identifier(),
|
||||
&cdmProvisionRequest, &cdmDefaultUrl);
|
||||
String8 defaultUrl;
|
||||
Vector<uint8_t> request;
|
||||
std::string defaultUrl;
|
||||
std::vector<uint8_t> request;
|
||||
if (isCdmResponseTypeSuccess(res)) {
|
||||
request = StrToVector(cdmProvisionRequest);
|
||||
defaultUrl.clear();
|
||||
defaultUrl.setTo(cdmDefaultUrl.data(), cdmDefaultUrl.size());
|
||||
defaultUrl.assign(cdmDefaultUrl.data(), cdmDefaultUrl.size());
|
||||
}
|
||||
|
||||
_hidl_cb(toStatus(mapCdmResponseType(res)), toHidlVec(request),
|
||||
@@ -441,9 +439,9 @@ Return<void> WVDrmPlugin::provideProvisionResponse(
|
||||
const hidl_vec<uint8_t>& response,
|
||||
provideProvisionResponse_cb _hidl_cb) {
|
||||
|
||||
const Vector<uint8_t> resp = toVector(response);
|
||||
Vector<uint8_t> certificate;
|
||||
Vector<uint8_t> wrappedKey;
|
||||
const std::vector<uint8_t> resp = toVector(response);
|
||||
std::vector<uint8_t> certificate;
|
||||
std::vector<uint8_t> wrappedKey;
|
||||
|
||||
CdmProvisioningResponse cdmResponse(resp.begin(), resp.end());
|
||||
if (cdmResponse == kSpecialUnprovisionResponse) {
|
||||
@@ -481,7 +479,7 @@ Return<void> WVDrmPlugin::getSecureStop(
|
||||
const hidl_vec<uint8_t>& secureStopId,
|
||||
getSecureStop_cb _hidl_cb) {
|
||||
|
||||
const Vector<uint8_t> id = toVector(secureStopId);
|
||||
const std::vector<uint8_t> id = toVector(secureStopId);
|
||||
CdmUsageInfo cdmUsageInfo;
|
||||
CdmSecureStopId cdmSsId(id.begin(), id.end());
|
||||
CdmResponseType res = mCDM->GetUsageInfo(
|
||||
@@ -489,14 +487,12 @@ Return<void> WVDrmPlugin::getSecureStop(
|
||||
|
||||
SecureStop secureStop;
|
||||
if (isCdmResponseTypeSuccess(res)) {
|
||||
|
||||
Vector<uint8_t> cdmStopVec;
|
||||
std::vector<uint8_t> cdmStopVec;
|
||||
for (CdmUsageInfo::const_iterator iter = cdmUsageInfo.begin();
|
||||
iter != cdmUsageInfo.end();
|
||||
++iter) {
|
||||
const std::string& cdmStop = *iter;
|
||||
cdmStopVec.appendArray(reinterpret_cast<const uint8_t*>(cdmStop.data()),
|
||||
cdmStop.size());
|
||||
cdmStopVec = StrToVector(cdmStop);
|
||||
}
|
||||
secureStop.opaqueData = toHidlVec(cdmStopVec);
|
||||
}
|
||||
@@ -507,7 +503,7 @@ Return<void> WVDrmPlugin::getSecureStop(
|
||||
|
||||
Return<void> WVDrmPlugin::getSecureStops(getSecureStops_cb _hidl_cb) {
|
||||
|
||||
List<Vector<uint8_t> > secureStops;
|
||||
std::list<std::vector<uint8_t> > secureStops;
|
||||
|
||||
CdmUsageInfo cdmUsageInfo;
|
||||
CdmResponseType res =
|
||||
@@ -523,8 +519,8 @@ Return<void> WVDrmPlugin::getSecureStops(getSecureStops_cb _hidl_cb) {
|
||||
}
|
||||
}
|
||||
|
||||
Vector<SecureStop> secureStopsVec;
|
||||
List<Vector<uint8_t> >::iterator iter = secureStops.begin();
|
||||
std::vector<SecureStop> secureStopsVec;
|
||||
std::list<std::vector<uint8_t> >::iterator iter = secureStops.begin();
|
||||
while (iter != secureStops.end()) {
|
||||
SecureStop secureStop;
|
||||
secureStop.opaqueData = toHidlVec(*iter++);
|
||||
@@ -544,7 +540,7 @@ Return<Status> WVDrmPlugin::releaseAllSecureStops() {
|
||||
Return<Status> WVDrmPlugin::releaseSecureStop(
|
||||
const hidl_vec<uint8_t>& secureStopId) {
|
||||
|
||||
const Vector<uint8_t> ssRelease = toVector(secureStopId);
|
||||
const std::vector<uint8_t> ssRelease = toVector(secureStopId);
|
||||
CdmUsageInfoReleaseMessage cdmMessage(ssRelease.begin(), ssRelease.end());
|
||||
CdmResponseType res = mCDM->ReleaseUsageInfo(cdmMessage);
|
||||
return toStatus(mapCdmResponseType(res));
|
||||
@@ -553,8 +549,8 @@ Return<Status> WVDrmPlugin::releaseSecureStop(
|
||||
Return<void> WVDrmPlugin::getPropertyString(const hidl_string& propertyName,
|
||||
getPropertyString_cb _hidl_cb) {
|
||||
status_t status = android::OK;
|
||||
String8 name(propertyName);
|
||||
String8 value;
|
||||
std::string name(propertyName.c_str());
|
||||
std::string value;
|
||||
|
||||
if (name == "vendor") {
|
||||
value = "Google";
|
||||
@@ -603,11 +599,11 @@ Return<void> WVDrmPlugin::getPropertyString(const hidl_string& propertyName,
|
||||
} else if (name == "origin") {
|
||||
value = mCdmIdentifierBuilder.origin().c_str();
|
||||
} else {
|
||||
ALOGE("App requested unknown string property %s", name.string());
|
||||
ALOGE("App requested unknown string property %s", name.c_str());
|
||||
status = android::ERROR_DRM_CANNOT_HANDLE;
|
||||
}
|
||||
|
||||
_hidl_cb(toStatus(status), value.string());
|
||||
_hidl_cb(toStatus(status), value.c_str());
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -616,8 +612,8 @@ Return<void> WVDrmPlugin::getPropertyByteArray(
|
||||
getPropertyByteArray_cb _hidl_cb) {
|
||||
|
||||
status_t status = android::OK;
|
||||
String8 name(propertyName);
|
||||
Vector<uint8_t> value;
|
||||
std::string name(propertyName.c_str());
|
||||
std::vector<uint8_t> value;
|
||||
|
||||
if (name == "deviceUniqueId") {
|
||||
value = StrToVector(mCdmIdentifierBuilder.get_device_unique_id());
|
||||
@@ -626,7 +622,7 @@ Return<void> WVDrmPlugin::getPropertyByteArray(
|
||||
} else if (name == "serviceCertificate") {
|
||||
value = StrToVector(mPropertySet.service_certificate());
|
||||
} else {
|
||||
ALOGE("App requested unknown byte array property %s", name.string());
|
||||
ALOGE("App requested unknown byte array property %s", name.c_str());
|
||||
status = android::ERROR_DRM_CANNOT_HANDLE;
|
||||
}
|
||||
|
||||
@@ -636,8 +632,8 @@ Return<void> WVDrmPlugin::getPropertyByteArray(
|
||||
|
||||
Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
const hidl_string& value) {
|
||||
String8 name(propertyName);
|
||||
String8 _value(value);
|
||||
std::string name(propertyName.c_str());
|
||||
std::string _value(value.c_str());
|
||||
|
||||
if (name == "securityLevel") {
|
||||
if (mCryptoSessions.size() == 0) {
|
||||
@@ -661,7 +657,7 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
} else if (_value == kResetSecurityLevel) {
|
||||
mPropertySet.set_security_level(kResetSecurityLevel);
|
||||
} else {
|
||||
ALOGE("App requested invalid security level %s", _value.string());
|
||||
ALOGE("App requested invalid security level %s", _value.c_str());
|
||||
return Status::BAD_VALUE;
|
||||
}
|
||||
} else {
|
||||
@@ -674,7 +670,7 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
} else if (_value == kDisable) {
|
||||
mPropertySet.set_use_privacy_mode(false);
|
||||
} else {
|
||||
ALOGE("App requested unknown privacy mode %s", _value.string());
|
||||
ALOGE("App requested unknown privacy mode %s", _value.c_str());
|
||||
return Status::BAD_VALUE;
|
||||
}
|
||||
} else if (name == "sessionSharing") {
|
||||
@@ -684,7 +680,7 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
} else if (_value == kDisable) {
|
||||
mPropertySet.set_is_session_sharing_enabled(false);
|
||||
} else {
|
||||
ALOGE("App requested unknown sharing type %s", _value.string());
|
||||
ALOGE("App requested unknown sharing type %s", _value.c_str());
|
||||
return Status::BAD_VALUE;
|
||||
}
|
||||
} else {
|
||||
@@ -693,7 +689,7 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
}
|
||||
} else if (name == "appId") {
|
||||
if (mCryptoSessions.size() == 0) {
|
||||
mPropertySet.set_app_id(_value.string());
|
||||
mPropertySet.set_app_id(_value.c_str());
|
||||
} else {
|
||||
ALOGE("App tried to set the application id while sessions are opened.");
|
||||
return toStatus(kErrorSessionIsOpen);
|
||||
@@ -703,12 +699,12 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
ALOGE("App tried to set the origin while sessions are opened.");
|
||||
return toStatus(kErrorSessionIsOpen);
|
||||
} else {
|
||||
if (!mCdmIdentifierBuilder.set_origin(_value.string())) {
|
||||
if (!mCdmIdentifierBuilder.set_origin(_value.c_str())) {
|
||||
return Status::BAD_VALUE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ALOGE("App set unknown string property %s", name.string());
|
||||
ALOGE("App set unknown string property %s", name.c_str());
|
||||
return Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
}
|
||||
|
||||
@@ -718,18 +714,18 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
Return<Status> WVDrmPlugin::setPropertyByteArray(
|
||||
const hidl_string& propertyName, const hidl_vec<uint8_t>& value) {
|
||||
|
||||
String8 name(propertyName);
|
||||
Vector<uint8_t> _value = toVector(value);
|
||||
std::string name(propertyName.c_str());
|
||||
std::vector<uint8_t> _value = toVector(value);
|
||||
|
||||
if (name == "serviceCertificate") {
|
||||
std::string cert(_value.begin(), _value.end());
|
||||
if (_value.isEmpty() || mCDM->IsValidServiceCertificate(cert)) {
|
||||
if (_value.empty() || mCDM->IsValidServiceCertificate(cert)) {
|
||||
mPropertySet.set_service_certificate(cert);
|
||||
} else {
|
||||
return Status::BAD_VALUE;
|
||||
}
|
||||
} else {
|
||||
ALOGE("App set unknown byte array property %s", name.string());
|
||||
ALOGE("App set unknown byte array property %s", name.c_str());
|
||||
return Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
}
|
||||
|
||||
@@ -739,8 +735,8 @@ Return<Status> WVDrmPlugin::setPropertyByteArray(
|
||||
Return<Status> WVDrmPlugin::setCipherAlgorithm(
|
||||
const hidl_vec<uint8_t>& sessionId, const hidl_string& algorithm) {
|
||||
|
||||
String8 algo(algorithm);
|
||||
Vector<uint8_t> sId = toVector(sessionId);
|
||||
std::string algo(algorithm.c_str());
|
||||
std::vector<uint8_t> sId = toVector(sessionId);
|
||||
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
if (!mCryptoSessions.count(cdmSessionId)) {
|
||||
@@ -761,8 +757,8 @@ Return<Status> WVDrmPlugin::setCipherAlgorithm(
|
||||
Return<Status> WVDrmPlugin::setMacAlgorithm(
|
||||
const hidl_vec<uint8_t>& sessionId, const hidl_string& algorithm) {
|
||||
|
||||
String8 algo(algorithm);
|
||||
Vector<uint8_t> sId = toVector(sessionId);
|
||||
std::string algo(algorithm.c_str());
|
||||
std::vector<uint8_t> sId = toVector(sessionId);
|
||||
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
if (!mCryptoSessions.count(cdmSessionId)) {
|
||||
@@ -787,8 +783,8 @@ Return<void> WVDrmPlugin::encrypt(
|
||||
const hidl_vec<uint8_t>& iv,
|
||||
encrypt_cb _hidl_cb) {
|
||||
|
||||
const Vector<uint8_t> sId = toVector(sessionId);
|
||||
Vector<uint8_t> output;
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
std::vector<uint8_t> output;
|
||||
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
if (!mCryptoSessions.count(cdmSessionId)) {
|
||||
@@ -803,9 +799,9 @@ Return<void> WVDrmPlugin::encrypt(
|
||||
return Void();
|
||||
}
|
||||
|
||||
const Vector<uint8_t> _keyId = toVector(keyId);
|
||||
const std::vector<uint8_t> _keyId = toVector(keyId);
|
||||
OEMCryptoResult res = mCrypto->selectKey(cryptoSession.oecSessionId(),
|
||||
_keyId.array(), _keyId.size());
|
||||
_keyId.data(), _keyId.size());
|
||||
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
||||
@@ -814,13 +810,13 @@ Return<void> WVDrmPlugin::encrypt(
|
||||
return Void();
|
||||
}
|
||||
|
||||
const Vector<uint8_t> _input = toVector(input);
|
||||
const Vector<uint8_t> _iv = toVector(iv);
|
||||
const std::vector<uint8_t> _input = toVector(input);
|
||||
const std::vector<uint8_t> _iv = toVector(iv);
|
||||
output.resize(_input.size());
|
||||
|
||||
res = mCrypto->encrypt(cryptoSession.oecSessionId(), _input.array(),
|
||||
_input.size(), _iv.array(),
|
||||
cryptoSession.cipherAlgorithm(), output.editArray());
|
||||
res = mCrypto->encrypt(cryptoSession.oecSessionId(), _input.data(),
|
||||
_input.size(), _iv.data(),
|
||||
cryptoSession.cipherAlgorithm(), output.data());
|
||||
|
||||
if (res == OEMCrypto_SUCCESS) {
|
||||
_hidl_cb(Status::OK, toHidlVec(output));
|
||||
@@ -839,8 +835,8 @@ Return<void> WVDrmPlugin::decrypt(
|
||||
const hidl_vec<uint8_t>& iv,
|
||||
decrypt_cb _hidl_cb) {
|
||||
|
||||
const Vector<uint8_t> sId = toVector(sessionId);
|
||||
Vector<uint8_t> output;
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
std::vector<uint8_t> output;
|
||||
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
if (!mCryptoSessions.count(cdmSessionId)) {
|
||||
@@ -855,9 +851,9 @@ Return<void> WVDrmPlugin::decrypt(
|
||||
return Void();
|
||||
}
|
||||
|
||||
const Vector<uint8_t> _keyId = toVector(keyId);
|
||||
const std::vector<uint8_t> _keyId = toVector(keyId);
|
||||
OEMCryptoResult res = mCrypto->selectKey(cryptoSession.oecSessionId(),
|
||||
_keyId.array(), _keyId.size());
|
||||
_keyId.data(), _keyId.size());
|
||||
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
||||
@@ -866,13 +862,13 @@ Return<void> WVDrmPlugin::decrypt(
|
||||
return Void();
|
||||
}
|
||||
|
||||
const Vector<uint8_t> _input = toVector(input);
|
||||
const Vector<uint8_t> _iv = toVector(iv);
|
||||
const std::vector<uint8_t> _input = toVector(input);
|
||||
const std::vector<uint8_t> _iv = toVector(iv);
|
||||
output.resize(_input.size());
|
||||
|
||||
res = mCrypto->decrypt(cryptoSession.oecSessionId(), _input.array(),
|
||||
_input.size(), _iv.array(),
|
||||
cryptoSession.cipherAlgorithm(), output.editArray());
|
||||
res = mCrypto->decrypt(cryptoSession.oecSessionId(), _input.data(),
|
||||
_input.size(), _iv.data(),
|
||||
cryptoSession.cipherAlgorithm(), output.data());
|
||||
|
||||
if (res == OEMCrypto_SUCCESS) {
|
||||
_hidl_cb(Status::OK, toHidlVec(output));
|
||||
@@ -890,8 +886,8 @@ Return<void> WVDrmPlugin::sign(
|
||||
const hidl_vec<uint8_t>& message,
|
||||
sign_cb _hidl_cb) {
|
||||
|
||||
const Vector<uint8_t> sId = toVector(sessionId);
|
||||
Vector<uint8_t> signature;
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
std::vector<uint8_t> signature;
|
||||
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
if (!mCryptoSessions.count(cdmSessionId)) {
|
||||
@@ -906,9 +902,9 @@ Return<void> WVDrmPlugin::sign(
|
||||
return Void();
|
||||
}
|
||||
|
||||
const Vector<uint8_t> _keyId = toVector(keyId);
|
||||
const std::vector<uint8_t> _keyId = toVector(keyId);
|
||||
OEMCryptoResult res = mCrypto->selectKey(cryptoSession.oecSessionId(),
|
||||
_keyId.array(), _keyId.size());
|
||||
_keyId.data(), _keyId.size());
|
||||
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
||||
@@ -919,8 +915,8 @@ Return<void> WVDrmPlugin::sign(
|
||||
|
||||
size_t signatureSize = 0;
|
||||
|
||||
const Vector<uint8_t> msg = toVector(message);
|
||||
res = mCrypto->sign(cryptoSession.oecSessionId(), msg.array(),
|
||||
const std::vector<uint8_t> msg = toVector(message);
|
||||
res = mCrypto->sign(cryptoSession.oecSessionId(), msg.data(),
|
||||
msg.size(), cryptoSession.macAlgorithm(),
|
||||
NULL, &signatureSize);
|
||||
|
||||
@@ -938,9 +934,9 @@ Return<void> WVDrmPlugin::sign(
|
||||
|
||||
signature.resize(signatureSize);
|
||||
|
||||
res = mCrypto->sign(cryptoSession.oecSessionId(), msg.array(),
|
||||
res = mCrypto->sign(cryptoSession.oecSessionId(), msg.data(),
|
||||
msg.size(), cryptoSession.macAlgorithm(),
|
||||
signature.editArray(), &signatureSize);
|
||||
signature.data(), &signatureSize);
|
||||
|
||||
if (res == OEMCrypto_SUCCESS) {
|
||||
_hidl_cb(Status::OK, toHidlVec(signature));
|
||||
@@ -960,7 +956,7 @@ Return<void> WVDrmPlugin::verify(
|
||||
verify_cb _hidl_cb) {
|
||||
|
||||
bool match = false;
|
||||
const Vector<uint8_t> sId = toVector(sessionId);
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
if (!mCryptoSessions.count(cdmSessionId)) {
|
||||
@@ -975,9 +971,9 @@ Return<void> WVDrmPlugin::verify(
|
||||
return Void();
|
||||
}
|
||||
|
||||
const Vector<uint8_t> _keyId = toVector(keyId);
|
||||
const std::vector<uint8_t> _keyId = toVector(keyId);
|
||||
OEMCryptoResult res = mCrypto->selectKey(cryptoSession.oecSessionId(),
|
||||
_keyId.array(), _keyId.size());
|
||||
_keyId.data(), _keyId.size());
|
||||
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
||||
@@ -985,11 +981,11 @@ Return<void> WVDrmPlugin::verify(
|
||||
return Void();
|
||||
}
|
||||
|
||||
const Vector<uint8_t> _message = toVector(message);
|
||||
const Vector<uint8_t> _signature = toVector(signature);
|
||||
res = mCrypto->verify(cryptoSession.oecSessionId(), _message.array(),
|
||||
const std::vector<uint8_t> _message = toVector(message);
|
||||
const std::vector<uint8_t> _signature = toVector(signature);
|
||||
res = mCrypto->verify(cryptoSession.oecSessionId(), _message.data(),
|
||||
_message.size(), cryptoSession.macAlgorithm(),
|
||||
_signature.array(), _signature.size());
|
||||
_signature.data(), _signature.size());
|
||||
|
||||
if (res == OEMCrypto_SUCCESS) {
|
||||
match = true;
|
||||
@@ -1011,8 +1007,8 @@ Return<void> WVDrmPlugin::signRSA(
|
||||
const hidl_vec<uint8_t>& wrappedKey,
|
||||
signRSA_cb _hidl_cb) {
|
||||
|
||||
const String8 algo(algorithm);
|
||||
Vector<uint8_t> signature;
|
||||
const std::string algo(algorithm.c_str());
|
||||
std::vector<uint8_t> signature;
|
||||
|
||||
RSA_Padding_Scheme padding_scheme;
|
||||
if (algo == "RSASSA-PSS-SHA1") {
|
||||
@@ -1020,16 +1016,16 @@ Return<void> WVDrmPlugin::signRSA(
|
||||
} else if (algo == "PKCS1-BlockType1") {
|
||||
padding_scheme = kSign_PKCS1_Block1;
|
||||
} else {
|
||||
ALOGE("Unknown RSA Algorithm %s", algo.string());
|
||||
ALOGE("Unknown RSA Algorithm %s", algo.c_str());
|
||||
_hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, toHidlVec(signature));
|
||||
return Void();
|
||||
}
|
||||
|
||||
const Vector<uint8_t> msg = toVector(message);
|
||||
const Vector<uint8_t> _wrappedKey = toVector(wrappedKey);
|
||||
OEMCryptoResult res = mCrypto->signRSA(_wrappedKey.array(),
|
||||
const std::vector<uint8_t> msg = toVector(message);
|
||||
const std::vector<uint8_t> _wrappedKey = toVector(wrappedKey);
|
||||
OEMCryptoResult res = mCrypto->signRSA(_wrappedKey.data(),
|
||||
_wrappedKey.size(),
|
||||
msg.array(), msg.size(),
|
||||
msg.data(), msg.size(),
|
||||
signature,
|
||||
padding_scheme);
|
||||
|
||||
@@ -1082,7 +1078,7 @@ Return<void> WVDrmPlugin::sendKeysChange(
|
||||
}
|
||||
|
||||
void WVDrmPlugin::OnSessionRenewalNeeded(const CdmSessionId& cdmSessionId) {
|
||||
const Vector<uint8_t> sessionId = StrToVector(cdmSessionId);
|
||||
const std::vector<uint8_t> sessionId = StrToVector(cdmSessionId);
|
||||
const hidl_vec<uint8_t> data; // data is ignored
|
||||
const hidl_vec<uint8_t> sid = toHidlVec(sessionId);
|
||||
sendEvent(EventType::KEY_NEEDED, sid, data);
|
||||
@@ -1092,7 +1088,7 @@ void WVDrmPlugin::OnSessionKeysChange(const CdmSessionId& cdmSessionId,
|
||||
const CdmKeyStatusMap& cdmKeysStatus,
|
||||
bool hasNewUsableKey) {
|
||||
bool expired = false;
|
||||
Vector<KeyStatus> keyStatusList;
|
||||
std::vector<KeyStatus> keyStatusList;
|
||||
for (CdmKeyStatusMap::const_iterator it = cdmKeysStatus.begin();
|
||||
it != cdmKeysStatus.end(); ++it) {
|
||||
const KeyId& keyId = it->first;
|
||||
@@ -1105,7 +1101,7 @@ void WVDrmPlugin::OnSessionKeysChange(const CdmSessionId& cdmSessionId,
|
||||
keyStatusList.push_back(keyStatus);
|
||||
}
|
||||
|
||||
const Vector<uint8_t> sessionId = StrToVector(cdmSessionId);
|
||||
const std::vector<uint8_t> sessionId = StrToVector(cdmSessionId);
|
||||
const hidl_vec<uint8_t> data; // data is ignored
|
||||
const hidl_vec<uint8_t> sid = toHidlVec(sessionId);
|
||||
sendKeysChange(sid, toHidlVec(keyStatusList), hasNewUsableKey);
|
||||
@@ -1117,7 +1113,7 @@ void WVDrmPlugin::OnSessionKeysChange(const CdmSessionId& cdmSessionId,
|
||||
|
||||
void WVDrmPlugin::OnExpirationUpdate(const CdmSessionId& cdmSessionId,
|
||||
int64_t newExpiryTimeSeconds) {
|
||||
const Vector<uint8_t> sessionId = StrToVector(cdmSessionId);
|
||||
const std::vector<uint8_t> sessionId = StrToVector(cdmSessionId);
|
||||
int64_t newExpiryTimeMilliseconds =
|
||||
newExpiryTimeSeconds == wvcdm::NEVER_EXPIRES
|
||||
? newExpiryTimeSeconds : newExpiryTimeSeconds * 1000;
|
||||
@@ -1148,16 +1144,7 @@ status_t WVDrmPlugin::queryProperty(SecurityLevel securityLevel,
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::queryProperty(const std::string& property,
|
||||
String8& string8_value) const {
|
||||
std::string string_value;
|
||||
status_t status = queryProperty(property, string_value);
|
||||
if (status != android::OK) return status;
|
||||
string8_value = string_value.c_str();
|
||||
return android::OK;
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::queryProperty(const std::string& property,
|
||||
Vector<uint8_t>& vector_value) const {
|
||||
std::vector<uint8_t>& vector_value) const {
|
||||
std::string string_value;
|
||||
status_t status = queryProperty(property, string_value);
|
||||
if (status != android::OK) return status;
|
||||
@@ -1166,7 +1153,7 @@ status_t WVDrmPlugin::queryProperty(const std::string& property,
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::mapAndNotifyOfCdmResponseType(
|
||||
const Vector<uint8_t>& sessionId,
|
||||
const std::vector<uint8_t>& sessionId,
|
||||
CdmResponseType res) {
|
||||
|
||||
const hidl_vec<uint8_t> data; // data is ignored
|
||||
@@ -1180,7 +1167,7 @@ status_t WVDrmPlugin::mapAndNotifyOfCdmResponseType(
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::mapAndNotifyOfOEMCryptoResult(
|
||||
const Vector<uint8_t>& sessionId,
|
||||
const std::vector<uint8_t>& sessionId,
|
||||
OEMCryptoResult res) {
|
||||
|
||||
const hidl_vec<uint8_t> data; // data is ignored
|
||||
@@ -1218,8 +1205,8 @@ status_t WVDrmPlugin::mapOEMCryptoResult(OEMCryptoResult res) {
|
||||
}
|
||||
}
|
||||
|
||||
bool WVDrmPlugin::initDataResemblesPSSH(const Vector<uint8_t>& initData) {
|
||||
const uint8_t* const initDataArray = initData.array();
|
||||
bool WVDrmPlugin::initDataResemblesPSSH(const std::vector<uint8_t>& initData) {
|
||||
const uint8_t* const initDataArray = initData.data();
|
||||
|
||||
// Extract the size field
|
||||
const uint8_t* const sizeField = &initDataArray[0];
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
|
||||
//#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "WVCdm"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "WVGenericCryptoInterface.h"
|
||||
|
||||
#include "wv_cdm_constants.h"
|
||||
|
||||
namespace wvdrm {
|
||||
|
||||
using namespace android;
|
||||
using namespace std;
|
||||
using namespace wvcdm;
|
||||
|
||||
OEMCryptoResult WVGenericCryptoInterface::signRSA(const uint8_t* wrapped_rsa_key,
|
||||
size_t wrapped_rsa_key_length,
|
||||
const uint8_t* message,
|
||||
size_t message_length,
|
||||
std::vector<uint8_t>& signature,
|
||||
RSA_Padding_Scheme padding_scheme) {
|
||||
OEMCrypto_SESSION session;
|
||||
OEMCryptoResult sts = OEMCrypto_OpenSession(&session);
|
||||
if (sts != OEMCrypto_SUCCESS) return sts;
|
||||
sts = OEMCrypto_LoadDeviceRSAKey(session, wrapped_rsa_key,
|
||||
wrapped_rsa_key_length);
|
||||
if (sts == OEMCrypto_SUCCESS) {
|
||||
size_t signatureSize = 0;
|
||||
sts = OEMCrypto_GenerateRSASignature(session, message, message_length,
|
||||
NULL, &signatureSize,
|
||||
padding_scheme);
|
||||
if (sts == OEMCrypto_SUCCESS) {
|
||||
// Should be short buffer.
|
||||
sts = OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||
} else if (sts == OEMCrypto_ERROR_SHORT_BUFFER) {
|
||||
signature.resize(signatureSize);
|
||||
sts = OEMCrypto_GenerateRSASignature(session, message, message_length,
|
||||
signature.data(), &signatureSize,
|
||||
padding_scheme);
|
||||
}
|
||||
}
|
||||
OEMCrypto_CloseSession(session);
|
||||
return sts;
|
||||
}
|
||||
|
||||
} // namespace wvdrm
|
||||
@@ -34,9 +34,7 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
libcutils \
|
||||
libdl \
|
||||
liblog \
|
||||
libmedia \
|
||||
libprotobuf-cpp-lite \
|
||||
libstagefright_foundation \
|
||||
libutils \
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
@@ -102,9 +100,7 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
libhidlbase \
|
||||
libhidlmemory \
|
||||
liblog \
|
||||
libmedia \
|
||||
libprotobuf-cpp-lite \
|
||||
libstagefright_foundation \
|
||||
libutils \
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
|
||||
@@ -3,26 +3,22 @@
|
||||
//
|
||||
//#define LOG_NDEBUG 0
|
||||
#define LOG_TAG "WVDrmPluginTest"
|
||||
#include <utils/KeyedVector.h>
|
||||
#include "utils/List.h"
|
||||
#include <utils/Log.h>
|
||||
#include <utils/String8.h>
|
||||
|
||||
#include <android/hardware/drm/1.0/types.h>
|
||||
#include <android/hardware/drm/1.0/IDrmPlugin.h>
|
||||
#include <android/hardware/drm/1.0/IDrmPluginListener.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "cdm_client_property_set.h"
|
||||
#include "cutils/properties.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "media/stagefright/foundation/ABase.h"
|
||||
#include "media/stagefright/foundation/AString.h"
|
||||
#include "media/stagefright/MediaErrors.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "wv_cdm_types.h"
|
||||
@@ -43,9 +39,6 @@ using ::android::hardware::drm::V1_0::KeyStatusType;
|
||||
using ::android::hardware::drm::V1_0::Status;
|
||||
using ::android::hardware::drm::V1_0::widevine::toHidlVec;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::List;
|
||||
using ::android::KeyedVector;
|
||||
using ::android::String8;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::AllOf;
|
||||
@@ -116,9 +109,9 @@ using wvcdm::SESSION_ID_PREFIX;
|
||||
using wvcdm::WvCdmEventListener;
|
||||
|
||||
namespace {
|
||||
const String8 kEmptyString;
|
||||
const String8 kOrigin("widevine.com");
|
||||
const String8 kAppId("com.unittest.mock.app.id");
|
||||
const std::string kEmptyString;
|
||||
const std::string kOrigin("widevine.com");
|
||||
const std::string kAppId("com.unittest.mock.app.id");
|
||||
const uint8_t* const kUnprovisionResponse =
|
||||
reinterpret_cast<const uint8_t*>("unprovision");
|
||||
const size_t kUnprovisionResponseSize = 11;
|
||||
@@ -245,7 +238,7 @@ class WVDrmPluginTest : public Test {
|
||||
protected:
|
||||
static const uint32_t kSessionIdSize = 16;
|
||||
uint8_t sessionIdRaw[kSessionIdSize];
|
||||
Vector<uint8_t> sessionId;
|
||||
std::vector<uint8_t> sessionId;
|
||||
CdmSessionId cdmSessionId;
|
||||
|
||||
virtual void SetUp() {
|
||||
@@ -255,7 +248,7 @@ class WVDrmPluginTest : public Test {
|
||||
fclose(fp);
|
||||
|
||||
memcpy(sessionIdRaw, SESSION_ID_PREFIX, sizeof(SESSION_ID_PREFIX) - 1);
|
||||
sessionId.appendArray(sessionIdRaw, kSessionIdSize);
|
||||
sessionId.assign(sessionIdRaw, sessionIdRaw + kSessionIdSize);
|
||||
cdmSessionId.assign(sessionId.begin(), sessionId.end());
|
||||
|
||||
// Set default return values for gMock
|
||||
@@ -267,13 +260,14 @@ class WVDrmPluginTest : public Test {
|
||||
|
||||
struct OriginTestVariant {
|
||||
// For a test that does not expect any follow-up queries
|
||||
OriginTestVariant(const std::string& nameValue, const String8& originValue,
|
||||
OriginTestVariant(const std::string& nameValue,
|
||||
const std::string& originValue,
|
||||
const std::string& expectedOriginValue)
|
||||
: name(nameValue), origin(originValue),
|
||||
expectedOrigin(expectedOriginValue) {}
|
||||
|
||||
const std::string name;
|
||||
const String8 origin;
|
||||
const std::string origin;
|
||||
const std::string expectedOrigin;
|
||||
};
|
||||
|
||||
@@ -311,7 +305,7 @@ TEST_F(WVDrmPluginTest, OpensSessions) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
|
||||
EXPECT_THAT(sessionId, ElementsAreArray(sessionIdRaw, kSessionIdSize));
|
||||
@@ -372,12 +366,12 @@ TEST_F(WVDrmPluginTest, DISABLED_GeneratesKeyRequests) {
|
||||
|
||||
memcpy(keySetIdRaw, KEY_SET_ID_PREFIX, sizeof(KEY_SET_ID_PREFIX) - 1);
|
||||
CdmKeySetId cdmKeySetId(reinterpret_cast<char*>(keySetIdRaw), kKeySetIdSize);
|
||||
Vector<uint8_t> keySetId;
|
||||
keySetId.appendArray(keySetIdRaw, kKeySetIdSize);
|
||||
std::vector<uint8_t> keySetId;
|
||||
keySetId.assign(keySetIdRaw, keySetIdRaw + kKeySetIdSize);
|
||||
|
||||
CdmInitData cdmInitData(reinterpret_cast<char*>(initDataRaw), kInitDataSize);
|
||||
Vector<uint8_t> initData;
|
||||
initData.appendArray(initDataRaw, kInitDataSize);
|
||||
std::vector<uint8_t> initData;
|
||||
initData.assign(initDataRaw, initDataRaw + kInitDataSize);
|
||||
|
||||
static const uint8_t psshPrefix[] = {
|
||||
0, 0, 0, 32 + kInitDataSize, // Total size
|
||||
@@ -393,25 +387,29 @@ TEST_F(WVDrmPluginTest, DISABLED_GeneratesKeyRequests) {
|
||||
memcpy(psshBoxRaw, psshPrefix, kPsshPrefixSize);
|
||||
memcpy(psshBoxRaw + kPsshPrefixSize, initDataRaw, kInitDataSize);
|
||||
CdmInitData cdmPsshBox(reinterpret_cast<char*>(psshBoxRaw), kPsshBoxSize);
|
||||
Vector<uint8_t> psshBox;
|
||||
psshBox.appendArray(psshBoxRaw, kPsshBoxSize);
|
||||
std::vector<uint8_t> psshBox;
|
||||
psshBox.assign(psshBoxRaw, psshBoxRaw + kPsshBoxSize);
|
||||
|
||||
CdmKeyMessage cdmRequest(requestRaw, requestRaw + kRequestSize);
|
||||
|
||||
KeyedVector<String8, String8> parameters;
|
||||
std::map<std::string, std::string> parameters;
|
||||
CdmAppParameterMap cdmParameters;
|
||||
parameters.add(String8("paddingScheme"), String8("BUBBLE WRAP"));
|
||||
parameters.insert(
|
||||
std::pair<std::string, std::string>("paddingScheme", "BUBBLE WRAP"));
|
||||
cdmParameters["paddingScheme"] = "BUBBLE WRAP";
|
||||
parameters.add(String8("favorite-particle"), String8("tetraquark"));
|
||||
parameters.insert(
|
||||
std::pair<std::string, std::string>("favorite-particle", "tetraquark"));
|
||||
cdmParameters["favorite-particle"] = "tetraquark";
|
||||
parameters.add(String8("answer"), String8("6 * 9"));
|
||||
parameters.insert(
|
||||
std::pair<std::string, std::string>("answer", "6 * 9"));
|
||||
cdmParameters["answer"] = "6 * 9";
|
||||
|
||||
Vector<KeyValue> optionalParameters;
|
||||
std::vector<KeyValue> optionalParameters;
|
||||
KeyValue keyValue;
|
||||
for (size_t i = 0; i < parameters.size(); ++i) {
|
||||
keyValue.key = parameters.keyAt(i);
|
||||
keyValue.value = parameters.valueAt(i);
|
||||
for (std::map<std::string, std::string>::iterator itr = parameters.begin();
|
||||
itr != parameters.end(); ++itr) {
|
||||
keyValue.key = itr->first;
|
||||
keyValue.value = itr->second;
|
||||
optionalParameters.push_back(keyValue);
|
||||
}
|
||||
|
||||
@@ -421,7 +419,7 @@ TEST_F(WVDrmPluginTest, DISABLED_GeneratesKeyRequests) {
|
||||
|
||||
struct TestSet {
|
||||
const char* mimeType;
|
||||
const Vector<uint8_t>& initDataIn;
|
||||
const std::vector<uint8_t>& initDataIn;
|
||||
const CdmInitData& initDataOut;
|
||||
};
|
||||
|
||||
@@ -490,8 +488,8 @@ TEST_F(WVDrmPluginTest, DISABLED_GeneratesKeyRequests) {
|
||||
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto);
|
||||
for (size_t i = 0; i < testSetCount; ++i)
|
||||
{
|
||||
const String8 mimeType(testSets[i].mimeType);
|
||||
const Vector<uint8_t>& initData = testSets[i].initDataIn;
|
||||
const std::string mimeType(testSets[i].mimeType);
|
||||
const std::vector<uint8_t>& initData = testSets[i].initDataIn;
|
||||
|
||||
plugin.getKeyRequest(
|
||||
toHidlVec(sessionId), toHidlVec(initData),
|
||||
@@ -551,14 +549,14 @@ TEST_F(WVDrmPluginTest, AddsKeys) {
|
||||
fread(keySetIdRaw, sizeof(uint8_t), kKeySetIdSize, fp);
|
||||
fclose(fp);
|
||||
|
||||
Vector<uint8_t> response;
|
||||
response.appendArray(responseRaw, kResponseSize);
|
||||
std::vector<uint8_t> response;
|
||||
response.assign(responseRaw, responseRaw + kResponseSize);
|
||||
|
||||
memcpy(keySetIdRaw, KEY_SET_ID_PREFIX, sizeof(KEY_SET_ID_PREFIX) - 1);
|
||||
CdmKeySetId cdmKeySetId(reinterpret_cast<char *>(keySetIdRaw), kKeySetIdSize);
|
||||
|
||||
Vector<uint8_t> keySetId;
|
||||
Vector<uint8_t> emptyKeySetId;
|
||||
std::vector<uint8_t> keySetId;
|
||||
std::vector<uint8_t> emptyKeySetId;
|
||||
|
||||
EXPECT_CALL(*cdm, AddKey(cdmSessionId,
|
||||
ElementsAreArray(responseRaw, kResponseSize), _))
|
||||
@@ -577,7 +575,7 @@ TEST_F(WVDrmPluginTest, AddsKeys) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
|
||||
std::vector<uint8_t> id(hKeySetId);
|
||||
keySetId.appendArray(id.data(), id.size());
|
||||
keySetId.assign(id.data(), id.data() + id.size());
|
||||
ASSERT_THAT(keySetId, ElementsAreArray(keySetIdRaw, kKeySetIdSize));
|
||||
});
|
||||
|
||||
@@ -639,7 +637,7 @@ TEST_F(WVDrmPluginTest, HandlesPrivacyCertCaseOfAddKey) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
|
||||
@@ -650,9 +648,9 @@ TEST_F(WVDrmPluginTest, HandlesPrivacyCertCaseOfAddKey) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
EXPECT_TRUE(propertySet->use_privacy_mode());
|
||||
|
||||
Vector<uint8_t> response;
|
||||
response.appendArray(responseRaw, kResponseSize);
|
||||
Vector<uint8_t> keySetId;
|
||||
std::vector<uint8_t> response;
|
||||
response.assign(responseRaw, responseRaw + kResponseSize);
|
||||
std::vector<uint8_t> keySetId;
|
||||
|
||||
plugin.provideKeyResponse(
|
||||
toHidlVec(sessionId), toHidlVec(response),
|
||||
@@ -691,8 +689,8 @@ TEST_F(WVDrmPluginTest, RestoresKeys) {
|
||||
fread(keySetIdRaw, sizeof(uint8_t), kKeySetIdSize, fp);
|
||||
fclose(fp);
|
||||
|
||||
Vector<uint8_t> keySetId;
|
||||
keySetId.appendArray(keySetIdRaw, kKeySetIdSize);
|
||||
std::vector<uint8_t> keySetId;
|
||||
keySetId.assign(keySetIdRaw, keySetIdRaw + kKeySetIdSize);
|
||||
|
||||
EXPECT_CALL(*cdm, RestoreKey(cdmSessionId,
|
||||
ElementsAreArray(keySetIdRaw, kKeySetIdSize)))
|
||||
@@ -711,14 +709,17 @@ TEST_F(WVDrmPluginTest, QueriesKeyStatus) {
|
||||
.WillOnce(DoAll(SetArgPointee<2>(kDeviceId),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
KeyedVector<String8, String8> expectedLicenseStatus;
|
||||
std::map<std::string, std::string> expectedLicenseStatus;
|
||||
CdmQueryMap cdmLicenseStatus;
|
||||
|
||||
expectedLicenseStatus.add(String8("areTheKeysAllRight"), String8("yes"));
|
||||
expectedLicenseStatus.insert(
|
||||
std::pair<std::string, std::string>("areTheKeysAllRight", "yes"));
|
||||
cdmLicenseStatus["areTheKeysAllRight"] = "yes";
|
||||
expectedLicenseStatus.add(String8("isGMockAwesome"), String8("ohhhhhhYeah"));
|
||||
expectedLicenseStatus.insert(
|
||||
std::pair<std::string, std::string>("isGMockAwesome", "ohhhhhhYeah"));
|
||||
cdmLicenseStatus["isGMockAwesome"] = "ohhhhhhYeah";
|
||||
expectedLicenseStatus.add(String8("answer"), String8("42"));
|
||||
expectedLicenseStatus.insert(
|
||||
std::pair<std::string, std::string>("answer", "42"));
|
||||
cdmLicenseStatus["answer"] = "42";
|
||||
|
||||
EXPECT_CALL(*cdm, QueryKeyStatus(cdmSessionId, _))
|
||||
@@ -732,11 +733,13 @@ TEST_F(WVDrmPluginTest, QueriesKeyStatus) {
|
||||
ASSERT_EQ(expectedLicenseStatus.size(), hLicenseStatus.size());
|
||||
|
||||
KeyValue keyValuePair;
|
||||
for (size_t i = 0; i < expectedLicenseStatus.size(); ++i) {
|
||||
const String8& key = expectedLicenseStatus.keyAt(i);
|
||||
keyValuePair = hLicenseStatus[i];
|
||||
EXPECT_EQ(expectedLicenseStatus.valueFor(key),
|
||||
String8(keyValuePair.value.c_str()));
|
||||
size_t i = 0;
|
||||
for (std::map<std::string, std::string>::iterator itr =
|
||||
expectedLicenseStatus.begin();
|
||||
itr != expectedLicenseStatus.end(); ++itr) {
|
||||
const std::string& key = itr->first;
|
||||
keyValuePair.value = hLicenseStatus[i++].value;
|
||||
EXPECT_EQ(itr->second.c_str(), std::string(keyValuePair.value.c_str()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -791,8 +794,8 @@ TEST_F(WVDrmPluginTest, HandlesProvisioningResponses) {
|
||||
fread(responseRaw, sizeof(uint8_t), kResponseSize, fp);
|
||||
fclose(fp);
|
||||
|
||||
Vector<uint8_t> response;
|
||||
response.appendArray(responseRaw, kResponseSize);
|
||||
std::vector<uint8_t> response;
|
||||
response.assign(responseRaw, responseRaw + kResponseSize);
|
||||
|
||||
EXPECT_CALL(*cdm, HandleProvisioningResponse(HasOrigin(EMPTY_ORIGIN),
|
||||
ElementsAreArray(responseRaw,
|
||||
@@ -800,8 +803,8 @@ TEST_F(WVDrmPluginTest, HandlesProvisioningResponses) {
|
||||
_, _))
|
||||
.Times(1);
|
||||
|
||||
Vector<uint8_t> cert;
|
||||
Vector<uint8_t> key;
|
||||
std::vector<uint8_t> cert;
|
||||
std::vector<uint8_t> key;
|
||||
|
||||
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto);
|
||||
plugin.provideProvisionResponse(
|
||||
@@ -866,14 +869,15 @@ TEST_F(WVDrmPluginTest, UnprovisionsOrigin) {
|
||||
.WillOnce(DoAll(SetArgPointee<2>(kDeviceId),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
Vector<uint8_t> cert;
|
||||
Vector<uint8_t> key;
|
||||
Vector<uint8_t> specialResponse;
|
||||
specialResponse.appendArray(kUnprovisionResponse, kUnprovisionResponseSize);
|
||||
std::vector<uint8_t> cert;
|
||||
std::vector<uint8_t> key;
|
||||
std::vector<uint8_t> specialResponse;
|
||||
specialResponse.assign(
|
||||
kUnprovisionResponse, kUnprovisionResponse + kUnprovisionResponseSize);
|
||||
|
||||
EXPECT_CALL(*cdm, Unprovision(kSecurityLevelL1, HasOrigin(kOrigin.string())))
|
||||
EXPECT_CALL(*cdm, Unprovision(kSecurityLevelL1, HasOrigin(kOrigin.c_str())))
|
||||
.Times(1);
|
||||
EXPECT_CALL(*cdm, Unprovision(kSecurityLevelL3, HasOrigin(kOrigin.string())))
|
||||
EXPECT_CALL(*cdm, Unprovision(kSecurityLevelL3, HasOrigin(kOrigin.c_str())))
|
||||
.Times(1);
|
||||
|
||||
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto);
|
||||
@@ -908,10 +912,11 @@ TEST_F(WVDrmPluginTest, WillNotUnprovisionWithoutOrigin) {
|
||||
.WillOnce(DoAll(SetArgPointee<2>(kDeviceId),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
Vector<uint8_t> cert;
|
||||
Vector<uint8_t> key;
|
||||
Vector<uint8_t> specialResponse;
|
||||
specialResponse.appendArray(kUnprovisionResponse, kUnprovisionResponseSize);
|
||||
std::vector<uint8_t> cert;
|
||||
std::vector<uint8_t> key;
|
||||
std::vector<uint8_t> specialResponse;
|
||||
specialResponse.assign(
|
||||
kUnprovisionResponse, kUnprovisionResponse + kUnprovisionResponseSize);
|
||||
|
||||
EXPECT_CALL(*cdm, Unprovision(_, _))
|
||||
.Times(0);
|
||||
@@ -934,18 +939,19 @@ TEST_F(WVDrmPluginTest, MuxesOriginUnprovisioningErrors) {
|
||||
.WillOnce(DoAll(SetArgPointee<2>(kDeviceId),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
Vector<uint8_t> cert;
|
||||
Vector<uint8_t> key;
|
||||
Vector<uint8_t> specialResponse;
|
||||
specialResponse.appendArray(kUnprovisionResponse, kUnprovisionResponseSize);
|
||||
std::vector<uint8_t> cert;
|
||||
std::vector<uint8_t> key;
|
||||
std::vector<uint8_t> specialResponse;
|
||||
specialResponse.assign(
|
||||
kUnprovisionResponse, kUnprovisionResponse + kUnprovisionResponseSize);
|
||||
|
||||
// Tests that both Unprovisions are called even if one fails. Also tests that
|
||||
// no matter which fails, the function always propagates the error.
|
||||
EXPECT_CALL(*cdm, Unprovision(kSecurityLevelL1, HasOrigin(kOrigin.string())))
|
||||
EXPECT_CALL(*cdm, Unprovision(kSecurityLevelL1, HasOrigin(kOrigin.c_str())))
|
||||
.WillOnce(testing::Return(wvcdm::UNKNOWN_ERROR))
|
||||
.WillOnce(testing::Return(wvcdm::NO_ERROR))
|
||||
.WillOnce(testing::Return(wvcdm::UNKNOWN_ERROR));
|
||||
EXPECT_CALL(*cdm, Unprovision(kSecurityLevelL3, HasOrigin(kOrigin.string())))
|
||||
EXPECT_CALL(*cdm, Unprovision(kSecurityLevelL3, HasOrigin(kOrigin.c_str())))
|
||||
.WillOnce(testing::Return(wvcdm::NO_ERROR))
|
||||
.WillOnce(testing::Return(wvcdm::UNKNOWN_ERROR))
|
||||
.WillOnce(testing::Return(wvcdm::UNKNOWN_ERROR));
|
||||
@@ -1005,7 +1011,7 @@ TEST_F(WVDrmPluginTest, GetsSecureStops) {
|
||||
.WillOnce(DoAll(SetArgPointee<1>(cdmStops),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
List<std::vector<uint8_t> > stops;
|
||||
std::list<std::vector<uint8_t> > stops;
|
||||
|
||||
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto);
|
||||
Status status = plugin.setPropertyString(hidl_string("appId"),
|
||||
@@ -1024,7 +1030,7 @@ TEST_F(WVDrmPluginTest, GetsSecureStops) {
|
||||
}
|
||||
});
|
||||
|
||||
List<std::vector<uint8_t> >::iterator iter = stops.begin();
|
||||
std::list<std::vector<uint8_t> >::iterator iter = stops.begin();
|
||||
uint32_t rawIter = 0;
|
||||
while (rawIter < kStopCount && iter != stops.end()) {
|
||||
EXPECT_THAT(*iter, ElementsAreArray(stopsRaw[rawIter], kStopSize));
|
||||
@@ -1072,8 +1078,8 @@ TEST_F(WVDrmPluginTest, ReleasesSecureStop) {
|
||||
fread(messageRaw, sizeof(uint8_t), kMessageSize, fp);
|
||||
fclose(fp);
|
||||
|
||||
Vector<uint8_t> message;
|
||||
message.appendArray(messageRaw, kMessageSize);
|
||||
std::vector<uint8_t> message;
|
||||
message.assign(messageRaw, messageRaw + kMessageSize);
|
||||
|
||||
EXPECT_CALL(*cdm, ReleaseUsageInfo(ElementsAreArray(messageRaw,
|
||||
kMessageSize)))
|
||||
@@ -1131,8 +1137,8 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto);
|
||||
String8 stringResult;
|
||||
Vector<uint8_t> vectorResult;
|
||||
std::string stringResult;
|
||||
std::vector<uint8_t> vectorResult;
|
||||
|
||||
plugin.getPropertyString(
|
||||
hidl_string("vendor"), [&](Status status, hidl_string stringResult) {
|
||||
@@ -1219,8 +1225,8 @@ TEST_F(WVDrmPluginTest, DoesNotGetUnknownProperties) {
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto);
|
||||
String8 stringResult;
|
||||
Vector<uint8_t> vectorResult;
|
||||
std::string stringResult;
|
||||
std::vector<uint8_t> vectorResult;
|
||||
|
||||
plugin.getPropertyString(
|
||||
hidl_string("unknownProperty"),
|
||||
@@ -1252,8 +1258,8 @@ TEST_F(WVDrmPluginTest, DoesNotSetUnknownProperties) {
|
||||
fclose(fp);
|
||||
|
||||
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto);
|
||||
Vector<uint8_t> value;
|
||||
value.appendArray(valueRaw, kValueSize);
|
||||
std::vector<uint8_t> value;
|
||||
value.assign(valueRaw, valueRaw + kValueSize);
|
||||
|
||||
Status status = plugin.setPropertyString(hidl_string("unknownProperty"),
|
||||
hidl_string("ignored"));
|
||||
@@ -1272,10 +1278,10 @@ TEST_F(WVDrmPluginTest, FailsGenericMethodsWithoutAnAlgorithmSet) {
|
||||
.WillOnce(DoAll(SetArgPointee<2>(kDeviceId),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
Vector<uint8_t> keyId;
|
||||
Vector<uint8_t> input;
|
||||
Vector<uint8_t> iv;
|
||||
Vector<uint8_t> output;
|
||||
std::vector<uint8_t> keyId;
|
||||
std::vector<uint8_t> input;
|
||||
std::vector<uint8_t> iv;
|
||||
std::vector<uint8_t> output;
|
||||
bool match;
|
||||
|
||||
// Provide expected behavior to support session creation
|
||||
@@ -1296,7 +1302,7 @@ TEST_F(WVDrmPluginTest, FailsGenericMethodsWithoutAnAlgorithmSet) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
|
||||
// Note that we do not set the algorithms. This should cause these methods
|
||||
@@ -1353,13 +1359,13 @@ TEST_F(WVDrmPluginTest, CallsGenericEncrypt) {
|
||||
fread(ivRaw, sizeof(uint8_t), KEY_IV_SIZE, fp);
|
||||
fclose(fp);
|
||||
|
||||
Vector<uint8_t> keyId;
|
||||
keyId.appendArray(keyIdRaw, KEY_ID_SIZE);
|
||||
Vector<uint8_t> input;
|
||||
input.appendArray(inputRaw, kDataSize);
|
||||
Vector<uint8_t> iv;
|
||||
iv.appendArray(ivRaw, KEY_IV_SIZE);
|
||||
Vector<uint8_t> output;
|
||||
std::vector<uint8_t> keyId;
|
||||
keyId.assign(keyIdRaw, keyIdRaw + KEY_ID_SIZE);
|
||||
std::vector<uint8_t> input;
|
||||
input.assign(inputRaw, inputRaw + kDataSize);
|
||||
std::vector<uint8_t> iv;
|
||||
iv.assign(ivRaw, ivRaw + KEY_IV_SIZE);
|
||||
std::vector<uint8_t> output;
|
||||
|
||||
{
|
||||
InSequence calls;
|
||||
@@ -1392,7 +1398,7 @@ TEST_F(WVDrmPluginTest, CallsGenericEncrypt) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
|
||||
Status status = plugin.setCipherAlgorithm(toHidlVec(sessionId),
|
||||
@@ -1424,13 +1430,13 @@ TEST_F(WVDrmPluginTest, CallsGenericDecrypt) {
|
||||
fread(ivRaw, sizeof(uint8_t), KEY_IV_SIZE, fp);
|
||||
fclose(fp);
|
||||
|
||||
Vector<uint8_t> keyId;
|
||||
keyId.appendArray(keyIdRaw, KEY_ID_SIZE);
|
||||
Vector<uint8_t> input;
|
||||
input.appendArray(inputRaw, kDataSize);
|
||||
Vector<uint8_t> iv;
|
||||
iv.appendArray(ivRaw, KEY_IV_SIZE);
|
||||
Vector<uint8_t> output;
|
||||
std::vector<uint8_t> keyId;
|
||||
keyId.assign(keyIdRaw, keyIdRaw + KEY_ID_SIZE);
|
||||
std::vector<uint8_t> input;
|
||||
input.assign(inputRaw, inputRaw + kDataSize);
|
||||
std::vector<uint8_t> iv;
|
||||
iv.assign(ivRaw, ivRaw + KEY_IV_SIZE);
|
||||
std::vector<uint8_t> output;
|
||||
|
||||
{
|
||||
InSequence calls;
|
||||
@@ -1463,7 +1469,7 @@ TEST_F(WVDrmPluginTest, CallsGenericDecrypt) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
|
||||
Status status = plugin.setCipherAlgorithm(toHidlVec(sessionId),
|
||||
@@ -1493,11 +1499,11 @@ TEST_F(WVDrmPluginTest, CallsGenericSign) {
|
||||
fread(messageRaw, sizeof(uint8_t), kDataSize, fp);
|
||||
fclose(fp);
|
||||
|
||||
Vector<uint8_t> keyId;
|
||||
keyId.appendArray(keyIdRaw, KEY_ID_SIZE);
|
||||
Vector<uint8_t> message;
|
||||
message.appendArray(messageRaw, kDataSize);
|
||||
Vector<uint8_t> signature;
|
||||
std::vector<uint8_t> keyId;
|
||||
keyId.assign(keyIdRaw, keyIdRaw + KEY_ID_SIZE);
|
||||
std::vector<uint8_t> message;
|
||||
message.assign(messageRaw, messageRaw + kDataSize);
|
||||
std::vector<uint8_t> signature;
|
||||
|
||||
{
|
||||
InSequence calls;
|
||||
@@ -1536,7 +1542,7 @@ TEST_F(WVDrmPluginTest, CallsGenericSign) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
|
||||
Status status = plugin.setMacAlgorithm(toHidlVec(sessionId),
|
||||
@@ -1570,12 +1576,12 @@ TEST_F(WVDrmPluginTest, CallsGenericVerify) {
|
||||
fread(signatureRaw, sizeof(uint8_t), kSignatureSize, fp);
|
||||
fclose(fp);
|
||||
|
||||
Vector<uint8_t> keyId;
|
||||
keyId.appendArray(keyIdRaw, KEY_ID_SIZE);
|
||||
Vector<uint8_t> message;
|
||||
message.appendArray(messageRaw, kDataSize);
|
||||
Vector<uint8_t> signature;
|
||||
signature.appendArray(signatureRaw, kSignatureSize);
|
||||
std::vector<uint8_t> keyId;
|
||||
keyId.assign(keyIdRaw, keyIdRaw + KEY_ID_SIZE);
|
||||
std::vector<uint8_t> message;
|
||||
message.assign(messageRaw, messageRaw + kDataSize);
|
||||
std::vector<uint8_t> signature;
|
||||
signature.assign(signatureRaw, signatureRaw + kSignatureSize);
|
||||
bool match;
|
||||
|
||||
{
|
||||
@@ -1620,7 +1626,7 @@ TEST_F(WVDrmPluginTest, CallsGenericVerify) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
|
||||
Status status = plugin.setMacAlgorithm(toHidlVec(sessionId),
|
||||
@@ -1738,11 +1744,11 @@ TEST_F(WVDrmPluginTest, DISABLED_MarshalsEvents) {
|
||||
hidl_vec<uint8_t> hSessionId;
|
||||
hSessionId.setToExternal(sessionIdRaw, kSessionIdSize);
|
||||
|
||||
Vector<uint8_t> keyId;
|
||||
Vector<KeyStatus> keyStatusList;
|
||||
std::vector<uint8_t> keyId;
|
||||
std::vector<KeyStatus> keyStatusList;
|
||||
|
||||
KeyStatus keyStatus;
|
||||
keyId.appendArray(reinterpret_cast<const uint8_t*>(kKeyId1.data()), kKeyId1.size());
|
||||
keyId.assign(kKeyId1.begin(), kKeyId1.end());
|
||||
keyStatus.keyId = toHidlVec(keyId);
|
||||
keyStatus.type = KeyStatusType::EXPIRED;
|
||||
keyStatusList.push_back(keyStatus);
|
||||
@@ -1765,16 +1771,16 @@ TEST_F(WVDrmPluginTest, DISABLED_MarshalsEvents) {
|
||||
|
||||
keyStatusList.clear();
|
||||
keyId.clear();
|
||||
keyId.appendArray(reinterpret_cast<const uint8_t*>(kKeyId1.data()), kKeyId1.size());
|
||||
keyId.assign(kKeyId1.begin(), kKeyId1.end());
|
||||
keyStatus.type = KeyStatusType::USABLE;
|
||||
keyStatusList.push_back(keyStatus);
|
||||
keyId.appendArray(reinterpret_cast<const uint8_t*>(kKeyId2.data()), kKeyId2.size());
|
||||
keyId.assign(kKeyId2.begin(), kKeyId2.end());
|
||||
keyStatus.type = KeyStatusType::OUTPUTNOTALLOWED;
|
||||
keyStatusList.push_back(keyStatus);
|
||||
keyId.appendArray(reinterpret_cast<const uint8_t*>(kKeyId3.data()), kKeyId3.size());
|
||||
keyId.assign(kKeyId3.begin(), kKeyId3.end());
|
||||
keyStatus.type = KeyStatusType::INTERNALERROR;
|
||||
keyStatusList.push_back(keyStatus);
|
||||
keyId.appendArray(reinterpret_cast<const uint8_t*>(kKeyId4.data()), kKeyId4.size());
|
||||
keyId.assign(kKeyId4.begin(), kKeyId4.end());
|
||||
keyStatus.type = KeyStatusType::STATUSPENDING;
|
||||
keyStatusList.push_back(keyStatus);
|
||||
|
||||
@@ -1928,7 +1934,7 @@ TEST_F(WVDrmPluginTest, CanSetAppId) {
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
|
||||
// Verify application id is set correctly.
|
||||
EXPECT_STREQ(kAppId, propertySet->app_id().c_str());
|
||||
EXPECT_STREQ(kAppId.c_str(), propertySet->app_id().c_str());
|
||||
|
||||
// Test setting application id while session is opened, this should fail.
|
||||
status = plugin.setPropertyString(hidl_string("appId"),
|
||||
@@ -1965,7 +1971,7 @@ TEST_P(WVDrmPluginOriginTest, CanSetOrigin) {
|
||||
// Set the properties & run the test
|
||||
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto);
|
||||
|
||||
if (!params.origin.isEmpty()) {
|
||||
if (!params.origin.empty()) {
|
||||
ASSERT_EQ(Status::OK,
|
||||
plugin.setPropertyString(hidl_string("origin"),
|
||||
hidl_string(params.origin)));
|
||||
@@ -1983,7 +1989,7 @@ TEST_P(WVDrmPluginOriginTest, CanSetOrigin) {
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OriginTests, WVDrmPluginOriginTest, Values(
|
||||
OriginTestVariant("No Origin", kEmptyString, EMPTY_ORIGIN),
|
||||
OriginTestVariant("With an Origin", kOrigin, kOrigin.string())));
|
||||
OriginTestVariant("With an Origin", kOrigin, kOrigin.c_str())));
|
||||
|
||||
TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
|
||||
@@ -2028,7 +2034,7 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
EXPECT_STREQ("L3", propertySet->security_level().c_str());
|
||||
@@ -2043,7 +2049,7 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
EXPECT_STREQ("L3", propertySet->security_level().c_str());
|
||||
@@ -2058,7 +2064,7 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
EXPECT_STREQ("", propertySet->security_level().c_str());
|
||||
@@ -2073,7 +2079,7 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
EXPECT_STREQ("L3", propertySet->security_level().c_str());
|
||||
@@ -2087,7 +2093,7 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
EXPECT_STREQ("", propertySet->security_level().c_str());
|
||||
@@ -2102,7 +2108,7 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
EXPECT_STREQ("", propertySet->security_level().c_str());
|
||||
@@ -2150,7 +2156,7 @@ TEST_F(WVDrmPluginTest, CanSetPrivacyMode) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
|
||||
@@ -2189,11 +2195,11 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
|
||||
fread(privacyCertRaw, sizeof(uint8_t), kPrivacyCertSize, fp);
|
||||
fclose(fp);
|
||||
|
||||
Vector<uint8_t> privacyCert;
|
||||
privacyCert.appendArray(privacyCertRaw, kPrivacyCertSize);
|
||||
std::vector<uint8_t> privacyCert;
|
||||
privacyCert.assign(privacyCertRaw, privacyCertRaw + kPrivacyCertSize);
|
||||
std::string strPrivacyCert(reinterpret_cast<char*>(privacyCertRaw),
|
||||
kPrivacyCertSize);
|
||||
Vector<uint8_t> emptyVector;
|
||||
std::vector<uint8_t> emptyVector;
|
||||
|
||||
// Provide expected mock behavior
|
||||
{
|
||||
@@ -2224,7 +2230,7 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
|
||||
@@ -2286,7 +2292,7 @@ TEST_F(WVDrmPluginTest, CanSetSessionSharing) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
EXPECT_TRUE(propertySet->is_session_sharing_enabled());
|
||||
@@ -2301,7 +2307,7 @@ TEST_F(WVDrmPluginTest, CanSetSessionSharing) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
EXPECT_FALSE(propertySet->is_session_sharing_enabled());
|
||||
@@ -2317,7 +2323,7 @@ TEST_F(WVDrmPluginTest, CanSetSessionSharing) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
status = plugin.setPropertyString(hidl_string("sessionSharing"),
|
||||
hidl_string("enable"));
|
||||
@@ -2363,7 +2369,7 @@ TEST_F(WVDrmPluginTest, AllowsStoringOfSessionSharingId) {
|
||||
plugin.openSession([&](Status status, hidl_vec<uint8_t> hSessionId) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
sessionId.clear();
|
||||
sessionId.appendArray(hSessionId.data(), hSessionId.size());
|
||||
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
|
||||
});
|
||||
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
|
||||
@@ -25,8 +25,6 @@ LOCAL_STATIC_LIBRARIES := \
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libdl \
|
||||
liblog \
|
||||
libmedia \
|
||||
libstagefright_foundation \
|
||||
libutils \
|
||||
libwvdrmengine \
|
||||
|
||||
@@ -74,8 +72,6 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
libhidlbase \
|
||||
libhidlmemory \
|
||||
liblog \
|
||||
libmedia \
|
||||
libstagefright_foundation \
|
||||
libutils \
|
||||
libwvhidl \
|
||||
|
||||
|
||||
Reference in New Issue
Block a user