From bef3988921ece2076e441c2c1253755627760ea4 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 13 Jun 2017 18:20:09 -0700 Subject: [PATCH] SensorManager: attach background thread to JavaVM Test: pass Bug: 62404135 Change-Id: Ic3c0849cd366f550cbdccbb9bb8d082c5c570c35 --- services/core/jni/com_android_server_SystemServer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/core/jni/com_android_server_SystemServer.cpp b/services/core/jni/com_android_server_SystemServer.cpp index 96c2d7e382328..470cc572e3e58 100644 --- a/services/core/jni/com_android_server_SystemServer.cpp +++ b/services/core/jni/com_android_server_SystemServer.cpp @@ -39,7 +39,7 @@ static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jo } -static void android_server_SystemServer_startHidlServices(JNIEnv* /* env */, jobject /* clazz */) { +static void android_server_SystemServer_startHidlServices(JNIEnv* env, jobject /* clazz */) { using ::android::frameworks::schedulerservice::V1_0::ISchedulingPolicyService; using ::android::frameworks::schedulerservice::V1_0::implementation::SchedulingPolicyService; using ::android::frameworks::sensorservice::V1_0::ISensorManager; @@ -50,7 +50,10 @@ static void android_server_SystemServer_startHidlServices(JNIEnv* /* env */, job configureRpcThreadpool(5, false /* callerWillJoin */); - sp sensorService = new SensorManager(); + JavaVM *vm; + LOG_ALWAYS_FATAL_IF(env->GetJavaVM(&vm) != JNI_OK, "Cannot get Java VM"); + + sp sensorService = new SensorManager(vm); err = sensorService->registerAsService(); ALOGE_IF(err != OK, "Cannot register %s: %d", ISensorManager::descriptor, err);