diff options
| author | 2017-03-10 13:41:11 -0800 | |
|---|---|---|
| committer | 2017-03-16 12:15:05 -0700 | |
| commit | 26b421f8e0411f044e13bbdad4b3ab1dab3c17c8 (patch) | |
| tree | 4c07dfcdc2b14a70932d089e5a304dbac3eb0682 | |
| parent | 78ccde1c9d91c7833824970ec73c49214f072a7d (diff) | |
Start android.frameworks.sensorservice@1.0 in system_server
Bug: 35219747
Test: marlin boots
Test: lshal -ipm | grep android.frameworks.sensorservice@1.0
Change-Id: I67dfb217d1b568e140cefce0bdba3f8f4dbe679c
| -rw-r--r-- | services/core/jni/Android.mk | 4 | ||||
| -rw-r--r-- | services/core/jni/com_android_server_SystemServer.cpp | 19 | ||||
| -rw-r--r-- | services/java/com/android/server/SystemServer.java | 19 |
3 files changed, 40 insertions, 2 deletions
diff --git a/services/core/jni/Android.mk b/services/core/jni/Android.mk index ac95db5c34b4..b5ed26630b23 100644 --- a/services/core/jni/Android.mk +++ b/services/core/jni/Android.mk @@ -65,6 +65,7 @@ LOCAL_SHARED_LIBRARIES += \ libinputflinger \ libinputservice \ libsensorservice \ + libsensorservicehidl \ libskia \ libgui \ libusbhost \ @@ -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
\ No newline at end of file +LOCAL_STATIC_LIBRARIES += libscrypt_static diff --git a/services/core/jni/com_android_server_SystemServer.cpp b/services/core/jni/com_android_server_SystemServer.cpp index 3120af56a1fd..8ad88eddd73b 100644 --- a/services/core/jni/com_android_server_SystemServer.cpp +++ b/services/core/jni/com_android_server_SystemServer.cpp @@ -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> @@ -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); + } } /* @@ -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) diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index a8423e2e8a11..a7077617cfaf 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -235,16 +235,24 @@ 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. */ public static void main(String[] args) { @@ -610,6 +618,7 @@ public final class SystemServer { startSensorService(); traceLog.traceEnd(); }, START_SENSOR_SERVICE); + } /** @@ -637,6 +646,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); } /** |