Search in sources :

Example 1 with IInstalld

use of android.os.IInstalld in project platform_frameworks_base by android.

the class ZygoteInit method performSystemServerDexOpt.

/**
     * Performs dex-opt on the elements of {@code classPath}, if needed. We
     * choose the instruction set of the current runtime.
     */
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 sharedLibraries = "";
    for (String classPathElement : classPathElements) {
        // System server is fully AOTed and never profiled
        // for profile guided compilation.
        // TODO: Make this configurable between INTERPRET_ONLY, SPEED, SPACE and EVERYTHING?
        int dexoptNeeded;
        try {
            dexoptNeeded = DexFile.getDexOptNeeded(classPathElement, instructionSet, "speed", false);
        } catch (FileNotFoundException ignored) {
            // Do not add to the classpath.
            Log.w(TAG, "Missing classpath element for system server: " + classPathElement);
            continue;
        } catch (IOException e) {
            // Not fully clear what to do here as we don't know the cause of the
            // IO exception. Add to the classpath to be conservative, but don't
            // attempt to compile it.
            Log.w(TAG, "Error checking classpath element for system server: " + classPathElement, e);
            dexoptNeeded = DexFile.NO_DEXOPT_NEEDED;
        }
        if (dexoptNeeded != DexFile.NO_DEXOPT_NEEDED) {
            final String packageName = "*";
            final String outputPath = null;
            final int dexFlags = 0;
            final String compilerFilter = "speed";
            final String uuid = StorageManager.UUID_PRIVATE_INTERNAL;
            try {
                installd.dexopt(classPathElement, Process.SYSTEM_UID, packageName, instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter, uuid, sharedLibraries);
            } catch (RemoteException | ServiceSpecificException e) {
                // Ignore (but log), we need this on the classpath for fallback mode.
                Log.w(TAG, "Failed compiling classpath element for system server: " + classPathElement, e);
            }
        }
        if (!sharedLibraries.isEmpty()) {
            sharedLibraries += ":";
        }
        sharedLibraries += classPathElement;
    }
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) IInstalld(android.os.IInstalld) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) RemoteException(android.os.RemoteException)

Aggregations

IInstalld (android.os.IInstalld)1 RemoteException (android.os.RemoteException)1 ServiceSpecificException (android.os.ServiceSpecificException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1