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

Commit 4558b89c authored by Makoto Onuki's avatar Makoto Onuki Committed by android-build-merger
Browse files

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

am: edda7ebd

Change-Id: Ide5189580c7b930e4aa86aa68b52460b91d6f8d7
parents 99512fd4 edda7ebd
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);
        }
    }

    /**