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

Commit 4d97de45 authored by Chitti Babu Theegala's avatar Chitti Babu Theegala Committed by Linux Build Service Account
Browse files

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
parent 223d668f
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -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);
    }
}