Convert MotionEvent#getSurfaceRotation to ui::Rotation

Because it might have an invalid rotation it needs to return
std::optional<ui::Rotation>, but at least we're using the types
effectively here.

Test: compiles
Change-Id: Ib8bd1cf5c1d910c08fa9ff2a8bb7c74f7c51a71d
This commit is contained in:
Michael Wright
2022-12-02 00:45:06 +00:00
parent ecde4d0883
commit 9b8724c719

View File

@@ -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<MotionEvent*>(nativePtr);
return jint(event->getSurfaceRotation());
auto rotation = event->getSurfaceRotation();
if (rotation) {
return static_cast<jint>(rotation.value());
} else {
return -1;
}
}
// ----------------------------------------------------------------------------