Search in sources :

Example 1 with PackageDexOptimizer

use of com.android.server.pm.PackageDexOptimizer in project platform_frameworks_base by android.

the class DexManager method dexoptSecondaryDex.

/**
     * Perform dexopt on the package {@code packageName} secondary dex files.
     * @return true if all secondary dex files were processed successfully (compiled or skipped
     *         because they don't need to be compiled)..
     */
public boolean dexoptSecondaryDex(String packageName, String compilerFilter, boolean force) {
    // Select the dex optimizer based on the force parameter.
    // Forced compilation is done through ForcedUpdatePackageDexOptimizer which will adjust
    // the necessary dexopt flags to make sure that compilation is not skipped. This avoid
    // passing the force flag through the multitude of layers.
    // Note: The force option is rarely used (cmdline input for testing, mostly), so it's OK to
    //       allocate an object here.
    PackageDexOptimizer pdo = force ? new PackageDexOptimizer.ForcedUpdatePackageDexOptimizer(mPackageDexOptimizer) : mPackageDexOptimizer;
    PackageUseInfo useInfo = getPackageUseInfo(packageName);
    if (useInfo == null || useInfo.getDexUseInfoMap().isEmpty()) {
        if (DEBUG) {
            Slog.d(TAG, "No secondary dex use for package:" + packageName);
        }
        // Nothing to compile, return true.
        return true;
    }
    boolean success = true;
    for (Map.Entry<String, DexUseInfo> entry : useInfo.getDexUseInfoMap().entrySet()) {
        String dexPath = entry.getKey();
        DexUseInfo dexUseInfo = entry.getValue();
        PackageInfo pkg = null;
        try {
            pkg = mPackageManager.getPackageInfo(packageName, /*flags*/
            0, dexUseInfo.getOwnerUserId());
        } catch (RemoteException e) {
            throw new AssertionError(e);
        }
        // installed for other users.
        if (pkg == null) {
            Slog.d(TAG, "Could not find package when compiling secondary dex " + packageName + " for user " + dexUseInfo.getOwnerUserId());
            mPackageDexUsage.removeUserPackage(packageName, dexUseInfo.getOwnerUserId());
            continue;
        }
        int result = pdo.dexOptSecondaryDexPath(pkg.applicationInfo, dexPath, dexUseInfo.getLoaderIsas(), compilerFilter, dexUseInfo.isUsedByOtherApps());
        success = success && (result != PackageDexOptimizer.DEX_OPT_FAILED);
    }
    return success;
}
Also used : DexUseInfo(com.android.server.pm.dex.PackageDexUsage.DexUseInfo) PackageInfo(android.content.pm.PackageInfo) RemoteException(android.os.RemoteException) PackageDexOptimizer(com.android.server.pm.PackageDexOptimizer) PackageUseInfo(com.android.server.pm.dex.PackageDexUsage.PackageUseInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

PackageInfo (android.content.pm.PackageInfo)1 RemoteException (android.os.RemoteException)1 PackageDexOptimizer (com.android.server.pm.PackageDexOptimizer)1 DexUseInfo (com.android.server.pm.dex.PackageDexUsage.DexUseInfo)1 PackageUseInfo (com.android.server.pm.dex.PackageDexUsage.PackageUseInfo)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1