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

Commit 56be1690 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge changes from topic "am-d7887c92318748ca81c6d11a22e05a83"

* changes:
  Merge "Revert "Refine documentation for Process.setThreadPriority"" am: fe6160ab am: 1cb565ec am: 017adb40 am: 765dbc6b am: ac2eaa17
  Merge "Revert "Implement the ThreadPrioritySetter interface"" am: b01d0fe1 am: f7ac1ee9 am: 05a7df81 am: 149f54eb am: 545b3b44
parents 3ec9feb5 2d43e28f
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -853,8 +853,7 @@ public class Process {
    /**
     * Set the priority of a thread, based on Linux priorities.
     * 
     * @param tid The identifier of the thread/process to change. It should be
     * the native thread id but not the managed id of {@link java.lang.Thread}.
     * @param tid The identifier of the thread/process to change.
     * @param priority A Linux priority level, from -20 for highest scheduling
     * priority to 19 for lowest scheduling priority.
     * 
+0 −31
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import com.android.internal.logging.AndroidConfig;
import com.android.server.NetworkManagementSocketTagger;

import dalvik.system.RuntimeHooks;
import dalvik.system.ThreadPrioritySetter;
import dalvik.system.VMRuntime;

import libcore.content.type.MimeMap;
@@ -208,7 +207,6 @@ public class RuntimeInit {
     */
    public static void preForkInit() {
        if (DEBUG) Slog.d(TAG, "Entered preForkInit.");
        RuntimeHooks.setThreadPrioritySetter(new RuntimeThreadPrioritySetter());
        RuntimeInit.enableDdms();
        // TODO(b/142019040#comment13): Decide whether to load the default instance eagerly, i.e.
        // MimeMap.setDefault(DefaultMimeMapFactory.create());
@@ -221,35 +219,6 @@ public class RuntimeInit {
        MimeMap.setDefaultSupplier(DefaultMimeMapFactory::create);
    }

    private static class RuntimeThreadPrioritySetter implements ThreadPrioritySetter {
        // Should remain consistent with kNiceValues[] in system/libartpalette/palette_android.cc
        private static final int[] NICE_VALUES = {
            Process.THREAD_PRIORITY_LOWEST,  // 1 (MIN_PRIORITY)
            Process.THREAD_PRIORITY_BACKGROUND + 6,
            Process.THREAD_PRIORITY_BACKGROUND + 3,
            Process.THREAD_PRIORITY_BACKGROUND,
            Process.THREAD_PRIORITY_DEFAULT,  // 5 (NORM_PRIORITY)
            Process.THREAD_PRIORITY_DEFAULT - 2,
            Process.THREAD_PRIORITY_DEFAULT - 4,
            Process.THREAD_PRIORITY_URGENT_DISPLAY + 3,
            Process.THREAD_PRIORITY_URGENT_DISPLAY + 2,
            Process.THREAD_PRIORITY_URGENT_DISPLAY  // 10 (MAX_PRIORITY)
        };

        @Override
        public void setPriority(int nativeTid, int priority) {
            // Check NICE_VALUES[] length first.
            if (NICE_VALUES.length != (1 + Thread.MAX_PRIORITY - Thread.MIN_PRIORITY)) {
                throw new AssertionError("Unexpected NICE_VALUES.length=" + NICE_VALUES.length);
            }
            // Priority should be in the range of MIN_PRIORITY (1) to MAX_PRIORITY (10).
            if (priority < Thread.MIN_PRIORITY || priority > Thread.MAX_PRIORITY) {
                throw new IllegalArgumentException("Priority out of range: " + priority);
            }
            Process.setThreadPriority(nativeTid, NICE_VALUES[priority - Thread.MIN_PRIORITY]);
        }
    }

    @UnsupportedAppUsage
    protected static final void commonInit() {
        if (DEBUG) Slog.d(TAG, "Entered RuntimeInit!");