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

Commit d2392b54 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Update KL and KCM usages for new optional outputs

We updated some APIs to return std::optional. Use those APIs here in the
jni code.

Per our docs for MotionEvent and KeyEvent, in the event of failure, we
should be returning -1 and KEYCODE_UNKNOWN, respectively, so update the
code to actually follow this spec.

Bug: 266400536
Test: m
Change-Id: I8e414b1ec104a6458b1bc45b220eb9eeef99df21
parent ac6cd614
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ static jstring android_view_KeyEvent_nativeKeyCodeToString(JNIEnv* env, jobject
static jint android_view_KeyEvent_nativeKeyCodeFromString(JNIEnv* env, jobject clazz,
        jstring label) {
    ScopedUtfChars keyLabel(env, label);
    return KeyEvent::getKeyCodeFromLabel(keyLabel.c_str());
    return KeyEvent::getKeyCodeFromLabel(keyLabel.c_str()).value_or(AKEYCODE_UNKNOWN);
}

static jint android_view_KeyEvent_nativeNextId() {
+1 −1
Original line number Diff line number Diff line
@@ -515,7 +515,7 @@ static jstring android_view_MotionEvent_nativeAxisToString(JNIEnv* env, jclass c
static jint android_view_MotionEvent_nativeAxisFromString(JNIEnv* env, jclass clazz,
        jstring label) {
    ScopedUtfChars axisLabel(env, label);
    return static_cast<jint>(MotionEvent::getAxisFromLabel(axisLabel.c_str()));
    return static_cast<jint>(MotionEvent::getAxisFromLabel(axisLabel.c_str()).value_or(-1));
}

// ---------------- @FastNative ----------------------------------