From 7adcb4f170f4b5ea5ee5471e32ec3a1308f7e10e Mon Sep 17 00:00:00 2001 From: Sebastian Achim Date: Thu, 2 Jul 2020 10:03:42 +0200 Subject: [PATCH] Wait for installd to start to perform dexopt operation If there are any system_server jars that need dexopt then we need to make sure that installd is started. Issue: 160911601 Test: Manual - see issue Change-Id: Iefcaf708b695504353f664b91017c9cd3a094f8e --- core/java/com/android/internal/os/ZygoteInit.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index fe87b64940fb5..c220428df58b0 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -648,8 +648,6 @@ public class ZygoteInit { */ private static void performSystemServerDexOpt(String classPath) { final String[] classPathElements = classPath.split(":"); - final IInstalld installd = IInstalld.Stub - .asInterface(ServiceManager.getService("installd")); final String instructionSet = VMRuntime.getRuntime().vmInstructionSet(); String classPathForElement = ""; @@ -686,6 +684,10 @@ public class ZygoteInit { final String uuid = StorageManager.UUID_PRIVATE_INTERNAL; final String seInfo = null; final int targetSdkVersion = 0; // SystemServer targets the system's SDK version + // Wait for installd to be made available + IInstalld installd = IInstalld.Stub.asInterface( + ServiceManager.waitForService("installd")); + try { installd.dexopt(classPathElement, Process.SYSTEM_UID, packageName, instructionSet, dexoptNeeded, outputPath, dexFlags, systemServerFilter,