summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/os/SchedulingPolicyService.java12
-rw-r--r--services/core/jni/Android.mk2
-rw-r--r--services/core/jni/com_android_server_SystemServer.cpp17
3 files changed, 22 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/os/SchedulingPolicyService.java b/services/core/java/com/android/server/os/SchedulingPolicyService.java
index 5d72d5056715..a8bb80905cd2 100644
--- a/services/core/java/com/android/server/os/SchedulingPolicyService.java
+++ b/services/core/java/com/android/server/os/SchedulingPolicyService.java
@@ -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;
diff --git a/services/core/jni/Android.mk b/services/core/jni/Android.mk
index b5ed26630b23..23637de70f9c 100644
--- a/services/core/jni/Android.mk
+++ b/services/core/jni/Android.mk
@@ -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
diff --git a/services/core/jni/com_android_server_SystemServer.cpp b/services/core/jni/com_android_server_SystemServer.cpp
index 8ad88eddd73b..4a08ce4aebb7 100644
--- a/services/core/jni/com_android_server_SystemServer.cpp
+++ b/services/core/jni/com_android_server_SystemServer.cpp
@@ -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);
}
/*