Fix NPE in reading package-usage.list file

A zero-length file is a valid package usage file of version 0 but
checking against the version 1 magic would throw a NPE.

Bug: 29491065
Change-Id: Ie54b1dd3218e4b1251c29db0c784a5ddf605394f
This commit is contained in:
David Brazdil
2016-06-20 14:06:42 +01:00
parent c1720dce1b
commit 83dce3642a

View File

@@ -1214,7 +1214,9 @@ public class PackageManagerService extends IPackageManager.Stub {
StringBuffer sb = new StringBuffer();
String firstLine = readLine(in, sb);
if (firstLine.equals(USAGE_FILE_MAGIC_VERSION_1)) {
if (firstLine == null) {
// Empty file. Do nothing.
} else if (USAGE_FILE_MAGIC_VERSION_1.equals(firstLine)) {
readVersion1LP(in, sb);
} else {
readVersion0LP(in, sb, firstLine);