1 /*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #define LOG_TAG "VerifiedKey-JNI"
18
19 #include "android_view_VerifiedKeyEvent.h"
20 #include <input/Input.h>
21 #include "core_jni_helpers.h"
22
23 namespace android {
24
25 static struct {
26 jclass clazz;
27
28 jmethodID constructor;
29 } gVerifiedKeyEventClassInfo;
30
31 // ----------------------------------------------------------------------------
32
android_view_VerifiedKeyEvent(JNIEnv * env,const VerifiedKeyEvent & event)33 jobject android_view_VerifiedKeyEvent(JNIEnv* env, const VerifiedKeyEvent& event) {
34 return env->NewObject(gVerifiedKeyEventClassInfo.clazz, gVerifiedKeyEventClassInfo.constructor,
35 event.deviceId, event.eventTimeNanos, event.source, event.displayId,
36 event.action, event.downTimeNanos, event.flags, event.keyCode,
37 event.scanCode, event.metaState, event.repeatCount);
38 }
39
register_android_view_VerifiedKeyEvent(JNIEnv * env)40 int register_android_view_VerifiedKeyEvent(JNIEnv* env) {
41 jclass clazz = FindClassOrDie(env, "android/view/VerifiedKeyEvent");
42 gVerifiedKeyEventClassInfo.clazz = MakeGlobalRefOrDie(env, clazz);
43
44 gVerifiedKeyEventClassInfo.constructor =
45 GetMethodIDOrDie(env, clazz, "<init>", "(IJIIIJIIIII)V");
46
47 return OK;
48 }
49
50 } // namespace android
51