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

Commit 14e7acd5 authored by David Brazdil's avatar David Brazdil
Browse files

Fix infinite loop during package-usage.list file upgrade

When upgrading from version 0 to version 1 of the file
'/data/system/package-usage.list', the PackageManagerService can get
stuck in an infinite loop if one of the listed packages does not
exist, e.g. because it had been uninstalled. Fix the issue by
refactoring the loop.

Bug: 28409278
Change-Id: Ia312bd0d04f696240445b710dd6a68b93c5d5946
parent 6e5b6025
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -1217,12 +1217,7 @@ public class PackageManagerService extends IPackageManager.Stub {
            // Initial version of the file had no version number and stored one
            // package-timestamp pair per line.
            // Note that the first line has already been read from the InputStream.
            String line = firstLine;
            while (true) {
                if (line == null) {
                    break;
                }
            for (String line = firstLine; line != null; line = readLine(in, sb)) {
                String[] tokens = line.split(" ");
                if (tokens.length != 2) {
                    throw new IOException("Failed to parse " + line +
@@ -1241,8 +1236,6 @@ public class PackageManagerService extends IPackageManager.Stub {
                        reason++) {
                    pkg.mLastPackageUsageTimeInMills[reason] = timestamp;
                }
                line = readLine(in, sb);
            }
        }