diff options
10 files changed, 27 insertions, 25 deletions
diff --git a/services/core/java/com/android/server/ContextHubSystemService.java b/services/core/java/com/android/server/ContextHubSystemService.java index 110847dd54c8..c6853a5119ec 100644 --- a/services/core/java/com/android/server/ContextHubSystemService.java +++ b/services/core/java/com/android/server/ContextHubSystemService.java @@ -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"); } diff --git a/services/core/java/com/android/server/PersistentDataBlockService.java b/services/core/java/com/android/server/PersistentDataBlockService.java index bd5ad960a886..73c852083cfd 100644 --- a/services/core/java/com/android/server/PersistentDataBlockService.java +++ b/services/core/java/com/android/server/PersistentDataBlockService.java @@ -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(); diff --git a/services/core/java/com/android/server/SystemServerInitThreadPool.java b/services/core/java/com/android/server/SystemServerInitThreadPool.java index 19f4089b07af..5ed94e380b5b 100644 --- a/services/core/java/com/android/server/SystemServerInitThreadPool.java +++ b/services/core/java/com/android/server/SystemServerInitThreadPool.java @@ -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); diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java index b9d7c687704c..a51746767f0f 100644 --- a/services/core/java/com/android/server/UiModeManagerService.java +++ b/services/core/java/com/android/server/UiModeManagerService.java @@ -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(); diff --git a/services/core/java/com/android/server/biometrics/face/FaceService.java b/services/core/java/com/android/server/biometrics/face/FaceService.java index 9eb0d50dd789..1b132120f709 100644 --- a/services/core/java/com/android/server/biometrics/face/FaceService.java +++ b/services/core/java/com/android/server/biometrics/face/FaceService.java @@ -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"); } diff --git a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java index 320e1022873c..d85af2eb0b32 100644 --- a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java +++ b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java @@ -725,7 +725,7 @@ public class FingerprintService extends BiometricServiceBase { public void onStart() { super.onStart(); publishBinderService(Context.FINGERPRINT_SERVICE, new FingerprintServiceWrapper()); - SystemServerInitThreadPool.get().submit(this::getFingerprintDaemon, TAG + ".onStart"); + SystemServerInitThreadPool.submit(this::getFingerprintDaemon, TAG + ".onStart"); } @Override diff --git a/services/core/java/com/android/server/os/SchedulingPolicyService.java b/services/core/java/com/android/server/os/SchedulingPolicyService.java index 2371b04b583c..c3ed7d7dd6c6 100644 --- a/services/core/java/com/android/server/os/SchedulingPolicyService.java +++ b/services/core/java/com/android/server/os/SchedulingPolicyService.java @@ -21,7 +21,6 @@ import android.os.Binder; import android.os.IBinder; import android.os.ISchedulingPolicyService; import android.os.Process; -import android.os.RemoteException; import android.util.Log; import com.android.server.SystemServerInitThreadPool; @@ -64,7 +63,7 @@ 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(() -> { + SystemServerInitThreadPool.submit(() -> { synchronized (mDeathRecipient) { // only do this if we haven't already got a request to boost. if (mBoostedPid == -1) { diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index b1d05f4c07d6..d675e36faae6 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -3134,7 +3134,7 @@ public class PackageManagerService extends IPackageManager.Stub List<String> deferPackages = reconcileAppsDataLI(StorageManager.UUID_PRIVATE_INTERNAL, UserHandle.USER_SYSTEM, storageFlags, true /* migrateAppData */, true /* onlyCoreApps */); - mPrepareAppDataFuture = SystemServerInitThreadPool.get().submit(() -> { + mPrepareAppDataFuture = SystemServerInitThreadPool.submit(() -> { TimingsTraceLog traceLog = new TimingsTraceLog("SystemServerTimingAsync", Trace.TRACE_TAG_PACKAGE_MANAGER); traceLog.traceBegin("AppDataFixup"); diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 47291cb286ba..9569ac8dfdd1 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -2186,7 +2186,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } void postOnSystemServerInitThreadPool(Runnable runnable) { - SystemServerInitThreadPool.get().submit(runnable, LOG_TAG); + SystemServerInitThreadPool.submit(runnable, LOG_TAG); } public TransferOwnershipMetadataManager newTransferOwnershipMetadataManager() { diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index a453164b8fbc..4cf98d32f8de 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -635,7 +635,7 @@ public final class SystemServer { Slog.i(TAG, "Reading configuration..."); final String TAG_SYSTEM_CONFIG = "ReadingSystemConfig"; t.traceBegin(TAG_SYSTEM_CONFIG); - SystemServerInitThreadPool.get().submit(SystemConfig::getInstance, TAG_SYSTEM_CONFIG); + SystemServerInitThreadPool.submit(SystemConfig::getInstance, TAG_SYSTEM_CONFIG); t.traceEnd(); // Platform compat service is used by ActivityManagerService, PackageManagerService, and @@ -821,7 +821,7 @@ public final class SystemServer { // service, and permissions service, therefore we start it after them. // Start sensor service in a separate thread. Completion should be checked // before using it. - mSensorServiceStart = SystemServerInitThreadPool.get().submit(() -> { + mSensorServiceStart = SystemServerInitThreadPool.submit(() -> { TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog(); traceLog.traceBegin(START_SENSOR_SERVICE); startSensorService(); @@ -946,7 +946,7 @@ public final class SystemServer { // ensure that it completes before the 32 bit relro process is forked // from the zygote. In the event that it takes too long, the webview // RELRO process will block, but it will do so without holding any locks. - mZygotePreload = SystemServerInitThreadPool.get().submit(() -> { + mZygotePreload = SystemServerInitThreadPool.submit(() -> { try { Slog.i(TAG, SECONDARY_ZYGOTE_PRELOAD); TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog(); @@ -1058,7 +1058,7 @@ public final class SystemServer { // Start receiving calls from HIDL services. Start in in a separate thread // because it need to connect to SensorManager. This have to start // after START_SENSOR_SERVICE is done. - SystemServerInitThreadPool.get().submit(() -> { + SystemServerInitThreadPool.submit(() -> { TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog(); traceLog.traceBegin(START_HIDL_SERVICES); startHidlServices(); @@ -2050,7 +2050,7 @@ public final class SystemServer { final String WEBVIEW_PREPARATION = "WebViewFactoryPreparation"; Future<?> webviewPrep = null; if (!mOnlyCore && mWebViewUpdateService != null) { - webviewPrep = SystemServerInitThreadPool.get().submit(() -> { + webviewPrep = SystemServerInitThreadPool.submit(() -> { Slog.i(TAG, WEBVIEW_PREPARATION); TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog(); traceLog.traceBegin(WEBVIEW_PREPARATION); |