Merge "Actually wait for installd" into mnc-dev

This commit is contained in:
Makoto Onuki
2015-06-24 19:25:26 +00:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ package com.android.internal.os;
import android.net.LocalSocket; import android.net.LocalSocket;
import android.net.LocalSocketAddress; import android.net.LocalSocketAddress;
import android.os.SystemClock;
import android.util.Slog; import android.util.Slog;
import libcore.io.IoUtils; import libcore.io.IoUtils;
import libcore.io.Streams; import libcore.io.Streams;
@@ -206,4 +207,14 @@ public class InstallerConnection {
} }
return true; return true;
} }
public void waitForConnection() {
for (;;) {
if (execute("ping") >= 0) {
return;
}
Slog.w(TAG, "installd not ready");
SystemClock.sleep(1000);
}
}
} }

View File

@@ -468,6 +468,7 @@ public class ZygoteInit {
private static void performSystemServerDexOpt(String classPath) { private static void performSystemServerDexOpt(String classPath) {
final String[] classPathElements = classPath.split(":"); final String[] classPathElements = classPath.split(":");
final InstallerConnection installer = new InstallerConnection(); final InstallerConnection installer = new InstallerConnection();
installer.waitForConnection();
final String instructionSet = VMRuntime.getRuntime().vmInstructionSet(); final String instructionSet = VMRuntime.getRuntime().vmInstructionSet();
try { try {

View File

@@ -41,7 +41,7 @@ public final class Installer extends SystemService {
@Override @Override
public void onStart() { public void onStart() {
Slog.i(TAG, "Waiting for installd to be ready."); Slog.i(TAG, "Waiting for installd to be ready.");
ping(); mInstaller.waitForConnection();
} }
private static String escapeNull(String arg) { private static String escapeNull(String arg) {
@@ -310,14 +310,6 @@ public final class Installer extends SystemService {
return mInstaller.execute(builder.toString()); return mInstaller.execute(builder.toString());
} }
public boolean ping() {
if (mInstaller.execute("ping") < 0) {
return false;
} else {
return true;
}
}
@Deprecated @Deprecated
public int freeCache(long freeStorageSize) { public int freeCache(long freeStorageSize) {
return freeCache(null, freeStorageSize); return freeCache(null, freeStorageSize);