Replace toStatus indirection.
CdmResponseType are mapped to android::status_t, then map to hidl android::hardware::drm::V1_0::Status. This CL removes the indirection by mapping cdm errors to hidl Status. Test: Play Movies (pin and streaming) Test: Netflix (download and streaming) Test: libwvdrmmediacrypto_hidl_test and libwvdrmdrmplugin_hidl_test Test: GtsMediaTestCases module Test: Vts - VtsHalDrmV1_0Target bug: 34682447 Change-Id: I0b04f47871f5e4898e7297831d5fceab52e0f7f9
This commit is contained in:
@@ -38,7 +38,7 @@ using ::android::hardware::drm::V1_0::KeyStatusType;
|
||||
using ::android::hardware::drm::V1_0::KeyType;
|
||||
using ::android::hardware::drm::V1_0::Status;
|
||||
using ::android::hardware::drm::V1_0::widevine::toHidlVec;
|
||||
using ::android::hardware::drm::V1_0::widevine::toStatus;
|
||||
|
||||
using ::android::hardware::drm::V1_0::widevine::toVector;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
@@ -123,13 +123,13 @@ WVDrmPlugin::~WVDrmPlugin() {
|
||||
}
|
||||
|
||||
Return<void> WVDrmPlugin::openSession(openSession_cb _hidl_cb) {
|
||||
status_t status = android::OK;
|
||||
Status status = Status::OK;
|
||||
std::vector<uint8_t> sessionId;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != android::OK) {
|
||||
_hidl_cb(toStatus(status), toHidlVec(sessionId));
|
||||
if (status != Status::OK) {
|
||||
_hidl_cb(status, toHidlVec(sessionId));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ Return<void> WVDrmPlugin::openSession(openSession_cb _hidl_cb) {
|
||||
|
||||
if (!isCdmResponseTypeSuccess(res)) {
|
||||
status = mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
_hidl_cb(toStatus(status), toHidlVec(sessionId));
|
||||
_hidl_cb(status, toHidlVec(sessionId));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -175,10 +175,11 @@ Return<void> WVDrmPlugin::openSession(openSession_cb _hidl_cb) {
|
||||
} 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.
|
||||
status = kErrorCDMGeneric;
|
||||
ALOGW("Returns UNKNOWN error for legacy status kErrorCDMGeneric");
|
||||
status = Status::ERROR_DRM_UNKNOWN;
|
||||
}
|
||||
}
|
||||
_hidl_cb(toStatus(status), toHidlVec(sessionId));
|
||||
_hidl_cb(status, toHidlVec(sessionId));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -210,15 +211,15 @@ Return<void> WVDrmPlugin::getKeyRequest(
|
||||
return Void();
|
||||
}
|
||||
KeyRequestType requestType = KeyRequestType::UNKNOWN;
|
||||
status_t status = android::OK;
|
||||
Status status = Status::OK;
|
||||
std::string defaultUrl;
|
||||
std::vector<uint8_t> request;
|
||||
const std::vector<uint8_t> scopeId = toVector(scope);
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != android::OK) {
|
||||
_hidl_cb(toStatus(status), toHidlVec(request), requestType,
|
||||
if (status != Status::OK) {
|
||||
_hidl_cb(status, toHidlVec(request), requestType,
|
||||
defaultUrl.c_str());
|
||||
return Void();
|
||||
}
|
||||
@@ -313,7 +314,7 @@ Return<void> WVDrmPlugin::getKeyRequest(
|
||||
// For all other requests, we have a session ID.
|
||||
status = mapAndNotifyOfCdmResponseType(scopeId, res);
|
||||
}
|
||||
_hidl_cb(toStatus(status), toHidlVec(request), requestType,
|
||||
_hidl_cb(status, toHidlVec(request), requestType,
|
||||
defaultUrl.c_str());
|
||||
return Void();
|
||||
}
|
||||
@@ -356,7 +357,7 @@ Return<void> WVDrmPlugin::provideKeyResponse(
|
||||
keySetId = StrToVector(cdmKeySetId);
|
||||
}
|
||||
|
||||
status_t status = android::OK;
|
||||
Status status = Status::OK;
|
||||
if (isRelease) {
|
||||
// When releasing keys, we do not have a session ID.
|
||||
status = mapCdmResponseType(res);
|
||||
@@ -367,10 +368,10 @@ Return<void> WVDrmPlugin::provideKeyResponse(
|
||||
// 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 = android::OK;
|
||||
status = Status::OK;
|
||||
}
|
||||
}
|
||||
_hidl_cb(toStatus(status), toHidlVec(keySetId));
|
||||
_hidl_cb(status, toHidlVec(keySetId));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -384,7 +385,7 @@ Return<Status> WVDrmPlugin::removeKeys(const hidl_vec<uint8_t>& sessionId) {
|
||||
|
||||
CdmResponseType res = mCDM->RemoveKeys(cdmSessionId);
|
||||
|
||||
return toStatus(mapAndNotifyOfCdmResponseType(sId, res));
|
||||
return mapAndNotifyOfCdmResponseType(sId, res);
|
||||
}
|
||||
|
||||
Return<Status> WVDrmPlugin::restoreKeys(const hidl_vec<uint8_t>& sessionId,
|
||||
@@ -400,16 +401,16 @@ Return<Status> WVDrmPlugin::restoreKeys(const hidl_vec<uint8_t>& sessionId,
|
||||
|
||||
CdmResponseType res = mCDM->RestoreKey(cdmSessionId, cdmKeySetId);
|
||||
|
||||
return toStatus(mapAndNotifyOfCdmResponseType(sId, res));
|
||||
return mapAndNotifyOfCdmResponseType(sId, res);
|
||||
}
|
||||
|
||||
Return<void> WVDrmPlugin::queryKeyStatus(const hidl_vec<uint8_t>& sessionId,
|
||||
queryKeyStatus_cb _hidl_cb) {
|
||||
|
||||
if (sessionId.size() == 0) {
|
||||
_hidl_cb(Status::BAD_VALUE, hidl_vec<KeyValue>());
|
||||
return Void();
|
||||
}
|
||||
if (sessionId.size() == 0) {
|
||||
_hidl_cb(Status::BAD_VALUE, hidl_vec<KeyValue>());
|
||||
return Void();
|
||||
}
|
||||
const std::vector<uint8_t> sId = toVector(sessionId);
|
||||
CdmSessionId cdmSessionId(sId.begin(), sId.end());
|
||||
CdmQueryMap cdmLicenseInfo;
|
||||
@@ -432,7 +433,7 @@ Return<Status> WVDrmPlugin::restoreKeys(const hidl_vec<uint8_t>& sessionId,
|
||||
}
|
||||
}
|
||||
|
||||
_hidl_cb(toStatus(mapCdmResponseType(res)), toHidlVec(infoMapVec));
|
||||
_hidl_cb(mapCdmResponseType(res), toHidlVec(infoMapVec));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -440,14 +441,14 @@ Return<Status> WVDrmPlugin::restoreKeys(const hidl_vec<uint8_t>& sessionId,
|
||||
const hidl_string& certificateType,
|
||||
const hidl_string& certificateAuthority,
|
||||
getProvisionRequest_cb _hidl_cb) {
|
||||
status_t status = android::OK;
|
||||
Status status = Status::OK;
|
||||
std::string defaultUrl;
|
||||
std::vector<uint8_t> request;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != android::OK) {
|
||||
_hidl_cb(toStatus(status), toHidlVec(request), hidl_string(defaultUrl));
|
||||
if (status != Status::OK) {
|
||||
_hidl_cb(status, toHidlVec(request), hidl_string(defaultUrl));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -470,7 +471,7 @@ Return<Status> WVDrmPlugin::restoreKeys(const hidl_vec<uint8_t>& sessionId,
|
||||
defaultUrl.assign(cdmDefaultUrl.data(), cdmDefaultUrl.size());
|
||||
}
|
||||
|
||||
_hidl_cb(toStatus(mapCdmResponseType(res)), toHidlVec(request),
|
||||
_hidl_cb(mapCdmResponseType(res), toHidlVec(request),
|
||||
hidl_string(defaultUrl));
|
||||
return Void();
|
||||
}
|
||||
@@ -488,19 +489,20 @@ Return<void> WVDrmPlugin::provideProvisionResponse(
|
||||
std::vector<uint8_t> wrappedKey;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status_t status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != android::OK) {
|
||||
_hidl_cb(toStatus(status), toHidlVec(certificate), toHidlVec(wrappedKey));
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
_hidl_cb(status, toHidlVec(certificate), toHidlVec(wrappedKey));
|
||||
}
|
||||
|
||||
CdmProvisioningResponse cdmResponse(resp.begin(), resp.end());
|
||||
if (cdmResponse == kSpecialUnprovisionResponse) {
|
||||
if (identifier == kDefaultCdmIdentifier) {
|
||||
_hidl_cb(toStatus(kErrorNoOriginSpecified), toHidlVec(certificate),
|
||||
ALOGW("Returns UNKNOWN error for legacy status kErrorNoOriginSpecified");
|
||||
_hidl_cb(Status::ERROR_DRM_UNKNOWN, toHidlVec(certificate),
|
||||
toHidlVec(wrappedKey));
|
||||
return Void();
|
||||
}
|
||||
_hidl_cb(toStatus(unprovision(identifier)),
|
||||
_hidl_cb(unprovision(identifier),
|
||||
toHidlVec(certificate),
|
||||
toHidlVec(wrappedKey));
|
||||
return Void();
|
||||
@@ -514,13 +516,13 @@ Return<void> WVDrmPlugin::provideProvisionResponse(
|
||||
wrappedKey = StrToVector(cdmWrappedKey);
|
||||
}
|
||||
|
||||
_hidl_cb(toStatus(mapCdmResponseType(res)), toHidlVec(certificate),
|
||||
_hidl_cb(mapCdmResponseType(res), toHidlVec(certificate),
|
||||
toHidlVec(wrappedKey));
|
||||
return Void();
|
||||
}
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::unprovisionDevice() {
|
||||
Status WVDrmPlugin::unprovisionDevice() {
|
||||
return unprovision(kDefaultCdmIdentifier);
|
||||
}
|
||||
|
||||
@@ -536,9 +538,9 @@ Return<void> WVDrmPlugin::getSecureStop(
|
||||
SecureStop secureStop;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status_t status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != android::OK) {
|
||||
_hidl_cb(toStatus(status), secureStop);
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
_hidl_cb(status, secureStop);
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -558,7 +560,7 @@ Return<void> WVDrmPlugin::getSecureStop(
|
||||
secureStop.opaqueData = toHidlVec(cdmStopVec);
|
||||
}
|
||||
|
||||
_hidl_cb(toStatus(mapCdmResponseType(res)), secureStop);
|
||||
_hidl_cb(mapCdmResponseType(res), secureStop);
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -568,9 +570,9 @@ Return<void> WVDrmPlugin::getSecureStops(getSecureStops_cb _hidl_cb) {
|
||||
std::vector<SecureStop> secureStopsVec;
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status_t status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != android::OK) {
|
||||
_hidl_cb(toStatus(status), toHidlVec(secureStopsVec));
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
_hidl_cb(status, toHidlVec(secureStopsVec));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -595,21 +597,21 @@ Return<void> WVDrmPlugin::getSecureStops(getSecureStops_cb _hidl_cb) {
|
||||
secureStopsVec.push_back(secureStop);
|
||||
}
|
||||
|
||||
_hidl_cb(toStatus(mapCdmResponseType(res)), toHidlVec(secureStopsVec));
|
||||
_hidl_cb(mapCdmResponseType(res), toHidlVec(secureStopsVec));
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Status> WVDrmPlugin::releaseAllSecureStops() {
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status_t status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != android::OK) {
|
||||
return toStatus(status);
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
CdmResponseType res = mCDM->ReleaseAllUsageInfo(mPropertySet.app_id(),
|
||||
identifier);
|
||||
return toStatus(mapCdmResponseType(res));
|
||||
return mapCdmResponseType(res);
|
||||
}
|
||||
|
||||
Return<Status> WVDrmPlugin::releaseSecureStop(
|
||||
@@ -620,20 +622,20 @@ Return<Status> WVDrmPlugin::releaseSecureStop(
|
||||
}
|
||||
|
||||
CdmIdentifier identifier;
|
||||
status_t status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != android::OK) {
|
||||
return toStatus(status);
|
||||
Status status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
const std::vector<uint8_t> ssRelease = toVector(secureStopId);
|
||||
CdmUsageInfoReleaseMessage cdmMessage(ssRelease.begin(), ssRelease.end());
|
||||
CdmResponseType res = mCDM->ReleaseUsageInfo(cdmMessage, identifier);
|
||||
return toStatus(mapCdmResponseType(res));
|
||||
return mapCdmResponseType(res);
|
||||
}
|
||||
|
||||
Return<void> WVDrmPlugin::getPropertyString(const hidl_string& propertyName,
|
||||
getPropertyString_cb _hidl_cb) {
|
||||
status_t status = android::OK;
|
||||
Status status = Status::OK;
|
||||
std::string name(propertyName.c_str());
|
||||
std::string value;
|
||||
|
||||
@@ -689,10 +691,10 @@ Return<void> WVDrmPlugin::getPropertyString(const hidl_string& propertyName,
|
||||
status = queryProperty(wvcdm::QUERY_KEY_SRM_UPDATE_SUPPORT, value);
|
||||
} else {
|
||||
ALOGE("App requested unknown string property %s", name.c_str());
|
||||
status = android::ERROR_DRM_CANNOT_HANDLE;
|
||||
status = Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
}
|
||||
|
||||
_hidl_cb(toStatus(status), value.c_str());
|
||||
_hidl_cb(status, value.c_str());
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -700,20 +702,20 @@ Return<void> WVDrmPlugin::getPropertyByteArray(
|
||||
const hidl_string& propertyName,
|
||||
getPropertyByteArray_cb _hidl_cb) {
|
||||
|
||||
status_t status = android::OK;
|
||||
Status status = Status::OK;
|
||||
std::string name(propertyName.c_str());
|
||||
std::vector<uint8_t> value;
|
||||
|
||||
if (name == "deviceUniqueId") {
|
||||
std::string id;
|
||||
status = mCdmIdentifierBuilder.getDeviceUniqueId(&id);
|
||||
if (status == android::OK) {
|
||||
if (status == Status::OK) {
|
||||
value = StrToVector(id);
|
||||
}
|
||||
} else if (name == "provisioningUniqueId") {
|
||||
std::string id;
|
||||
status = mCdmIdentifierBuilder.getProvisioningUniqueId(&id);
|
||||
if (status == android::OK) {
|
||||
if (status == Status::OK) {
|
||||
value = StrToVector(id);
|
||||
}
|
||||
} else if (name == "serviceCertificate") {
|
||||
@@ -724,10 +726,10 @@ Return<void> WVDrmPlugin::getPropertyByteArray(
|
||||
value = StrToVector(metrics_value);
|
||||
} else {
|
||||
ALOGE("App requested unknown byte array property %s", name.c_str());
|
||||
status = android::ERROR_DRM_CANNOT_HANDLE;
|
||||
status = Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
}
|
||||
|
||||
_hidl_cb(toStatus(status), toHidlVec(value));
|
||||
_hidl_cb(status, toHidlVec(value));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -743,11 +745,11 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
} 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_t status = queryProperty(
|
||||
Status status = queryProperty(
|
||||
wvcdm::kLevelDefault, wvcdm::QUERY_KEY_SECURITY_LEVEL,
|
||||
current_security_level);
|
||||
if (status != android::OK) {
|
||||
return toStatus(status);
|
||||
if (status != Status::OK) {
|
||||
return status;
|
||||
}
|
||||
if (current_security_level != wvcdm::QUERY_VALUE_SECURITY_LEVEL_L1) {
|
||||
ALOGE("App requested L1 security on a non-L1 device.");
|
||||
@@ -763,7 +765,8 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
}
|
||||
} else {
|
||||
ALOGE("App tried to change security level while sessions are open.");
|
||||
return toStatus(kErrorSessionIsOpen);
|
||||
ALOGW("Returns UNKNOWN error for legacy status kErrorSessionIsOpen");
|
||||
return Status::ERROR_DRM_UNKNOWN;
|
||||
}
|
||||
} else if (name == "privacyMode") {
|
||||
if (_value == kEnable) {
|
||||
@@ -786,19 +789,22 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
}
|
||||
} else {
|
||||
ALOGE("App tried to change key sharing while sessions are open.");
|
||||
return toStatus(kErrorSessionIsOpen);
|
||||
ALOGW("Returns UNKNOWN error for legacy status kErrorSessionIsOpen");
|
||||
return Status::ERROR_DRM_UNKNOWN;
|
||||
}
|
||||
} else if (name == "appId") {
|
||||
if (mCryptoSessions.size() == 0) {
|
||||
mPropertySet.set_app_id(_value.c_str());
|
||||
} else {
|
||||
ALOGE("App tried to set the application id while sessions are opened.");
|
||||
return toStatus(kErrorSessionIsOpen);
|
||||
ALOGW("Returns UNKNOWN error for legacy status kErrorSessionIsOpen");
|
||||
return Status::ERROR_DRM_UNKNOWN;
|
||||
}
|
||||
} else if (name == "origin") {
|
||||
if (mCryptoSessions.size() != 0) {
|
||||
ALOGE("App tried to set the origin while sessions are opened.");
|
||||
return toStatus(kErrorSessionIsOpen);
|
||||
ALOGW("Returns UNKNOWN error for legacy status kErrorSessionIsOpen");
|
||||
return Status::ERROR_DRM_UNKNOWN;
|
||||
} else {
|
||||
if (!mCdmIdentifierBuilder.set_origin(_value.c_str())) {
|
||||
return Status::BAD_VALUE;
|
||||
@@ -902,7 +908,8 @@ Return<void> WVDrmPlugin::encrypt(
|
||||
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
||||
|
||||
if (cryptoSession.cipherAlgorithm() == kInvalidCryptoAlgorithm) {
|
||||
_hidl_cb(toStatus(android::NO_INIT), toHidlVec(output));
|
||||
ALOGW("Returns UNKNOWN error for legacy status NO_INIT");
|
||||
_hidl_cb(Status::ERROR_DRM_UNKNOWN, toHidlVec(output));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -912,7 +919,7 @@ Return<void> WVDrmPlugin::encrypt(
|
||||
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
||||
_hidl_cb(toStatus(mapAndNotifyOfOEMCryptoResult(sId, res)),
|
||||
_hidl_cb(mapAndNotifyOfOEMCryptoResult(sId, res),
|
||||
toHidlVec(output));
|
||||
return Void();
|
||||
}
|
||||
@@ -929,7 +936,7 @@ Return<void> WVDrmPlugin::encrypt(
|
||||
_hidl_cb(Status::OK, toHidlVec(output));
|
||||
} else {
|
||||
ALOGE("OEMCrypto_Generic_Encrypt failed with %u", res);
|
||||
_hidl_cb(toStatus(mapAndNotifyOfOEMCryptoResult(sId, res)),
|
||||
_hidl_cb(mapAndNotifyOfOEMCryptoResult(sId, res),
|
||||
toHidlVec(output));
|
||||
}
|
||||
return Void();
|
||||
@@ -954,7 +961,8 @@ Return<void> WVDrmPlugin::decrypt(
|
||||
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
||||
|
||||
if (cryptoSession.cipherAlgorithm() == kInvalidCryptoAlgorithm) {
|
||||
_hidl_cb(toStatus(android::NO_INIT), toHidlVec(output));
|
||||
ALOGW("Returns UNKNOWN error for legacy status NO_INIT");
|
||||
_hidl_cb(Status::ERROR_DRM_UNKNOWN, toHidlVec(output));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -964,7 +972,7 @@ Return<void> WVDrmPlugin::decrypt(
|
||||
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
||||
_hidl_cb(toStatus(mapAndNotifyOfOEMCryptoResult(sId, res)),
|
||||
_hidl_cb(mapAndNotifyOfOEMCryptoResult(sId, res),
|
||||
toHidlVec(output));
|
||||
return Void();
|
||||
}
|
||||
@@ -981,7 +989,7 @@ Return<void> WVDrmPlugin::decrypt(
|
||||
_hidl_cb(Status::OK, toHidlVec(output));
|
||||
} else {
|
||||
ALOGE("OEMCrypto_Generic_Decrypt failed with %u", res);
|
||||
_hidl_cb(toStatus(mapAndNotifyOfOEMCryptoResult(sId, res)),
|
||||
_hidl_cb(mapAndNotifyOfOEMCryptoResult(sId, res),
|
||||
toHidlVec(output));
|
||||
}
|
||||
return Void();
|
||||
@@ -1005,7 +1013,8 @@ Return<void> WVDrmPlugin::sign(
|
||||
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
||||
|
||||
if (cryptoSession.macAlgorithm() == kInvalidCryptoAlgorithm) {
|
||||
_hidl_cb(toStatus(android::NO_INIT), toHidlVec(signature));
|
||||
ALOGW("Returns UNKNOWN error for legacy status NO_INIT");
|
||||
_hidl_cb(Status::ERROR_DRM_UNKNOWN, toHidlVec(signature));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -1015,7 +1024,7 @@ Return<void> WVDrmPlugin::sign(
|
||||
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
||||
_hidl_cb(toStatus(mapAndNotifyOfOEMCryptoResult(sId, res)),
|
||||
_hidl_cb(mapAndNotifyOfOEMCryptoResult(sId, res),
|
||||
toHidlVec(signature));
|
||||
return Void();
|
||||
}
|
||||
@@ -1031,7 +1040,7 @@ Return<void> WVDrmPlugin::sign(
|
||||
ALOGE("OEMCrypto_Generic_Sign failed with %u when requesting signature "
|
||||
"size", res);
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
_hidl_cb(toStatus(mapAndNotifyOfOEMCryptoResult(sId, res)),
|
||||
_hidl_cb(mapAndNotifyOfOEMCryptoResult(sId, res),
|
||||
toHidlVec(signature));
|
||||
} else {
|
||||
_hidl_cb(Status::ERROR_DRM_UNKNOWN, toHidlVec(signature));
|
||||
@@ -1049,7 +1058,7 @@ Return<void> WVDrmPlugin::sign(
|
||||
_hidl_cb(Status::OK, toHidlVec(signature));
|
||||
} else {
|
||||
ALOGE("OEMCrypto_Generic_Sign failed with %u", res);
|
||||
_hidl_cb(toStatus(mapAndNotifyOfOEMCryptoResult(sId, res)),
|
||||
_hidl_cb(mapAndNotifyOfOEMCryptoResult(sId, res),
|
||||
toHidlVec(signature));
|
||||
}
|
||||
return Void();
|
||||
@@ -1074,7 +1083,8 @@ Return<void> WVDrmPlugin::verify(
|
||||
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
||||
|
||||
if (cryptoSession.macAlgorithm() == kInvalidCryptoAlgorithm) {
|
||||
_hidl_cb(toStatus(android::NO_INIT), match);
|
||||
ALOGW("Returns UNKNOWN error for legacy status NO_INIT");
|
||||
_hidl_cb(Status::ERROR_DRM_UNKNOWN, match);
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -1084,7 +1094,7 @@ Return<void> WVDrmPlugin::verify(
|
||||
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
||||
_hidl_cb(toStatus(mapAndNotifyOfOEMCryptoResult(sId, res)), match);
|
||||
_hidl_cb(mapAndNotifyOfOEMCryptoResult(sId, res), match);
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -1102,7 +1112,7 @@ Return<void> WVDrmPlugin::verify(
|
||||
_hidl_cb(Status::OK, match);
|
||||
} else {
|
||||
ALOGE("OEMCrypto_Generic_Verify failed with %u", res);
|
||||
_hidl_cb(toStatus(mapAndNotifyOfOEMCryptoResult(sId, res)), match);
|
||||
_hidl_cb(mapAndNotifyOfOEMCryptoResult(sId, res), match);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
@@ -1143,7 +1153,7 @@ Return<void> WVDrmPlugin::signRSA(
|
||||
|
||||
if (res != OEMCrypto_SUCCESS) {
|
||||
ALOGE("OEMCrypto_GenerateRSASignature failed with %u", res);
|
||||
_hidl_cb(toStatus(mapOEMCryptoResult(res)), toHidlVec(signature));
|
||||
_hidl_cb(mapOEMCryptoResult(res), toHidlVec(signature));
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -1233,7 +1243,7 @@ void WVDrmPlugin::OnExpirationUpdate(const CdmSessionId& cdmSessionId,
|
||||
sendExpirationUpdate(toHidlVec(sessionId), newExpiryTimeMilliseconds);
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::queryProperty(const std::string& property,
|
||||
Status WVDrmPlugin::queryProperty(const std::string& property,
|
||||
std::string& stringValue) const {
|
||||
SecurityLevel securityLevel =
|
||||
mPropertySet.security_level().compare(
|
||||
@@ -1243,7 +1253,7 @@ status_t WVDrmPlugin::queryProperty(const std::string& property,
|
||||
return queryProperty(securityLevel, property, stringValue);
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::queryProperty(SecurityLevel securityLevel,
|
||||
Status WVDrmPlugin::queryProperty(SecurityLevel securityLevel,
|
||||
const std::string& property,
|
||||
std::string& stringValue) const {
|
||||
CdmResponseType res =
|
||||
@@ -1255,16 +1265,16 @@ status_t WVDrmPlugin::queryProperty(SecurityLevel securityLevel,
|
||||
return mapCdmResponseType(res);
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::queryProperty(const std::string& property,
|
||||
Status WVDrmPlugin::queryProperty(const std::string& property,
|
||||
std::vector<uint8_t>& vector_value) const {
|
||||
std::string string_value;
|
||||
status_t status = queryProperty(property, string_value);
|
||||
if (status != android::OK) return status;
|
||||
Status status = queryProperty(property, string_value);
|
||||
if (status != Status::OK) return status;
|
||||
vector_value = StrToVector(string_value);
|
||||
return android::OK;
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::mapAndNotifyOfCdmResponseType(
|
||||
Status WVDrmPlugin::mapAndNotifyOfCdmResponseType(
|
||||
const std::vector<uint8_t>& sessionId,
|
||||
CdmResponseType res) {
|
||||
|
||||
@@ -1278,7 +1288,7 @@ status_t WVDrmPlugin::mapAndNotifyOfCdmResponseType(
|
||||
return mapCdmResponseType(res);
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::mapAndNotifyOfOEMCryptoResult(
|
||||
Status WVDrmPlugin::mapAndNotifyOfOEMCryptoResult(
|
||||
const std::vector<uint8_t>& sessionId,
|
||||
OEMCryptoResult res) {
|
||||
|
||||
@@ -1289,31 +1299,34 @@ status_t WVDrmPlugin::mapAndNotifyOfOEMCryptoResult(
|
||||
return mapOEMCryptoResult(res);
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::mapOEMCryptoResult(OEMCryptoResult res) {
|
||||
Status WVDrmPlugin::mapOEMCryptoResult(OEMCryptoResult res) {
|
||||
switch (res) {
|
||||
case OEMCrypto_SUCCESS:
|
||||
return android::OK;
|
||||
return Status::OK;
|
||||
|
||||
case OEMCrypto_ERROR_SIGNATURE_FAILURE:
|
||||
return android::ERROR_DRM_TAMPER_DETECTED;
|
||||
case OEMCrypto_ERROR_SHORT_BUFFER:
|
||||
return kErrorIncorrectBufferSize;
|
||||
return Status::ERROR_DRM_INVALID_STATE;
|
||||
|
||||
case OEMCrypto_ERROR_NO_DEVICE_KEY:
|
||||
return android::ERROR_DRM_NOT_PROVISIONED;
|
||||
return Status::ERROR_DRM_NOT_PROVISIONED;
|
||||
|
||||
case OEMCrypto_ERROR_INVALID_SESSION:
|
||||
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
return Status::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
|
||||
case OEMCrypto_ERROR_TOO_MANY_SESSIONS:
|
||||
return android::ERROR_DRM_RESOURCE_BUSY;
|
||||
case OEMCrypto_ERROR_INVALID_RSA_KEY:
|
||||
return kErrorInvalidKey;
|
||||
case OEMCrypto_ERROR_INSUFFICIENT_RESOURCES:
|
||||
return android::ERROR_DRM_RESOURCE_BUSY;
|
||||
return Status::ERROR_DRM_RESOURCE_BUSY;
|
||||
|
||||
case OEMCrypto_ERROR_NOT_IMPLEMENTED:
|
||||
return android::ERROR_DRM_CANNOT_HANDLE;
|
||||
return Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
|
||||
case OEMCrypto_ERROR_INVALID_RSA_KEY:
|
||||
case OEMCrypto_ERROR_SHORT_BUFFER:
|
||||
ALOGW("Returns UNKNOWN error for legacy status: %d", res);
|
||||
case OEMCrypto_ERROR_UNKNOWN_FAILURE:
|
||||
case OEMCrypto_ERROR_OPEN_SESSION_FAILED:
|
||||
return android::ERROR_DRM_UNKNOWN;
|
||||
default:
|
||||
return android::UNKNOWN_ERROR;
|
||||
return Status::ERROR_DRM_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1342,7 +1355,7 @@ bool WVDrmPlugin::initDataResemblesPSSH(const std::vector<uint8_t>& initData) {
|
||||
return id == kPsshTag;
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::unprovision(const CdmIdentifier& identifier) {
|
||||
Status WVDrmPlugin::unprovision(const CdmIdentifier& identifier) {
|
||||
CdmResponseType res1 = mCDM->Unprovision(wvcdm::kSecurityLevelL1, identifier);
|
||||
CdmResponseType res3 = mCDM->Unprovision(wvcdm::kSecurityLevelL3, identifier);
|
||||
if (!isCdmResponseTypeSuccess(res1))
|
||||
@@ -1364,44 +1377,44 @@ WVDrmPlugin::CdmIdentifierBuilder::CdmIdentifierBuilder(
|
||||
mAppPackageName(appPackageName),
|
||||
mParent(parent) {}
|
||||
|
||||
status_t WVDrmPlugin::CdmIdentifierBuilder::getCdmIdentifier(
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::getCdmIdentifier(
|
||||
CdmIdentifier* identifier) {
|
||||
if (!mIsIdentifierSealed) {
|
||||
status_t res = calculateSpoid();
|
||||
if (res != android::OK) return res;
|
||||
Status res = calculateSpoid();
|
||||
if (res != Status::OK) return res;
|
||||
|
||||
mIsIdentifierSealed = true;
|
||||
}
|
||||
*identifier = mCdmIdentifier;
|
||||
return android::OK;
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::CdmIdentifierBuilder::getDeviceUniqueId(std::string* id) {
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::getDeviceUniqueId(std::string* id) {
|
||||
if (mUseSpoid) {
|
||||
CdmIdentifier identifier;
|
||||
status_t res = getCdmIdentifier(&identifier);
|
||||
if (res != android::OK) return res;
|
||||
Status res = getCdmIdentifier(&identifier);
|
||||
if (res != Status::OK) return res;
|
||||
|
||||
*id = identifier.spoid;
|
||||
return android::OK;
|
||||
return Status::OK;
|
||||
} else {
|
||||
return getOemcryptoDeviceId(id);
|
||||
}
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::CdmIdentifierBuilder::getProvisioningUniqueId(std::string* id) {
|
||||
Status 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_t res = getDeviceUniqueId(id);
|
||||
if (res != android::OK) return res;
|
||||
Status res = getDeviceUniqueId(id);
|
||||
if (res != Status::OK) return res;
|
||||
|
||||
for (char& c : *id) {
|
||||
c = ~c;
|
||||
}
|
||||
|
||||
return android::OK;
|
||||
return Status::OK;
|
||||
} else {
|
||||
return mParent.queryProperty(wvcdm::QUERY_KEY_PROVISIONING_ID, *id);
|
||||
}
|
||||
@@ -1413,11 +1426,11 @@ bool WVDrmPlugin::CdmIdentifierBuilder::set_origin(const std::string& id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid() {
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid() {
|
||||
if (mUseSpoid) {
|
||||
std::string deviceId;
|
||||
status_t res = getOemcryptoDeviceId(&deviceId);
|
||||
if (res != android::OK) return res;
|
||||
Status res = getOemcryptoDeviceId(&deviceId);
|
||||
if (res != Status::OK) return res;
|
||||
|
||||
uint8_t hash[SHA256_DIGEST_LENGTH];
|
||||
SHA256_CTX ctx;
|
||||
@@ -1430,10 +1443,10 @@ status_t WVDrmPlugin::CdmIdentifierBuilder::calculateSpoid() {
|
||||
mCdmIdentifier.spoid =
|
||||
std::string(reinterpret_cast<char*>(hash), SHA256_DIGEST_LENGTH);
|
||||
}
|
||||
return android::OK;
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::CdmIdentifierBuilder::getOemcryptoDeviceId(
|
||||
Status WVDrmPlugin::CdmIdentifierBuilder::getOemcryptoDeviceId(
|
||||
std::string* id) {
|
||||
return mParent.queryProperty(wvcdm::QUERY_KEY_DEVICE_ID, *id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user