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

Commit edda7ebd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Avoid potential reboot loop due to package cache" into oc-mr1-dev

parents 94fa7ee9 48e93165
Loading
Loading
Loading
Loading
+25 −21
Original line number Diff line number Diff line
@@ -1120,12 +1120,12 @@ public class PackageParser {
        final String cacheKey = getCacheKey(packageFile, flags);
        final File cacheFile = new File(mCacheDir, cacheKey);

        try {
            // If the cache is not up to date, return null.
            if (!isCacheUpToDate(packageFile, cacheFile)) {
                return null;
            }

        try {
            final byte[] bytes = IoUtils.readFileAsByteArray(cacheFile.getAbsolutePath());
            Package p = fromCacheEntry(bytes);
            if (mCallback != null) {
@@ -1140,7 +1140,7 @@ public class PackageParser {
                }
            }
            return p;
        } catch (Exception e) {
        } catch (Throwable e) {
            Slog.w(TAG, "Error reading package cache: ", e);

            // If something went wrong while reading the cache entry, delete the cache file
@@ -1158,6 +1158,7 @@ public class PackageParser {
            return;
        }

        try {
            final String cacheKey = getCacheKey(packageFile, flags);
            final File cacheFile = new File(mCacheDir, cacheKey);

@@ -1179,6 +1180,9 @@ public class PackageParser {
                Slog.w(TAG, "Error writing cache entry.", ioe);
                cacheFile.delete();
            }
        } catch (Throwable e) {
            Slog.w(TAG, "Error saving package cache.", e);
        }
    }

    /**