Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4df01973 authored by Narayan Kamath's avatar Narayan Kamath Committed by Android Git Automerger
Browse files

am 2666d12b: am d7b2a2e4: Merge "Be more accepting of dex2oat errors." into mnc-dev

* commit '2666d12b':
  Be more accepting of dex2oat errors.
parents 708fd00e 2666d12b
Loading
Loading
Loading
Loading
+46 −48
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import java.util.ArrayList;
import java.util.List;

import dalvik.system.DexFile;
import dalvik.system.StaleDexCacheError;

import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
@@ -112,13 +111,17 @@ final class PackageDexOptimizer {
            }

            for (String path : paths) {
                try {
                final int dexoptNeeded;
                if (forceDex) {
                    dexoptNeeded = DexFile.DEX2OAT_NEEDED;
                } else {
                        dexoptNeeded = DexFile.getDexOptNeeded(path,
                                pkg.packageName, dexCodeInstructionSet, defer);
                    try {
                        dexoptNeeded = DexFile.getDexOptNeeded(path, pkg.packageName,
                                dexCodeInstructionSet, defer);
                    } catch (IOException ioe) {
                        Slog.w(TAG, "IOException reading apk: " + path, ioe);
                        return DEX_OPT_FAILED;
                    }
                }

                if (!forceDex && defer && dexoptNeeded != DexFile.NO_DEXOPT_NEEDED) {
@@ -134,7 +137,12 @@ final class PackageDexOptimizer {
                    String oatDir = null;
                    if (dexoptNeeded == DexFile.DEX2OAT_NEEDED) {
                        dexoptType = "dex2oat";
                        try {
                            oatDir = createOatDirIfSupported(pkg, dexCodeInstructionSet);
                        } catch (IOException ioe) {
                            Slog.w(TAG, "Unable to create oatDir for package: " + pkg.packageName);
                            return DEX_OPT_FAILED;
                        }
                    } else if (dexoptNeeded == DexFile.PATCHOAT_NEEDED) {
                        dexoptType = "patchoat";
                    } else if (dexoptNeeded == DexFile.SELF_PATCHOAT_NEEDED) {
@@ -142,6 +150,7 @@ final class PackageDexOptimizer {
                    } else {
                        throw new IllegalStateException("Invalid dexopt needed: " + dexoptNeeded);
                    }

                    Log.i(TAG, "Running dexopt (" + dexoptType + ") on: " + path + " pkg="
                            + pkg.applicationInfo.packageName + " isa=" + dexCodeInstructionSet
                            + " vmSafeMode=" + vmSafeMode + " debuggable=" + debuggable
@@ -150,23 +159,12 @@ final class PackageDexOptimizer {
                    final int ret = mPackageManagerService.mInstaller.dexopt(path, sharedGid,
                            !pkg.isForwardLocked(), pkg.packageName, dexCodeInstructionSet,
                            dexoptNeeded, vmSafeMode, debuggable, oatDir);
                        if (ret < 0) {
                            return DEX_OPT_FAILED;
                        }

                    // Dex2oat might fail due to compiler / verifier errors. We soldier on
                    // regardless, and attempt to interpret the app as a safety net.
                    if (ret == 0) {
                        performedDexOpt = true;
                    }
                } catch (FileNotFoundException e) {
                    Slog.w(TAG, "Apk not found for dexopt: " + path);
                    return DEX_OPT_FAILED;
                } catch (IOException e) {
                    Slog.w(TAG, "IOException reading apk: " + path, e);
                    return DEX_OPT_FAILED;
                } catch (StaleDexCacheError e) {
                    Slog.w(TAG, "StaleDexCacheError when reading apk: " + path, e);
                    return DEX_OPT_FAILED;
                } catch (Exception e) {
                    Slog.w(TAG, "Exception when doing dexopt : ", e);
                    return DEX_OPT_FAILED;
                }
            }