Wait for installd to finish starting before booting.
Fixes a race condition where the system server might try to access /data/user/0 before it was created. In so doing, the system server could end up creating a directory in that location with the wrong permissions and everything would promptly crash. Bug: 7151686 Change-Id: I349c12fd2b9685d2e7f6305e74f6bf7d5816b752
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user