From f94016d91b1001b7575a7063934ec47edefb79a9 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 29 Nov 2016 11:53:53 -0800 Subject: [PATCH] Start sensor service in a seperate thread StartSensorService is taking ~141.8ms on marlin to start With this CL, StartSensor will be done in a seperate thread so the SystemServer can continue booting Bug: 33199244 Test: on marlin Change-Id: I9e486d61e85072d5cbe69b1671c8fbfeca9c2200 --- services/core/jni/com_android_server_SystemServer.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/core/jni/com_android_server_SystemServer.cpp b/services/core/jni/com_android_server_SystemServer.cpp index c7d6b95083d2..e46490bb3fac 100644 --- a/services/core/jni/com_android_server_SystemServer.cpp +++ b/services/core/jni/com_android_server_SystemServer.cpp @@ -22,15 +22,22 @@ #include #include #include +#include namespace android { +static int start_sensor_service(void* /*unused*/) { + SensorService::instantiate(); + return 0; +} + static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jobject /* clazz */) { char propBuf[PROPERTY_VALUE_MAX]; property_get("system_init.startsensorservice", propBuf, "1"); if (strcmp(propBuf, "1") == 0) { - // Start the sensor service - SensorService::instantiate(); + // Start the sensor service in a new thread + createThreadEtc(start_sensor_service, nullptr, + "StartSensorThread", PRIORITY_FOREGROUND); } } -- 2.11.0