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

Commit 6a4382ad authored by Patrick Williams's avatar Patrick Williams Committed by Automerger Merge Worker
Browse files

Merge "Check exceptions in BBQ and SC JNI code" into udc-dev am: f2ec83ae

parents 0baa1607 f2ec83ae
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -72,12 +72,14 @@ public:
    }

    void onTransactionHang(const std::string& reason) {
        if (mTransactionHangObject) {
        if (!mTransactionHangObject) {
            return;
        }
        JNIEnv* env = getenv(mVm);
        ScopedLocalRef<jstring> jReason(env, env->NewStringUTF(reason.c_str()));
        getenv(mVm)->CallVoidMethod(mTransactionHangObject,
                                    gTransactionHangCallback.onTransactionHang, jReason.get());
        }
        DieIfException(env, "Uncaught exception in TransactionHangCallback.");
    }

private:
+3 −0
Original line number Diff line number Diff line
@@ -285,6 +285,7 @@ public:
        JNIEnv* env = getenv();
        env->CallVoidMethod(mTransactionCommittedListenerObject,
                            gTransactionCommittedListenerClassInfo.onTransactionCommitted);
        DieIfException(env, "Uncaught exception in TransactionCommittedListener.");
    }

    static void transactionCallbackThunk(void* context, nsecs_t /*latchTime*/,
@@ -325,6 +326,7 @@ public:
    binder::Status onWindowInfosReported() override {
        JNIEnv* env = getenv();
        env->CallVoidMethod(mListener, gRunnableClassInfo.run);
        DieIfException(env, "Uncaught exception in WindowInfosReportedListener.");
        return binder::Status::ok();
    }

@@ -356,6 +358,7 @@ public:
        env->CallVoidMethod(mTrustedPresentationCallback,
                            gTrustedPresentationCallbackClassInfo.onTrustedPresentationChanged,
                            inTrustedPresentationState);
        DieIfException(env, "Uncaught exception in TrustedPresentationCallback.");
    }

    void addCallbackRef(const sp<SurfaceComposerClient::PresentationCallbackRAII>& callbackRef) {
+9 −0
Original line number Diff line number Diff line
@@ -134,6 +134,15 @@ static inline JNIEnv* GetOrAttachJNIEnvironment(JavaVM* jvm, jint version = JNI_
    return env;
}

static inline void DieIfException(JNIEnv* env, const char* message) {
    if (env->ExceptionCheck()) {
        jnihelp::ExpandableString summary;
        jnihelp::ExpandableStringInitialize(&summary);
        jnihelp::GetStackTraceOrSummary(env, nullptr, &summary);
        LOG_ALWAYS_FATAL("%s\n%s", message, summary.data);
    }
}

}  // namespace android

#endif  // CORE_JNI_HELPERS