Merge "Read SystemConfig on a worker thread"
diff --git a/services/core/java/com/android/server/SystemServerInitThreadPool.java b/services/core/java/com/android/server/SystemServerInitThreadPool.java
index d196850..5cc9bfd 100644
--- a/services/core/java/com/android/server/SystemServerInitThreadPool.java
+++ b/services/core/java/com/android/server/SystemServerInitThreadPool.java
@@ -44,7 +44,7 @@
 
     private static SystemServerInitThreadPool sInstance;
 
-    private ExecutorService mService = ConcurrentUtils.newFixedThreadPool(2,
+    private ExecutorService mService = ConcurrentUtils.newFixedThreadPool(4,
             "system-server-init-thread", Process.THREAD_PRIORITY_FOREGROUND);
 
     public static synchronized SystemServerInitThreadPool get() {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 7731228..c08bcef 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -770,7 +770,7 @@
     /**
      * Broadcast actions that will always be deliverable to unlaunched/background apps
      */
-    final ArraySet<String> mBackgroundLaunchBroadcasts;
+    ArraySet<String> mBackgroundLaunchBroadcasts;
 
     /**
      * All of the processes we currently have running organized by pid.
@@ -2615,12 +2615,11 @@
         mPermissionReviewRequired = mContext.getResources().getBoolean(
                 com.android.internal.R.bool.config_permissionReviewRequired);
 
-        mBackgroundLaunchBroadcasts = SystemConfig.getInstance().getAllowImplicitBroadcasts();
         if (DEBUG_BACKGROUND_CHECK) {
             Slog.d(TAG, "Enforcing O+ bg restrictions: " + mConstants.ENFORCE_BG_CHECK);
             StringBuilder sb = new StringBuilder(200);
             sb.append("  ");
-            for (String a : mBackgroundLaunchBroadcasts) {
+            for (String a : getBackgroundLaunchBroadcasts()) {
                 sb.append(' '); sb.append(a);
             }
             Slog.d(TAG, "Background implicit broadcasts:");
@@ -2784,6 +2783,13 @@
         mVoiceWakeLock.setReferenceCounted(false);
     }
 
+    private ArraySet<String> getBackgroundLaunchBroadcasts() {
+        if (mBackgroundLaunchBroadcasts == null) {
+            mBackgroundLaunchBroadcasts = SystemConfig.getInstance().getAllowImplicitBroadcasts();
+        }
+        return mBackgroundLaunchBroadcasts;
+    }
+
     @Override
     public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
             throws RemoteException {
@@ -18305,7 +18311,7 @@
         }
 
         if (action != null) {
-            if (mBackgroundLaunchBroadcasts.contains(action)) {
+            if (getBackgroundLaunchBroadcasts().contains(action)) {
                 if (DEBUG_BACKGROUND_CHECK) {
                     Slog.i(TAG, "Broadcast action " + action + " forcing include-background");
                 }
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 712441c..e4eaf4a 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -455,6 +455,12 @@
      * the other functions.
      */
     private void startBootstrapServices() {
+        Slog.i(TAG, "Reading configuration...");
+        final String TAG_SYSTEM_CONFIG = "ReadingSystemConfig";
+        traceBeginAndSlog(TAG_SYSTEM_CONFIG);
+        SystemServerInitThreadPool.get().submit(SystemConfig::getInstance, TAG_SYSTEM_CONFIG);
+        traceEnd();
+
         // Wait for installd to finish starting up so that it has a chance to
         // create critical directories such as /data/user with the appropriate
         // permissions.  We need this to complete before we initialize other services.
@@ -665,11 +671,6 @@
         }
 
         try {
-            Slog.i(TAG, "Reading configuration...");
-            traceBeginAndSlog("ReadingSystemConfig");
-            SystemConfig.getInstance();
-            traceEnd();
-
             traceBeginAndSlog("StartKeyAttestationApplicationIdProviderService");
             ServiceManager.addService("sec_key_att_app_id_provider",
                     new KeyAttestationApplicationIdProviderService(context));