1 /*
2 * Copyright (C) 2010 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 #include <poll.h>
18
19 #include <string>
20
21 #include "core_jni_helpers.h"
22
23 extern "C" void android_dlwarning(void*, void (*)(void*, const char*));
24
25 namespace android
26 {
27
getDlWarning_native(JNIEnv * env,jobject)28 static jstring getDlWarning_native(JNIEnv* env, jobject) {
29 std::string msg;
30 android_dlwarning(&msg, [](void* obj, const char* msg) {
31 if (msg != nullptr) {
32 *reinterpret_cast<std::string*>(obj) = msg;
33 }
34 });
35
36 return msg.empty() ? nullptr : env->NewStringUTF(msg.c_str());
37 }
38
39 static const JNINativeMethod g_methods[] = {
40 { "getDlWarning",
41 "()Ljava/lang/String;",
42 reinterpret_cast<void*>(getDlWarning_native) },
43 };
44
45 static const char* const kActivityPathName = "android/app/Activity";
46
register_android_app_Activity(JNIEnv * env)47 int register_android_app_Activity(JNIEnv* env) {
48 return RegisterMethodsOrDie(env, kActivityPathName, g_methods, NELEM(g_methods));
49 }
50
51 } // namespace android
52