Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d56d8a67 authored by Balamurugan Thanikachalam's avatar Balamurugan Thanikachalam Committed by Gerrit - the friendly Code Review server
Browse files

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
parent 9f14004c
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -25,12 +25,25 @@

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_nativeInit(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);
    }
}