From a0cb18dbfbaed7d52f49d4ca7bd55e987ff5c731 Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Tue, 7 Feb 2017 10:50:21 -0800 Subject: [PATCH] SchedulingPolicyService: specify the beneficiary of priority boost audioflinger needs to request priority boost on behalf of hal. This way, a new use case is introduced for requestPriority call. Bug: 34131400 Change-Id: I6cd0e509da2b0166ca4fce181287584179abe391 Test: check priority match between audioflinger's and hal's threads --- core/java/android/os/ISchedulingPolicyService.aidl | 2 +- .../java/com/android/server/os/SchedulingPolicyService.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/java/android/os/ISchedulingPolicyService.aidl b/core/java/android/os/ISchedulingPolicyService.aidl index 1273c83126679..efcf59aaa6615 100644 --- a/core/java/android/os/ISchedulingPolicyService.aidl +++ b/core/java/android/os/ISchedulingPolicyService.aidl @@ -29,6 +29,6 @@ interface ISchedulingPolicyService { * The thread group leader of tid must be pid. * There may be restrictions on who can call this. */ - int requestPriority(int pid, int tid, int prio); + int requestPriority(int pid, int tid, int prio, boolean isForApp); } diff --git a/services/core/java/com/android/server/os/SchedulingPolicyService.java b/services/core/java/com/android/server/os/SchedulingPolicyService.java index 62c9f4c116c24..5d72d5056715a 100644 --- a/services/core/java/com/android/server/os/SchedulingPolicyService.java +++ b/services/core/java/com/android/server/os/SchedulingPolicyService.java @@ -37,7 +37,9 @@ public class SchedulingPolicyService extends ISchedulingPolicyService.Stub { public SchedulingPolicyService() { } - public int requestPriority(int pid, int tid, int prio) { + // TODO(b/35196900) We should pass the period in time units, rather + // than a fixed priority number. + public int requestPriority(int pid, int tid, int prio, boolean isForApp) { //Log.i(TAG, "requestPriority(pid=" + pid + ", tid=" + tid + ", prio=" + prio + ")"); // Verify that the caller uid is permitted, priority is in range, @@ -52,7 +54,7 @@ public class SchedulingPolicyService extends ISchedulingPolicyService.Stub { } try { // make good use of our CAP_SYS_NICE capability - Process.setThreadGroup(tid, Binder.getCallingPid() == pid ? + Process.setThreadGroup(tid, !isForApp ? Process.THREAD_GROUP_AUDIO_SYS : Process.THREAD_GROUP_AUDIO_APP); // must be in this order or it fails the schedulability constraint Process.setThreadScheduler(tid, Process.SCHED_FIFO | Process.SCHED_RESET_ON_FORK,