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

Commit 1e3af319 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refactored SystemServerInitThreadPool.get().submit() into just submit()."

parents b6174ab9 b68b7693
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -16,12 +16,12 @@

package com.android.server;

import com.android.internal.util.ConcurrentUtils;
import com.android.server.location.ContextHubService;
import com.android.server.SystemServerInitThreadPool;
import android.content.Context;
import android.util.Log;

import com.android.internal.util.ConcurrentUtils;
import com.android.server.location.ContextHubService;

import java.util.concurrent.Future;

class ContextHubSystemService extends SystemService {
@@ -32,7 +32,7 @@ class ContextHubSystemService extends SystemService {

    public ContextHubSystemService(Context context) {
        super(context);
        mInit = SystemServerInitThreadPool.get().submit(() -> {
        mInit = SystemServerInitThreadPool.submit(() -> {
            mContextHubService = new ContextHubService(context);
        }, "Init ContextHubSystemService");
    }
+1 −1
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ public class PersistentDataBlockService extends SystemService {
    @Override
    public void onStart() {
        // Do init on a separate thread, will join in PHASE_ACTIVITY_MANAGER_READY
        SystemServerInitThreadPool.get().submit(() -> {
        SystemServerInitThreadPool.submit(() -> {
            mAllowedUid = getAllowedUid(UserHandle.USER_SYSTEM);
            enforceChecksumValidity();
            formatIfOemUnlockEnabled();
+11 −8
Original line number Diff line number Diff line
@@ -67,23 +67,26 @@ public class SystemServerInitThreadPool {
    }

    /**
     * Gets the singleton.
     * Submits a task for execution.
     *
     * @throws IllegalStateException if it hasn't been started or has been shut down already.
     */
    public static SystemServerInitThreadPool get() {
    public static @NonNull Future<?> submit(@NonNull Runnable runnable,
            @NonNull String description) {
        Preconditions.checkNotNull(description, "description cannot be null");

        SystemServerInitThreadPool instance;
        synchronized (LOCK) {
            Preconditions.checkState(sInstance != null, "Cannot get " + TAG
                    + " - it has been shut down");
            return sInstance;
            instance = sInstance;
        }

        return instance.submitTask(runnable, description);
    }

    /**
     * Submits a task for execution.
     */
    public @NonNull Future<?> submit(@NonNull Runnable runnable, @NonNull String description) {
        Preconditions.checkNotNull(description, "description cannot be null");
    private @NonNull Future<?> submitTask(@NonNull Runnable runnable,
            @NonNull String description) {
        synchronized (mPendingTasks) {
            Preconditions.checkState(!mShutDown, TAG + " already shut down");
            mPendingTasks.add(description);
+1 −1
Original line number Diff line number Diff line
@@ -288,7 +288,7 @@ final class UiModeManagerService extends SystemService {
        updateNightModeFromSettings(context, res, UserHandle.getCallingUserId());

        // Update the initial, static configurations.
        SystemServerInitThreadPool.get().submit(() -> {
        SystemServerInitThreadPool.submit(() -> {
            synchronized (mLock) {
                updateConfigurationLocked();
                sendConfigurationLocked();
+1 −1
Original line number Diff line number Diff line
@@ -1089,7 +1089,7 @@ public class FaceService extends BiometricServiceBase {
        publishBinderService(Context.FACE_SERVICE, new FaceServiceWrapper());
        // Get the face daemon on FaceService's on thread so SystemServerInitThreadPool isn't
        // blocked
        SystemServerInitThreadPool.get().submit(() -> mHandler.post(this::getFaceDaemon),
        SystemServerInitThreadPool.submit(() -> mHandler.post(this::getFaceDaemon),
                TAG + ".onStart");
    }

Loading