Loading services/core/jni/Android.mk +3 −1 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ LOCAL_SHARED_LIBRARIES += \ libinputflinger \ libinputservice \ libsensorservice \ libsensorservicehidl \ libskia \ libgui \ libusbhost \ Loading @@ -88,5 +89,6 @@ LOCAL_SHARED_LIBRARIES += \ android.hardware.tv.input@1.0 \ android.hardware.vibrator@1.0 \ android.hardware.vr@1.0 \ android.frameworks.sensorservice@1.0 \ LOCAL_STATIC_LIBRARIES += libscrypt_static services/core/jni/com_android_server_SystemServer.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,10 @@ #include <jni.h> #include <JNIHelp.h> #include <hidl/HidlTransportSupport.h> #include <sensorservice/SensorService.h> #include <sensorservicehidl/SensorManager.h> #include <cutils/properties.h> #include <utils/Log.h> Loading @@ -32,6 +35,21 @@ static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jo if (strcmp(propBuf, "1") == 0) { SensorService::instantiate(); } } static void android_server_SystemServer_startHidlServices(JNIEnv* /* env */, jobject /* clazz */) { using ::android::frameworks::sensorservice::V1_0::ISensorManager; using ::android::frameworks::sensorservice::V1_0::implementation::SensorManager; using ::android::hardware::configureRpcThreadpool; configureRpcThreadpool(1, false /* callerWillJoin */); sp<ISensorManager> sensorService = new SensorManager(); status_t err = sensorService->registerAsService(); if (err != OK) { ALOGE("Cannot register ::android::frameworks::sensorservice::V1_0::" "implementation::SensorManager: %d", err); } } /* Loading @@ -40,6 +58,7 @@ static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jo static const JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ { "startSensorService", "()V", (void*) android_server_SystemServer_startSensorService }, { "startHidlServices", "()V", (void*) android_server_SystemServer_startHidlServices }, }; int register_android_server_SystemServer(JNIEnv* env) Loading services/java/com/android/server/SystemServer.java +18 −1 Original line number Diff line number Diff line Loading @@ -236,15 +236,23 @@ public final class SystemServer { private final boolean mRuntimeRestart; private static final String START_SENSOR_SERVICE = "StartSensorService"; private static final String START_HIDL_SERVICES = "StartHidlServices"; private Future<?> mSensorServiceStart; private Future<?> mZygotePreload; /** * Start the sensor service. This is a blocking call and can take time. */ private static native void startSensorService(); /** * Start all HIDL services that are run inside the system server. This * may take some time. */ private static native void startHidlServices(); /** * The main entry point from zygote. */ Loading Loading @@ -611,6 +619,7 @@ public final class SystemServer { startSensorService(); traceLog.traceEnd(); }, START_SENSOR_SERVICE); } /** Loading Loading @@ -638,6 +647,14 @@ public final class SystemServer { traceBeginAndSlog("StartWebViewUpdateService"); mWebViewUpdateService = mSystemServiceManager.startService(WebViewUpdateService.class); traceEnd(); // Start receiving calls from HIDL services. Start in in a separate thread // because it need to connect to SensorManager. SystemServerInitThreadPool.get().submit(() -> { traceBeginAndSlog(START_HIDL_SERVICES); startHidlServices(); traceEnd(); }, START_HIDL_SERVICES); } /** Loading Loading
services/core/jni/Android.mk +3 −1 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ LOCAL_SHARED_LIBRARIES += \ libinputflinger \ libinputservice \ libsensorservice \ libsensorservicehidl \ libskia \ libgui \ libusbhost \ Loading @@ -88,5 +89,6 @@ LOCAL_SHARED_LIBRARIES += \ android.hardware.tv.input@1.0 \ android.hardware.vibrator@1.0 \ android.hardware.vr@1.0 \ android.frameworks.sensorservice@1.0 \ LOCAL_STATIC_LIBRARIES += libscrypt_static
services/core/jni/com_android_server_SystemServer.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,10 @@ #include <jni.h> #include <JNIHelp.h> #include <hidl/HidlTransportSupport.h> #include <sensorservice/SensorService.h> #include <sensorservicehidl/SensorManager.h> #include <cutils/properties.h> #include <utils/Log.h> Loading @@ -32,6 +35,21 @@ static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jo if (strcmp(propBuf, "1") == 0) { SensorService::instantiate(); } } static void android_server_SystemServer_startHidlServices(JNIEnv* /* env */, jobject /* clazz */) { using ::android::frameworks::sensorservice::V1_0::ISensorManager; using ::android::frameworks::sensorservice::V1_0::implementation::SensorManager; using ::android::hardware::configureRpcThreadpool; configureRpcThreadpool(1, false /* callerWillJoin */); sp<ISensorManager> sensorService = new SensorManager(); status_t err = sensorService->registerAsService(); if (err != OK) { ALOGE("Cannot register ::android::frameworks::sensorservice::V1_0::" "implementation::SensorManager: %d", err); } } /* Loading @@ -40,6 +58,7 @@ static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jo static const JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ { "startSensorService", "()V", (void*) android_server_SystemServer_startSensorService }, { "startHidlServices", "()V", (void*) android_server_SystemServer_startHidlServices }, }; int register_android_server_SystemServer(JNIEnv* env) Loading
services/java/com/android/server/SystemServer.java +18 −1 Original line number Diff line number Diff line Loading @@ -236,15 +236,23 @@ public final class SystemServer { private final boolean mRuntimeRestart; private static final String START_SENSOR_SERVICE = "StartSensorService"; private static final String START_HIDL_SERVICES = "StartHidlServices"; private Future<?> mSensorServiceStart; private Future<?> mZygotePreload; /** * Start the sensor service. This is a blocking call and can take time. */ private static native void startSensorService(); /** * Start all HIDL services that are run inside the system server. This * may take some time. */ private static native void startHidlServices(); /** * The main entry point from zygote. */ Loading Loading @@ -611,6 +619,7 @@ public final class SystemServer { startSensorService(); traceLog.traceEnd(); }, START_SENSOR_SERVICE); } /** Loading Loading @@ -638,6 +647,14 @@ public final class SystemServer { traceBeginAndSlog("StartWebViewUpdateService"); mWebViewUpdateService = mSystemServiceManager.startService(WebViewUpdateService.class); traceEnd(); // Start receiving calls from HIDL services. Start in in a separate thread // because it need to connect to SensorManager. SystemServerInitThreadPool.get().submit(() -> { traceBeginAndSlog(START_HIDL_SERVICES); startHidlServices(); traceEnd(); }, START_HIDL_SERVICES); } /** Loading