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

This commit is contained in:
TreeHugger Robot
2017-04-08 02:26:56 +00:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 9 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);
}
/*