Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4cbe13c7 authored by Robert Shih's avatar Robert Shih Committed by Gerrit Code Review
Browse files

Merge "MediaCodec: throw CryptoException with more error info"

parents 319863cc 57f369a0
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1285,7 +1285,7 @@ static void throwCryptoException(JNIEnv *env, status_t err, const char *msg,
    CHECK(clazz.get() != NULL);

    jmethodID constructID =
        env->GetMethodID(clazz.get(), "<init>", "(ILjava/lang/String;)V");
        env->GetMethodID(clazz.get(), "<init>", "(Ljava/lang/String;IIII)V");
    CHECK(constructID != NULL);

    std::string defaultMsg = "Unknown Error";
@@ -1335,14 +1335,14 @@ static void throwCryptoException(JNIEnv *env, status_t err, const char *msg,
            break;
    }

    std::string msgStr(msg != NULL ? msg : defaultMsg.c_str());
    if (crypto != NULL) {
        msgStr = DrmUtils::GetExceptionMessage(err, msgStr.c_str(), crypto);
    }
    jstring msgObj = env->NewStringUTF(msgStr.c_str());
    std::string originalMsg(msg != NULL ? msg : defaultMsg.c_str());
    DrmStatus dStatus(err, originalMsg.c_str());
    std::string detailedMsg(DrmUtils::GetExceptionMessage(dStatus, defaultMsg.c_str(), crypto));
    jstring msgObj = env->NewStringUTF(detailedMsg.c_str());

    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);
}