Merge "Handle invalid data during job loading." into rvc-dev

This commit is contained in:
TreeHugger Robot
2023-03-28 19:24:54 +00:00
committed by Android (Google) Code Review

View File

@@ -687,6 +687,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;
@@ -817,6 +821,15 @@ public final class JobStore {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Slog.d(TAG, "Error reading constraints, skipping."); Slog.d(TAG, "Error reading constraints, skipping.");
return null; return null;
} catch (XmlPullParserException e) {
Slog.d(TAG, "Error Parser Exception.", e);
return null;
} catch (IOException e) {
Slog.d(TAG, "Error I/O Exception.", e);
return null;
} catch (IllegalArgumentException e) {
Slog.e(TAG, "Constraints contained invalid data", e);
return null;
} }
parser.next(); // Consume </constraints> parser.next(); // Consume </constraints>
@@ -912,8 +925,14 @@ public final class JobStore {
return null; return null;
} }
PersistableBundle extras = PersistableBundle.restoreFromXml(parser); final PersistableBundle extras;
jobBuilder.setExtras(extras); try {
extras = PersistableBundle.restoreFromXml(parser);
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;
@@ -959,7 +978,8 @@ public final class JobStore {
return new JobInfo.Builder(jobId, cname); return new JobInfo.Builder(jobId, cname);
} }
private void buildConstraintsFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser) { private void buildConstraintsFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser)
throws XmlPullParserException, IOException {
String val; String val;
final String netCapabilities = parser.getAttributeValue(null, "net-capabilities"); final String netCapabilities = parser.getAttributeValue(null, "net-capabilities");