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

Commit 4e56ad3c authored by Chong Zhang's avatar Chong Zhang Committed by android-build-merger
Browse files

Merge "Move SchedulingPolicyService init code to SystemServerInitThreadPool" into pi-dev

am: 3f8dd1ca

Change-Id: I87bd861a64e4ff4b8098493ce2a3ee0708b42967
parents 1494d2b8 3f8dd1ca
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.os.Process;
import android.os.RemoteException;
import android.util.Log;

import com.android.server.SystemServerInitThreadPool;

/**
 * The implementation of the scheduling policy service interface.
 *
@@ -62,12 +64,19 @@ public class SchedulingPolicyService extends ISchedulingPolicyService.Stub {
        // (Note that if mediaserver thinks we're in boosted state before the crash,
        // the state could go out of sync temporarily until mediaserver enables/disable
        // boost next time, but this won't be a big issue.)
        SystemServerInitThreadPool.get().submit(() -> {
            synchronized (mDeathRecipient) {
                // only do this if we haven't already got a request to boost.
                if (mBoostedPid == -1) {
                    int[] nativePids = Process.getPidsForCommands(MEDIA_PROCESS_NAMES);
                    if (nativePids != null && nativePids.length == 1) {
                        mBoostedPid = nativePids[0];
                        disableCpusetBoost(nativePids[0]);
                    }
                }
            }
        }, TAG + ".<init>");
    }

    // TODO(b/35196900) We should pass the period in time units, rather
    // than a fixed priority number.
@@ -107,7 +116,9 @@ public class SchedulingPolicyService extends ISchedulingPolicyService.Stub {

    // Request to move media.codec process between SP_FOREGROUND and SP_TOP_APP.
    public int requestCpusetBoost(boolean enable, IBinder client) {
        if (!isPermitted()) {
        // Can only allow mediaserver to call this.
        if (Binder.getCallingPid() != Process.myPid() &&
                Binder.getCallingUid() != Process.MEDIA_UID) {
            return PackageManager.PERMISSION_DENIED;
        }

@@ -201,7 +212,6 @@ public class SchedulingPolicyService extends ISchedulingPolicyService.Stub {

        switch (Binder.getCallingUid()) {
        case Process.AUDIOSERVER_UID:  // fastcapture, fastmixer
        case Process.MEDIA_UID:        // mediaserver
        case Process.CAMERASERVER_UID: // camera high frame rate recording
        case Process.BLUETOOTH_UID:    // Bluetooth audio playback
            return true;