summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChitti Babu Theegala <ctheegal@codeaurora.org>2015-08-07 07:16:49 +0530
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:28:07 -0600
commit9a4880bc91912c62ad064187f739408284b333c7 (patch)
tree4849f526adbf5d3e5f2a5d1bf4c93fe041417853
parent7368c29ec48791af1715799acc0424a4d9b74590 (diff)
downloadframeworks_base-9a4880bc91912c62ad064187f739408284b333c7.zip
frameworks_base-9a4880bc91912c62ad064187f739408284b333c7.tar.gz
frameworks_base-9a4880bc91912c62ad064187f739408284b333c7.tar.bz2
Performance: SystemServer: Move sensor init to a new thread.
Move Sensor init to a separate thread so that it doesn't block the critical booting path. Initializing Sensors in separate thread has been seen to improve boot time on customer devices with low-tier / ult chipsets(less cpu cores) Change-Id: I5c46a5805c04ffe551019b4683523e3bf70274a2
-rw-r--r--services/core/jni/com_android_server_SystemServer.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/services/core/jni/com_android_server_SystemServer.cpp b/services/core/jni/com_android_server_SystemServer.cpp
index 64514a9..3f46ec6 100644
--- a/services/core/jni/com_android_server_SystemServer.cpp
+++ b/services/core/jni/com_android_server_SystemServer.cpp
@@ -25,12 +25,24 @@
namespace android {
+void* sensorInit(void *arg) {
+ ALOGI("System server: starting sensor init.\n");
+ // Start the sensor service
+ SensorService::instantiate();
+ ALOGI("System server: sensor init done.\n");
+ return NULL;
+}
+
static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jobject /* clazz */) {
char propBuf[PROPERTY_VALUE_MAX];
+ pthread_t sensor_init_thread;
+
property_get("system_init.startsensorservice", propBuf, "1");
if (strcmp(propBuf, "1") == 0) {
- // Start the sensor service
- SensorService::instantiate();
+ // We are safe to move this to a new thread because
+ // Android frame work has taken care to check whether the
+ // service is started or not before using it.
+ pthread_create( &sensor_init_thread, NULL, &sensorInit, NULL);
}
}