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

Commit 6df72bd9 authored by Rick Yiu's avatar Rick Yiu
Browse files

Revert "Implement the ThreadPrioritySetter interface"

Revert submission 1194951-ThreadPrioritySetter2

Reason for revert: need to update new API
Reverted Changes:
Iee33a26c0: Implement the ThreadPrioritySetter interface
I71c5052be: Use ThreadPrioritySetter to set thread priority

Change-Id: I38c1335bff657662d82ff8778bffade323ced620
parent a7612150
Loading
Loading
Loading
Loading
+0 −31
Original line number Original line Diff line number Diff line
@@ -35,7 +35,6 @@ import com.android.internal.logging.AndroidConfig;
import com.android.server.NetworkManagementSocketTagger;
import com.android.server.NetworkManagementSocketTagger;


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


import libcore.content.type.MimeMap;
import libcore.content.type.MimeMap;
@@ -205,7 +204,6 @@ public class RuntimeInit {
     */
     */
    public static void preForkInit() {
    public static void preForkInit() {
        if (DEBUG) Slog.d(TAG, "Entered preForkInit.");
        if (DEBUG) Slog.d(TAG, "Entered preForkInit.");
        RuntimeHooks.setThreadPrioritySetter(new RuntimeThreadPrioritySetter());
        RuntimeInit.enableDdms();
        RuntimeInit.enableDdms();
        // TODO(b/142019040#comment13): Decide whether to load the default instance eagerly, i.e.
        // TODO(b/142019040#comment13): Decide whether to load the default instance eagerly, i.e.
        // MimeMap.setDefault(DefaultMimeMapFactory.create());
        // MimeMap.setDefault(DefaultMimeMapFactory.create());
@@ -218,35 +216,6 @@ public class RuntimeInit {
        MimeMap.setDefaultSupplier(DefaultMimeMapFactory::create);
        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 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(NICE_VALUES[priority - Thread.MIN_PRIORITY]);
        }
    }

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