Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 "DisplayEventReceiver" |
| 18 | |
| 19 | //#define LOG_NDEBUG 0 |
| 20 | |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 21 | #include "JNIHelp.h" |
| 22 | |
Dan Albert | 46d8444 | 2014-11-18 16:07:51 -0800 | [diff] [blame] | 23 | #include <inttypes.h> |
| 24 | |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 25 | #include <android_runtime/AndroidRuntime.h> |
| 26 | #include <utils/Log.h> |
| 27 | #include <utils/Looper.h> |
| 28 | #include <utils/threads.h> |
| 29 | #include <gui/DisplayEventReceiver.h> |
| 30 | #include "android_os_MessageQueue.h" |
| 31 | |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 32 | #include <ScopedLocalRef.h> |
| 33 | |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 34 | #include "core_jni_helpers.h" |
| 35 | |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 36 | namespace android { |
| 37 | |
| 38 | // Number of events to read at a time from the DisplayEventReceiver pipe. |
| 39 | // The value should be large enough that we can quickly drain the pipe |
| 40 | // using just a few large reads. |
| 41 | static const size_t EVENT_BUFFER_SIZE = 100; |
| 42 | |
| 43 | static struct { |
| 44 | jclass clazz; |
| 45 | |
| 46 | jmethodID dispatchVsync; |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 47 | jmethodID dispatchHotplug; |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 48 | } gDisplayEventReceiverClassInfo; |
| 49 | |
| 50 | |
Jeff Brown | 80a1de1 | 2012-05-31 16:23:11 -0700 | [diff] [blame] | 51 | class NativeDisplayEventReceiver : public LooperCallback { |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 52 | public: |
| 53 | NativeDisplayEventReceiver(JNIEnv* env, |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 54 | jobject receiverWeak, const sp<MessageQueue>& messageQueue); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 55 | |
| 56 | status_t initialize(); |
Jeff Brown | 80a1de1 | 2012-05-31 16:23:11 -0700 | [diff] [blame] | 57 | void dispose(); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 58 | status_t scheduleVsync(); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 59 | |
| 60 | protected: |
| 61 | virtual ~NativeDisplayEventReceiver(); |
| 62 | |
| 63 | private: |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 64 | jobject mReceiverWeakGlobal; |
Jeff Brown | 603b445 | 2012-04-06 17:39:41 -0700 | [diff] [blame] | 65 | sp<MessageQueue> mMessageQueue; |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 66 | DisplayEventReceiver mReceiver; |
| 67 | bool mWaitingForVsync; |
Jeff Brown | bec0a86 | 2012-03-29 12:42:31 -0700 | [diff] [blame] | 68 | |
Jeff Brown | 80a1de1 | 2012-05-31 16:23:11 -0700 | [diff] [blame] | 69 | virtual int handleEvent(int receiveFd, int events, void* data); |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 70 | bool processPendingEvents(nsecs_t* outTimestamp, int32_t* id, uint32_t* outCount); |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 71 | void dispatchVsync(nsecs_t timestamp, int32_t id, uint32_t count); |
| 72 | void dispatchHotplug(nsecs_t timestamp, int32_t id, bool connected); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | |
| 76 | NativeDisplayEventReceiver::NativeDisplayEventReceiver(JNIEnv* env, |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 77 | jobject receiverWeak, const sp<MessageQueue>& messageQueue) : |
| 78 | mReceiverWeakGlobal(env->NewGlobalRef(receiverWeak)), |
Jeff Brown | 603b445 | 2012-04-06 17:39:41 -0700 | [diff] [blame] | 79 | mMessageQueue(messageQueue), mWaitingForVsync(false) { |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 80 | ALOGV("receiver %p ~ Initializing input event receiver.", this); |
| 81 | } |
| 82 | |
| 83 | NativeDisplayEventReceiver::~NativeDisplayEventReceiver() { |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 84 | JNIEnv* env = AndroidRuntime::getJNIEnv(); |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 85 | env->DeleteGlobalRef(mReceiverWeakGlobal); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | status_t NativeDisplayEventReceiver::initialize() { |
| 89 | status_t result = mReceiver.initCheck(); |
| 90 | if (result) { |
Steve Block | 8564c8d | 2012-01-05 23:22:43 +0000 | [diff] [blame] | 91 | ALOGW("Failed to initialize display event receiver, status=%d", result); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 92 | return result; |
| 93 | } |
| 94 | |
Brian Carlstrom | 82b007d | 2013-12-12 23:12:55 -0800 | [diff] [blame] | 95 | int rc = mMessageQueue->getLooper()->addFd(mReceiver.getFd(), 0, Looper::EVENT_INPUT, |
Jeff Brown | 80a1de1 | 2012-05-31 16:23:11 -0700 | [diff] [blame] | 96 | this, NULL); |
Jeff Brown | 58aedbc | 2012-02-13 20:15:01 -0800 | [diff] [blame] | 97 | if (rc < 0) { |
| 98 | return UNKNOWN_ERROR; |
| 99 | } |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 100 | return OK; |
| 101 | } |
| 102 | |
Jeff Brown | 80a1de1 | 2012-05-31 16:23:11 -0700 | [diff] [blame] | 103 | void NativeDisplayEventReceiver::dispose() { |
| 104 | ALOGV("receiver %p ~ Disposing display event receiver.", this); |
| 105 | |
| 106 | if (!mReceiver.initCheck()) { |
| 107 | mMessageQueue->getLooper()->removeFd(mReceiver.getFd()); |
| 108 | } |
| 109 | } |
| 110 | |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 111 | status_t NativeDisplayEventReceiver::scheduleVsync() { |
| 112 | if (!mWaitingForVsync) { |
| 113 | ALOGV("receiver %p ~ Scheduling vsync.", this); |
| 114 | |
| 115 | // Drain all pending events. |
Jeff Brown | bec0a86 | 2012-03-29 12:42:31 -0700 | [diff] [blame] | 116 | nsecs_t vsyncTimestamp; |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 117 | int32_t vsyncDisplayId; |
Jeff Brown | bec0a86 | 2012-03-29 12:42:31 -0700 | [diff] [blame] | 118 | uint32_t vsyncCount; |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 119 | processPendingEvents(&vsyncTimestamp, &vsyncDisplayId, &vsyncCount); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 120 | |
Mathias Agopian | 6779df2 | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 121 | status_t status = mReceiver.requestNextVsync(); |
| 122 | if (status) { |
Steve Block | 8564c8d | 2012-01-05 23:22:43 +0000 | [diff] [blame] | 123 | ALOGW("Failed to request next vsync, status=%d", status); |
Mathias Agopian | 6779df2 | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 124 | return status; |
| 125 | } |
| 126 | |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 127 | mWaitingForVsync = true; |
| 128 | } |
| 129 | return OK; |
| 130 | } |
| 131 | |
Jeff Brown | 80a1de1 | 2012-05-31 16:23:11 -0700 | [diff] [blame] | 132 | int NativeDisplayEventReceiver::handleEvent(int receiveFd, int events, void* data) { |
Brian Carlstrom | 82b007d | 2013-12-12 23:12:55 -0800 | [diff] [blame] | 133 | if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 134 | ALOGE("Display event receiver pipe was closed or an error occurred. " |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 135 | "events=0x%x", events); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 136 | return 0; // remove the callback |
| 137 | } |
| 138 | |
Brian Carlstrom | 82b007d | 2013-12-12 23:12:55 -0800 | [diff] [blame] | 139 | if (!(events & Looper::EVENT_INPUT)) { |
Steve Block | 8564c8d | 2012-01-05 23:22:43 +0000 | [diff] [blame] | 140 | ALOGW("Received spurious callback for unhandled poll event. " |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 141 | "events=0x%x", events); |
| 142 | return 1; // keep the callback |
| 143 | } |
| 144 | |
| 145 | // Drain all pending events, keep the last vsync. |
Jeff Brown | bec0a86 | 2012-03-29 12:42:31 -0700 | [diff] [blame] | 146 | nsecs_t vsyncTimestamp; |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 147 | int32_t vsyncDisplayId; |
Jeff Brown | bec0a86 | 2012-03-29 12:42:31 -0700 | [diff] [blame] | 148 | uint32_t vsyncCount; |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 149 | if (processPendingEvents(&vsyncTimestamp, &vsyncDisplayId, &vsyncCount)) { |
Dan Albert | 46d8444 | 2014-11-18 16:07:51 -0800 | [diff] [blame] | 150 | ALOGV("receiver %p ~ Vsync pulse: timestamp=%" PRId64 ", id=%d, count=%d", |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 151 | this, vsyncTimestamp, vsyncDisplayId, vsyncCount); |
| 152 | mWaitingForVsync = false; |
| 153 | dispatchVsync(vsyncTimestamp, vsyncDisplayId, vsyncCount); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 154 | } |
| 155 | |
Jeff Brown | 58aedbc | 2012-02-13 20:15:01 -0800 | [diff] [blame] | 156 | return 1; // keep the callback |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 157 | } |
| 158 | |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 159 | bool NativeDisplayEventReceiver::processPendingEvents( |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 160 | nsecs_t* outTimestamp, int32_t* outId, uint32_t* outCount) { |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 161 | bool gotVsync = false; |
Jeff Brown | bec0a86 | 2012-03-29 12:42:31 -0700 | [diff] [blame] | 162 | DisplayEventReceiver::Event buf[EVENT_BUFFER_SIZE]; |
| 163 | ssize_t n; |
| 164 | while ((n = mReceiver.getEvents(buf, EVENT_BUFFER_SIZE)) > 0) { |
| 165 | ALOGV("receiver %p ~ Read %d events.", this, int(n)); |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 166 | for (ssize_t i = 0; i < n; i++) { |
| 167 | const DisplayEventReceiver::Event& ev = buf[i]; |
| 168 | switch (ev.header.type) { |
| 169 | case DisplayEventReceiver::DISPLAY_EVENT_VSYNC: |
| 170 | // Later vsync events will just overwrite the info from earlier |
| 171 | // ones. That's fine, we only care about the most recent. |
| 172 | gotVsync = true; |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 173 | *outTimestamp = ev.header.timestamp; |
| 174 | *outId = ev.header.id; |
| 175 | *outCount = ev.vsync.count; |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 176 | break; |
| 177 | case DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG: |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 178 | dispatchHotplug(ev.header.timestamp, ev.header.id, ev.hotplug.connected); |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 179 | break; |
| 180 | default: |
| 181 | ALOGW("receiver %p ~ ignoring unknown event type %#x", this, ev.header.type); |
| 182 | break; |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 183 | } |
Jeff Brown | bec0a86 | 2012-03-29 12:42:31 -0700 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | if (n < 0) { |
| 187 | ALOGW("Failed to get events from display event receiver, status=%d", status_t(n)); |
| 188 | } |
Jesse Hall | 16823bd | 2012-11-19 10:53:26 -0800 | [diff] [blame] | 189 | return gotVsync; |
Jeff Brown | bec0a86 | 2012-03-29 12:42:31 -0700 | [diff] [blame] | 190 | } |
| 191 | |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 192 | void NativeDisplayEventReceiver::dispatchVsync(nsecs_t timestamp, int32_t id, uint32_t count) { |
| 193 | JNIEnv* env = AndroidRuntime::getJNIEnv(); |
| 194 | |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 195 | ScopedLocalRef<jobject> receiverObj(env, jniGetReferent(env, mReceiverWeakGlobal)); |
| 196 | if (receiverObj.get()) { |
| 197 | ALOGV("receiver %p ~ Invoking vsync handler.", this); |
| 198 | env->CallVoidMethod(receiverObj.get(), |
| 199 | gDisplayEventReceiverClassInfo.dispatchVsync, timestamp, id, count); |
| 200 | ALOGV("receiver %p ~ Returned from vsync handler.", this); |
| 201 | } |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 202 | |
| 203 | mMessageQueue->raiseAndClearException(env, "dispatchVsync"); |
| 204 | } |
| 205 | |
| 206 | void NativeDisplayEventReceiver::dispatchHotplug(nsecs_t timestamp, int32_t id, bool connected) { |
| 207 | JNIEnv* env = AndroidRuntime::getJNIEnv(); |
| 208 | |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 209 | ScopedLocalRef<jobject> receiverObj(env, jniGetReferent(env, mReceiverWeakGlobal)); |
| 210 | if (receiverObj.get()) { |
| 211 | ALOGV("receiver %p ~ Invoking hotplug handler.", this); |
| 212 | env->CallVoidMethod(receiverObj.get(), |
| 213 | gDisplayEventReceiverClassInfo.dispatchHotplug, timestamp, id, connected); |
| 214 | ALOGV("receiver %p ~ Returned from hotplug handler.", this); |
| 215 | } |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 216 | |
| 217 | mMessageQueue->raiseAndClearException(env, "dispatchHotplug"); |
| 218 | } |
| 219 | |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 220 | |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 221 | static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak, |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 222 | jobject messageQueueObj) { |
Jeff Brown | 603b445 | 2012-04-06 17:39:41 -0700 | [diff] [blame] | 223 | sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj); |
| 224 | if (messageQueue == NULL) { |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 225 | jniThrowRuntimeException(env, "MessageQueue is not initialized."); |
| 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | sp<NativeDisplayEventReceiver> receiver = new NativeDisplayEventReceiver(env, |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 230 | receiverWeak, messageQueue); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 231 | status_t status = receiver->initialize(); |
| 232 | if (status) { |
| 233 | String8 message; |
| 234 | message.appendFormat("Failed to initialize display event receiver. status=%d", status); |
| 235 | jniThrowRuntimeException(env, message.string()); |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | receiver->incStrong(gDisplayEventReceiverClassInfo.clazz); // retain a reference for the object |
Ashok Bhat | 2728582 | 2013-12-18 18:00:05 +0000 | [diff] [blame] | 240 | return reinterpret_cast<jlong>(receiver.get()); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 241 | } |
| 242 | |
Ashok Bhat | 2728582 | 2013-12-18 18:00:05 +0000 | [diff] [blame] | 243 | static void nativeDispose(JNIEnv* env, jclass clazz, jlong receiverPtr) { |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 244 | sp<NativeDisplayEventReceiver> receiver = |
| 245 | reinterpret_cast<NativeDisplayEventReceiver*>(receiverPtr); |
Jeff Brown | 80a1de1 | 2012-05-31 16:23:11 -0700 | [diff] [blame] | 246 | receiver->dispose(); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 247 | receiver->decStrong(gDisplayEventReceiverClassInfo.clazz); // drop reference held by the object |
| 248 | } |
| 249 | |
Ashok Bhat | 2728582 | 2013-12-18 18:00:05 +0000 | [diff] [blame] | 250 | static void nativeScheduleVsync(JNIEnv* env, jclass clazz, jlong receiverPtr) { |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 251 | sp<NativeDisplayEventReceiver> receiver = |
| 252 | reinterpret_cast<NativeDisplayEventReceiver*>(receiverPtr); |
| 253 | status_t status = receiver->scheduleVsync(); |
| 254 | if (status) { |
| 255 | String8 message; |
| 256 | message.appendFormat("Failed to schedule next vertical sync pulse. status=%d", status); |
| 257 | jniThrowRuntimeException(env, message.string()); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | |
| 262 | static JNINativeMethod gMethods[] = { |
| 263 | /* name, signature, funcPtr */ |
| 264 | { "nativeInit", |
Jeff Brown | 3b4049e | 2015-04-17 15:22:27 -0700 | [diff] [blame] | 265 | "(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;)J", |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 266 | (void*)nativeInit }, |
| 267 | { "nativeDispose", |
Ashok Bhat | 2728582 | 2013-12-18 18:00:05 +0000 | [diff] [blame] | 268 | "(J)V", |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 269 | (void*)nativeDispose }, |
Ashok Bhat | 2728582 | 2013-12-18 18:00:05 +0000 | [diff] [blame] | 270 | { "nativeScheduleVsync", "(J)V", |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 271 | (void*)nativeScheduleVsync } |
| 272 | }; |
| 273 | |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 274 | int register_android_view_DisplayEventReceiver(JNIEnv* env) { |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 275 | int res = RegisterMethodsOrDie(env, "android/view/DisplayEventReceiver", gMethods, |
| 276 | NELEM(gMethods)); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 277 | |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 278 | jclass clazz = FindClassOrDie(env, "android/view/DisplayEventReceiver"); |
| 279 | gDisplayEventReceiverClassInfo.clazz = MakeGlobalRefOrDie(env, clazz); |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 280 | |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 281 | gDisplayEventReceiverClassInfo.dispatchVsync = GetMethodIDOrDie(env, |
| 282 | gDisplayEventReceiverClassInfo.clazz, "dispatchVsync", "(JII)V"); |
| 283 | gDisplayEventReceiverClassInfo.dispatchHotplug = GetMethodIDOrDie(env, |
| 284 | gDisplayEventReceiverClassInfo.clazz, "dispatchHotplug", "(JIZ)V"); |
| 285 | |
| 286 | return res; |
Jeff Brown | 0a0a124 | 2011-12-02 02:25:22 -0800 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | } // namespace android |