From 9b8724c719997669913b0ccdfb8859d9468b9700 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 2 Dec 2022 00:45:06 +0000 Subject: [PATCH] Convert MotionEvent#getSurfaceRotation to ui::Rotation Because it might have an invalid rotation it needs to return std::optional, but at least we're using the types effectively here. Test: compiles Change-Id: Ib8bd1cf5c1d910c08fa9ff2a8bb7c74f7c51a71d --- core/jni/android_view_MotionEvent.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp index 80df0ead4bcd9..403c5836d9ddc 100644 --- a/core/jni/android_view_MotionEvent.cpp +++ b/core/jni/android_view_MotionEvent.cpp @@ -763,7 +763,12 @@ static void android_view_MotionEvent_nativeScale(jlong nativePtr, jfloat scale) static jint android_view_MotionEvent_nativeGetSurfaceRotation(jlong nativePtr) { MotionEvent* event = reinterpret_cast(nativePtr); - return jint(event->getSurfaceRotation()); + auto rotation = event->getSurfaceRotation(); + if (rotation) { + return static_cast(rotation.value()); + } else { + return -1; + } } // ----------------------------------------------------------------------------