diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 439844101c970..90783b740ca1e 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -55,6 +55,7 @@ import com.android.server.display.DisplayManagerService; import com.android.server.input.InputManagerService; import com.android.server.net.NetworkPolicyManagerService; import com.android.server.net.NetworkStatsService; +import com.android.server.pm.Installer; import com.android.server.pm.PackageManagerService; import com.android.server.pm.UserManagerService; import com.android.server.power.PowerManagerService; @@ -117,6 +118,7 @@ class ServerThread extends Thread { : Integer.parseInt(factoryTestStr); final boolean headless = "1".equals(SystemProperties.get("ro.config.headless", "0")); + Installer installer = null; AccountManagerService accountManager = null; ContentService contentService = null; LightsService lights = null; @@ -195,6 +197,13 @@ class ServerThread extends Thread { // Critical services... boolean onlyCore = false; try { + // Wait for installd to finished 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. + Slog.i(TAG, "Waiting for installd to be ready."); + installer = new Installer(); + installer.ping(); + Slog.i(TAG, "Entropy Mixer"); ServiceManager.addService("entropy", new EntropyMixer()); @@ -234,7 +243,7 @@ class ServerThread extends Thread { onlyCore = true; } - pm = PackageManagerService.main(context, + pm = PackageManagerService.main(context, installer, factoryTest != SystemServer.FACTORY_TEST_OFF, onlyCore); boolean firstBoot = false; diff --git a/services/java/com/android/server/pm/Installer.java b/services/java/com/android/server/pm/Installer.java index 85de3494bd9b5..ad85c0d6fa4ef 100644 --- a/services/java/com/android/server/pm/Installer.java +++ b/services/java/com/android/server/pm/Installer.java @@ -25,7 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -class Installer { +public final class Installer { private static final String TAG = "Installer"; private static final boolean LOCAL_DEBUG = false; diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index 01a9b4b7b0a48..ba63efde13cd9 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -937,9 +937,10 @@ public class PackageManagerService extends IPackageManager.Stub { } } - public static final IPackageManager main(Context context, boolean factoryTest, - boolean onlyCore) { - PackageManagerService m = new PackageManagerService(context, factoryTest, onlyCore); + public static final IPackageManager main(Context context, Installer installer, + boolean factoryTest, boolean onlyCore) { + PackageManagerService m = new PackageManagerService(context, installer, + factoryTest, onlyCore); ServiceManager.addService("package", m); return m; } @@ -966,7 +967,8 @@ public class PackageManagerService extends IPackageManager.Stub { return res; } - public PackageManagerService(Context context, boolean factoryTest, boolean onlyCore) { + public PackageManagerService(Context context, Installer installer, + boolean factoryTest, boolean onlyCore) { EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_START, SystemClock.uptimeMillis()); @@ -1004,7 +1006,7 @@ public class PackageManagerService extends IPackageManager.Stub { mSeparateProcesses = null; } - mInstaller = new Installer(); + mInstaller = installer; WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); Display d = wm.getDefaultDisplay();