summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2014-05-27 16:13:28 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-27 16:13:28 +0000
commit5d0045835b0bfd456b9400be1cacdc8cb16d6cc7 (patch)
treec98751658350b40d7834369e9ddf02cc6c3f2e67 /services
parent427a15a0f0d3d2a244348c2d572a44bca3035fd9 (diff)
parente0129b3c672f5555deb75366b1a7159f41737874 (diff)
downloadframeworks_base-5d0045835b0bfd456b9400be1cacdc8cb16d6cc7.zip
frameworks_base-5d0045835b0bfd456b9400be1cacdc8cb16d6cc7.tar.gz
frameworks_base-5d0045835b0bfd456b9400be1cacdc8cb16d6cc7.tar.bz2
Merge "Add more error checking to xml restore" into lmp-preview-dev
Diffstat (limited to 'services')
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityRecord.java6
-rw-r--r--services/core/java/com/android/server/am/TaskPersister.java16
2 files changed, 13 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index b948c41..b429b93 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -1154,13 +1154,15 @@ final class ActivityRecord {
}
if (intent == null) {
- Slog.e(TAG, "restoreActivity error intent=" + intent);
- return null;
+ throw new XmlPullParserException("restoreActivity error intent=" + intent);
}
final ActivityManagerService service = stackSupervisor.mService;
final ActivityInfo aInfo = stackSupervisor.resolveActivity(intent, resolvedType, 0, null,
null, userId);
+ if (aInfo == null) {
+ throw new XmlPullParserException("restoreActivity resolver error.");
+ }
final ActivityRecord r = new ActivityRecord(service, /*caller*/null, launchedFromUid,
launchedFromPackage, intent, resolvedType, aInfo, service.getConfiguration(),
null, null, 0, componentSpecified, stackSupervisor, null, null);
diff --git a/services/core/java/com/android/server/am/TaskPersister.java b/services/core/java/com/android/server/am/TaskPersister.java
index ba3f2fe..3bfaca9 100644
--- a/services/core/java/com/android/server/am/TaskPersister.java
+++ b/services/core/java/com/android/server/am/TaskPersister.java
@@ -155,6 +155,7 @@ public class TaskPersister {
File taskFile = recentFiles[taskNdx];
if (DEBUG) Slog.d(TAG, "restoreTasksLocked: taskFile=" + taskFile.getName());
BufferedReader reader = null;
+ boolean deleteFile = false;
try {
reader = new BufferedReader(new FileReader(taskFile));
final XmlPullParser in = Xml.newPullParser();
@@ -183,10 +184,9 @@ public class TaskPersister {
}
XmlUtils.skipCurrentTag(in);
}
- } catch (IOException e) {
- Slog.e(TAG, "Unable to parse " + taskFile + ". Error " + e);
- } catch (XmlPullParserException e) {
- Slog.e(TAG, "Unable to parse " + taskFile + ". Error " + e);
+ } catch (Exception e) {
+ Slog.wtf(TAG, "Unable to parse " + taskFile + ". Error " + e);
+ deleteFile = true;
} finally {
if (reader != null) {
try {
@@ -194,6 +194,9 @@ public class TaskPersister {
} catch (IOException e) {
}
}
+ if (!DEBUG && deleteFile) {
+ taskFile.delete();
+ }
}
}
@@ -220,7 +223,7 @@ public class TaskPersister {
return new ArrayList<TaskRecord>(Arrays.asList(tasksArray));
}
- private void removeObsoleteFiles(ArraySet<Integer> persistentTaskIds, File[] files) {
+ private static void removeObsoleteFiles(ArraySet<Integer> persistentTaskIds, File[] files) {
for (int fileNdx = 0; fileNdx < files.length; ++fileNdx) {
File file = files[fileNdx];
String filename = file.getName();
@@ -285,8 +288,7 @@ public class TaskPersister {
synchronized(mService) {
final ArrayList<TaskRecord> tasks = mService.mRecentTasks;
persistentTaskIds.clear();
- int taskNdx;
- for (taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
+ for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
task = tasks.get(taskNdx);
if (DEBUG) Slog.d(TAG, "LazyTaskWriter: task=" + task + " persistable=" +
task.isPersistable + " needsPersisting=" + task.needsPersisting);