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

Commit d8f3fe94 authored by Yifan Hong's avatar Yifan Hong Committed by Android (Google) Code Review
Browse files

Merge "Start android.frameworks.sensorservice@1.0 in system_server"

parents 08153e65 26b421f8
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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
+19 −0
Original line number Diff line number Diff line
@@ -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)
+18 −1
Original line number Diff line number Diff line
@@ -236,15 +236,23 @@ 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.
     */
@@ -611,6 +619,7 @@ public final class SystemServer {
            startSensorService();
            traceLog.traceEnd();
        }, START_SENSOR_SERVICE);

    }

    /**
@@ -638,6 +647,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);
    }

    /**