Loading core/java/android/os/ServiceManager.java +6 −1 Original line number Original line Diff line number Diff line Loading @@ -257,7 +257,12 @@ public final class ServiceManager { * * * @return {@code null} only if there are permission problems or fatal errors. * @return {@code null} only if there are permission problems or fatal errors. */ */ public static native IBinder waitForService(@NonNull String name); public static IBinder waitForService(@NonNull String name) { return Binder.allowBlocking(waitForServiceNative(name)); } private static native IBinder waitForServiceNative(@NonNull String name); /** /** * Returns the specified service from the service manager, if declared. * Returns the specified service from the service manager, if declared. Loading core/jni/android_os_ServiceManager.cpp +5 −11 Original line number Original line Diff line number Diff line Loading @@ -29,11 +29,8 @@ namespace android { // Native because we have a client-side wait in waitForService() and we do not // Native because we have a client-side wait in waitForService() and we do not // want an unnecessary second copy of it. // want an unnecessary second copy of it. static jobject android_os_ServiceManager_waitForService( static jobject android_os_ServiceManager_waitForServiceNative(JNIEnv* env, jclass /* clazzObj */, JNIEnv *env, jclass /* clazzObj */, jstring serviceNameObj) { jstring serviceNameObj) { const jchar* serviceName = env->GetStringCritical(serviceNameObj, nullptr); const jchar* serviceName = env->GetStringCritical(serviceNameObj, nullptr); if (!serviceName) { if (!serviceName) { jniThrowNullPointerException(env, nullptr); jniThrowNullPointerException(env, nullptr); Loading @@ -56,11 +53,8 @@ static jobject android_os_ServiceManager_waitForService( static const JNINativeMethod method_table[] = { static const JNINativeMethod method_table[] = { /* name, signature, funcPtr */ /* name, signature, funcPtr */ { {"waitForServiceNative", "(Ljava/lang/String;)Landroid/os/IBinder;", "waitForService", (void*)android_os_ServiceManager_waitForServiceNative}, "(Ljava/lang/String;)Landroid/os/IBinder;", (void*)android_os_ServiceManager_waitForService }, }; }; int register_android_os_ServiceManager(JNIEnv* env) { int register_android_os_ServiceManager(JNIEnv* env) { Loading Loading
core/java/android/os/ServiceManager.java +6 −1 Original line number Original line Diff line number Diff line Loading @@ -257,7 +257,12 @@ public final class ServiceManager { * * * @return {@code null} only if there are permission problems or fatal errors. * @return {@code null} only if there are permission problems or fatal errors. */ */ public static native IBinder waitForService(@NonNull String name); public static IBinder waitForService(@NonNull String name) { return Binder.allowBlocking(waitForServiceNative(name)); } private static native IBinder waitForServiceNative(@NonNull String name); /** /** * Returns the specified service from the service manager, if declared. * Returns the specified service from the service manager, if declared. Loading
core/jni/android_os_ServiceManager.cpp +5 −11 Original line number Original line Diff line number Diff line Loading @@ -29,11 +29,8 @@ namespace android { // Native because we have a client-side wait in waitForService() and we do not // Native because we have a client-side wait in waitForService() and we do not // want an unnecessary second copy of it. // want an unnecessary second copy of it. static jobject android_os_ServiceManager_waitForService( static jobject android_os_ServiceManager_waitForServiceNative(JNIEnv* env, jclass /* clazzObj */, JNIEnv *env, jclass /* clazzObj */, jstring serviceNameObj) { jstring serviceNameObj) { const jchar* serviceName = env->GetStringCritical(serviceNameObj, nullptr); const jchar* serviceName = env->GetStringCritical(serviceNameObj, nullptr); if (!serviceName) { if (!serviceName) { jniThrowNullPointerException(env, nullptr); jniThrowNullPointerException(env, nullptr); Loading @@ -56,11 +53,8 @@ static jobject android_os_ServiceManager_waitForService( static const JNINativeMethod method_table[] = { static const JNINativeMethod method_table[] = { /* name, signature, funcPtr */ /* name, signature, funcPtr */ { {"waitForServiceNative", "(Ljava/lang/String;)Landroid/os/IBinder;", "waitForService", (void*)android_os_ServiceManager_waitForServiceNative}, "(Ljava/lang/String;)Landroid/os/IBinder;", (void*)android_os_ServiceManager_waitForService }, }; }; int register_android_os_ServiceManager(JNIEnv* env) { int register_android_os_ServiceManager(JNIEnv* env) { Loading