Merge "MediaCodec: throw CryptoException with more error info" am: 4cbe13c73f

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2362899

Change-Id: Ib85b0d8d27951cbfbba46badcf0474e3ec3b71c3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Robert Shih
2022-12-20 09:45:23 +00:00
committed by Automerger Merge Worker

View File

@@ -1285,7 +1285,7 @@ static void throwCryptoException(JNIEnv *env, status_t err, const char *msg,
CHECK(clazz.get() != NULL); CHECK(clazz.get() != NULL);
jmethodID constructID = jmethodID constructID =
env->GetMethodID(clazz.get(), "<init>", "(ILjava/lang/String;)V"); env->GetMethodID(clazz.get(), "<init>", "(Ljava/lang/String;IIII)V");
CHECK(constructID != NULL); CHECK(constructID != NULL);
std::string defaultMsg = "Unknown Error"; std::string defaultMsg = "Unknown Error";
@@ -1335,14 +1335,14 @@ static void throwCryptoException(JNIEnv *env, status_t err, const char *msg,
break; break;
} }
std::string msgStr(msg != NULL ? msg : defaultMsg.c_str()); std::string originalMsg(msg != NULL ? msg : defaultMsg.c_str());
if (crypto != NULL) { DrmStatus dStatus(err, originalMsg.c_str());
msgStr = DrmUtils::GetExceptionMessage(err, msgStr.c_str(), crypto); std::string detailedMsg(DrmUtils::GetExceptionMessage(dStatus, defaultMsg.c_str(), crypto));
} jstring msgObj = env->NewStringUTF(detailedMsg.c_str());
jstring msgObj = env->NewStringUTF(msgStr.c_str());
jthrowable exception = jthrowable exception =
(jthrowable)env->NewObject(clazz.get(), constructID, jerr, msgObj); (jthrowable)env->NewObject(clazz.get(), constructID, msgObj, jerr,
dStatus.getCdmErr(), dStatus.getOemErr(), dStatus.getContext());
env->Throw(exception); env->Throw(exception);
} }