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

Commit 42136b20 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Start service from libscheduleservicehidl." into oc-dev

parents 72790bad 3d8166f8
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class SchedulingPolicyService extends ISchedulingPolicyService.Stub {
        // Once we've verified that the caller uid is permitted, we can trust the pid but
        // we can't trust the tid.  No need to explicitly check for pid == 0 || tid == 0,
        // since if not the case then the getThreadGroupLeader() test will also fail.
        if (!isPermittedCallingUid() || prio < PRIORITY_MIN ||
        if (!isPermitted() || prio < PRIORITY_MIN ||
                prio > PRIORITY_MAX || Process.getThreadGroupLeader(tid) != pid) {
            return PackageManager.PERMISSION_DENIED;
        }
@@ -65,9 +65,13 @@ public class SchedulingPolicyService extends ISchedulingPolicyService.Stub {
        return PackageManager.PERMISSION_GRANTED;
    }

    private boolean isPermittedCallingUid() {
        final int callingUid = Binder.getCallingUid();
        switch (callingUid) {
    private boolean isPermitted() {
        // schedulerservice hidl
        if (Binder.getCallingPid() == Process.myPid()) {
            return true;
        }

        switch (Binder.getCallingUid()) {
        case Process.AUDIOSERVER_UID: // fastcapture, fastmixer
        case Process.CAMERASERVER_UID: // camera high frame rate recording
            return true;
+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ LOCAL_SHARED_LIBRARIES += \
    libinput \
    libinputflinger \
    libinputservice \
    libschedulerservicehidl \
    libsensorservice \
    libsensorservicehidl \
    libskia \
@@ -89,6 +90,7 @@ LOCAL_SHARED_LIBRARIES += \
    android.hardware.tv.input@1.0 \
    android.hardware.vibrator@1.0 \
    android.hardware.vr@1.0 \
    android.frameworks.schedulerservice@1.0 \
    android.frameworks.sensorservice@1.0 \

LOCAL_STATIC_LIBRARIES += libscrypt_static
+12 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include <hidl/HidlTransportSupport.h>

#include <schedulerservice/SchedulingPolicyService.h>
#include <sensorservice/SensorService.h>
#include <sensorservicehidl/SensorManager.h>

@@ -39,17 +40,23 @@ static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jo
}

static void android_server_SystemServer_startHidlServices(JNIEnv* /* env */, jobject /* clazz */) {
    using ::android::frameworks::schedulerservice::V1_0::ISchedulingPolicyService;
    using ::android::frameworks::schedulerservice::V1_0::implementation::SchedulingPolicyService;
    using ::android::frameworks::sensorservice::V1_0::ISensorManager;
    using ::android::frameworks::sensorservice::V1_0::implementation::SensorManager;
    using ::android::hardware::configureRpcThreadpool;

    status_t err;

    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);
    }
    err = sensorService->registerAsService();
    ALOGE_IF(err != OK, "Cannot register %s: %d", ISensorManager::descriptor, err);

    sp<ISchedulingPolicyService> schedulingService = new SchedulingPolicyService();
    err = schedulingService->registerAsService();
    ALOGE_IF(err != OK, "Cannot register %s: %d", ISchedulingPolicyService::descriptor, err);
}

/*