Loading services/core/java/com/android/server/os/SchedulingPolicyService.java +8 −4 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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; Loading services/core/jni/Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ LOCAL_SHARED_LIBRARIES += \ libinput \ libinputflinger \ libinputservice \ libschedulerservicehidl \ libsensorservice \ libsensorservicehidl \ libskia \ Loading @@ -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 services/core/jni/com_android_server_SystemServer.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <hidl/HidlTransportSupport.h> #include <schedulerservice/SchedulingPolicyService.h> #include <sensorservice/SensorService.h> #include <sensorservicehidl/SensorManager.h> Loading @@ -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); } /* Loading Loading
services/core/java/com/android/server/os/SchedulingPolicyService.java +8 −4 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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; Loading
services/core/jni/Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ LOCAL_SHARED_LIBRARIES += \ libinput \ libinputflinger \ libinputservice \ libschedulerservicehidl \ libsensorservice \ libsensorservicehidl \ libskia \ Loading @@ -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
services/core/jni/com_android_server_SystemServer.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <hidl/HidlTransportSupport.h> #include <schedulerservice/SchedulingPolicyService.h> #include <sensorservice/SensorService.h> #include <sensorservicehidl/SensorManager.h> Loading @@ -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); } /* Loading