Fix NPE in JobStore when jobs.xml is empty.

It is possible that jobs.xml does not have valid content
if the device meet unexpected power off or reboot during
writing the file, then parser.getName() may get null string
on next boot.

Because log does not allow to print null message.
It will result boot fail:
Caused by: java.lang.NullPointerException: println needs a message
 at android.util.Log.println_native(Native Method)
 at android.util.Slog.d
 at com.android.server.job.JobStore
    $ReadJobMapFromDiskRunnable.readJobMapImpl

Change-Id: Icd485096e2f00f4028428a9ad95cd0ef66b2dca0
This commit is contained in:
riddle_hsu
2015-07-30 21:52:58 +08:00
parent 84a04d52e7
commit 98bfb3466c

View File

@@ -457,7 +457,7 @@ public class JobStore {
while (eventType != XmlPullParser.START_TAG &&
eventType != XmlPullParser.END_DOCUMENT) {
eventType = parser.next();
Slog.d(TAG, parser.getName());
Slog.d(TAG, "Start tag: " + parser.getName());
}
if (eventType == XmlPullParser.END_DOCUMENT) {
if (DEBUG) {