Handle invalid data during job loading.
Catch exceptions that may be thrown if invalid data ended up in the
persisted job file.
Bug: 246541702
Bug: 246542132
Bug: 246542285
Bug: 246542330
Test: install test app with invalid job config, start app to schedule job, then reboot device
Change-Id: Id0ceba345942baf21177f687b8dd85ef001c0a9e
(cherry picked from commit c98fb42b48)
Merged-In: Id0ceba345942baf21177f687b8dd85ef001c0a9e
This commit is contained in:
committed by
Cherrypicker Worker
parent
64a78c7a03
commit
53522d89c1
@@ -733,6 +733,10 @@ public final class JobStore {
|
|||||||
}
|
}
|
||||||
} catch (XmlPullParserException | IOException e) {
|
} catch (XmlPullParserException | IOException e) {
|
||||||
Slog.wtf(TAG, "Error jobstore xml.", e);
|
Slog.wtf(TAG, "Error jobstore xml.", e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Crashing at this point would result in a boot loop, so live with a general
|
||||||
|
// Exception for system stability's sake.
|
||||||
|
Slog.wtf(TAG, "Unexpected exception", e);
|
||||||
} finally {
|
} finally {
|
||||||
if (mPersistInfo.countAllJobsLoaded < 0) { // Only set them once.
|
if (mPersistInfo.countAllJobsLoaded < 0) { // Only set them once.
|
||||||
mPersistInfo.countAllJobsLoaded = numJobs;
|
mPersistInfo.countAllJobsLoaded = numJobs;
|
||||||
@@ -869,6 +873,9 @@ public final class JobStore {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.d(TAG, "Error I/O Exception.", e);
|
Slog.d(TAG, "Error I/O Exception.", e);
|
||||||
return null;
|
return null;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Slog.e(TAG, "Constraints contained invalid data", e);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.next(); // Consume </constraints>
|
parser.next(); // Consume </constraints>
|
||||||
@@ -965,8 +972,14 @@ public final class JobStore {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistableBundle extras = PersistableBundle.restoreFromXml(parser);
|
final PersistableBundle extras;
|
||||||
|
try {
|
||||||
|
extras = PersistableBundle.restoreFromXml(parser);
|
||||||
jobBuilder.setExtras(extras);
|
jobBuilder.setExtras(extras);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Slog.e(TAG, "Persisted extras contained invalid data", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
parser.nextTag(); // Consume </extras>
|
parser.nextTag(); // Consume </extras>
|
||||||
|
|
||||||
final JobInfo builtJob;
|
final JobInfo builtJob;
|
||||||
|
|||||||
Reference in New Issue
Block a user