Loading drm/libmediadrm/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ cc_library { "CryptoHalAidl.cpp", "DrmUtils.cpp", "DrmHalListener.cpp", "DrmStatus.cpp", ], local_include_dirs: [ Loading drm/libmediadrm/DrmStatus.cpp 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <mediadrm/DrmStatus.h> #include <json/json.h> namespace android { DrmStatus::DrmStatus(status_t err, const char *msg) : mStatus(err) { Json::Value errorDetails; Json::Reader reader; if (!reader.parse(msg, errorDetails)) { mErrMsg = msg; return; } std::string errMsg; auto val = errorDetails["cdmError"]; if (!val.isNull()) { mCdmErr = val.asInt(); } val = errorDetails["oemError"]; if (!val.isNull()) { mOemErr = val.asInt(); } val = errorDetails["context"]; if (!val.isNull()) { mCtx = val.asInt(); } val = errorDetails["errorMessage"]; if (!val.isNull()) { mErrMsg = val.asString(); } else { mErrMsg = msg; } } } // namespace android drm/libmediadrm/DrmUtils.cpp +1 −25 Original line number Diff line number Diff line Loading @@ -548,31 +548,7 @@ DrmStatus statusAidlToDrmStatus(::ndk::ScopedAStatus& statusAidl) { break; } Json::Value errorDetails; Json::Reader reader; if (!reader.parse(statusAidl.getMessage(), errorDetails)) { return status; } int32_t cdmErr{}, oemErr{}, ctx{}; std::string errMsg; auto val = errorDetails["cdmError"]; if (!val.isNull()) { cdmErr = val.asInt(); } val = errorDetails["oemError"]; if (!val.isNull()) { oemErr = val.asInt(); } val = errorDetails["context"]; if (!val.isNull()) { ctx = val.asInt(); } val = errorDetails["errorMessage"]; if (!val.isNull()) { errMsg = val.asString(); } return DrmStatus(status, cdmErr, oemErr, ctx, errMsg); return DrmStatus(status, statusAidl.getMessage()); } LogBuffer gLogBuf; Loading drm/libmediadrm/include/mediadrm/DrmStatus.h +2 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ struct DrmStatus { int32_t ctx = 0, std::string errMsg = "") : mStatus(status), mCdmErr(cdmErr), mOemErr(oemErr), mCtx(ctx), mErrMsg(errMsg) {} DrmStatus(status_t err, const char *msg); operator status_t() const { return mStatus; } int32_t getCdmErr() const { return mCdmErr; } int32_t getOemErr() const { return mOemErr; } Loading @@ -41,7 +42,7 @@ struct DrmStatus { bool operator!=(status_t other) const { return mStatus != other; } private: status_t mStatus; status_t mStatus{}; int32_t mCdmErr{}, mOemErr{}, mCtx{}; std::string mErrMsg; }; Loading drm/libmediadrm/interface/mediadrm/DrmUtils.h +3 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,9 @@ std::string GetExceptionMessage(const DrmStatus & err, const char *defaultMsg, template<typename T> std::string GetExceptionMessage(const DrmStatus &err, const char *defaultMsg, const sp<T> &iface) { Vector<::V1_4::LogMessage> logs; if (iface != NULL) { iface->getLogMessages(logs); } return GetExceptionMessage(err, defaultMsg, logs); } Loading Loading
drm/libmediadrm/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ cc_library { "CryptoHalAidl.cpp", "DrmUtils.cpp", "DrmHalListener.cpp", "DrmStatus.cpp", ], local_include_dirs: [ Loading
drm/libmediadrm/DrmStatus.cpp 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <mediadrm/DrmStatus.h> #include <json/json.h> namespace android { DrmStatus::DrmStatus(status_t err, const char *msg) : mStatus(err) { Json::Value errorDetails; Json::Reader reader; if (!reader.parse(msg, errorDetails)) { mErrMsg = msg; return; } std::string errMsg; auto val = errorDetails["cdmError"]; if (!val.isNull()) { mCdmErr = val.asInt(); } val = errorDetails["oemError"]; if (!val.isNull()) { mOemErr = val.asInt(); } val = errorDetails["context"]; if (!val.isNull()) { mCtx = val.asInt(); } val = errorDetails["errorMessage"]; if (!val.isNull()) { mErrMsg = val.asString(); } else { mErrMsg = msg; } } } // namespace android
drm/libmediadrm/DrmUtils.cpp +1 −25 Original line number Diff line number Diff line Loading @@ -548,31 +548,7 @@ DrmStatus statusAidlToDrmStatus(::ndk::ScopedAStatus& statusAidl) { break; } Json::Value errorDetails; Json::Reader reader; if (!reader.parse(statusAidl.getMessage(), errorDetails)) { return status; } int32_t cdmErr{}, oemErr{}, ctx{}; std::string errMsg; auto val = errorDetails["cdmError"]; if (!val.isNull()) { cdmErr = val.asInt(); } val = errorDetails["oemError"]; if (!val.isNull()) { oemErr = val.asInt(); } val = errorDetails["context"]; if (!val.isNull()) { ctx = val.asInt(); } val = errorDetails["errorMessage"]; if (!val.isNull()) { errMsg = val.asString(); } return DrmStatus(status, cdmErr, oemErr, ctx, errMsg); return DrmStatus(status, statusAidl.getMessage()); } LogBuffer gLogBuf; Loading
drm/libmediadrm/include/mediadrm/DrmStatus.h +2 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ struct DrmStatus { int32_t ctx = 0, std::string errMsg = "") : mStatus(status), mCdmErr(cdmErr), mOemErr(oemErr), mCtx(ctx), mErrMsg(errMsg) {} DrmStatus(status_t err, const char *msg); operator status_t() const { return mStatus; } int32_t getCdmErr() const { return mCdmErr; } int32_t getOemErr() const { return mOemErr; } Loading @@ -41,7 +42,7 @@ struct DrmStatus { bool operator!=(status_t other) const { return mStatus != other; } private: status_t mStatus; status_t mStatus{}; int32_t mCdmErr{}, mOemErr{}, mCtx{}; std::string mErrMsg; }; Loading
drm/libmediadrm/interface/mediadrm/DrmUtils.h +3 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,9 @@ std::string GetExceptionMessage(const DrmStatus & err, const char *defaultMsg, template<typename T> std::string GetExceptionMessage(const DrmStatus &err, const char *defaultMsg, const sp<T> &iface) { Vector<::V1_4::LogMessage> logs; if (iface != NULL) { iface->getLogMessages(logs); } return GetExceptionMessage(err, defaultMsg, logs); } Loading