summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2014-04-28 23:43:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-04-28 23:43:04 +0000
commit7a70981fc1eead712d62d9502f6dccb963779ae8 (patch)
treecc0a84f7016c3b4da481d81fd084be97cadcbbdb /services
parent74af8b54b3e2907dc08e0cecd6d89d0743835aa6 (diff)
parent648c83b4ee5fe825aa4032e0bb32c1d6269b02ad (diff)
downloadframeworks_base-7a70981fc1eead712d62d9502f6dccb963779ae8.zip
frameworks_base-7a70981fc1eead712d62d9502f6dccb963779ae8.tar.gz
frameworks_base-7a70981fc1eead712d62d9502f6dccb963779ae8.tar.bz2
Merge "Fixing NPE. (Bug 14385152)"
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java24
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityStack.java5
2 files changed, 18 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index b6a41bf..0c91907 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1859,24 +1859,28 @@ public final class ActivityManagerService extends ActivityManagerNative
@Override
public boolean onPackageChanged(String packageName, int uid, String[] components) {
final PackageManager pm = mContext.getPackageManager();
- final ArrayList<TaskRecord> recentTasks = new ArrayList<TaskRecord>();
- final ArrayList<TaskRecord> tasksToRemove = new ArrayList<TaskRecord>();
+ final ArrayList<Pair<Intent, Integer>> recentTaskIntents =
+ new ArrayList<Pair<Intent, Integer>>();
+ final ArrayList<Integer> tasksToRemove = new ArrayList<Integer>();
// Copy the list of recent tasks so that we don't hold onto the lock on
// ActivityManagerService for long periods while checking if components exist.
synchronized (ActivityManagerService.this) {
- recentTasks.addAll(mRecentTasks);
+ for (int i = mRecentTasks.size() - 1; i >= 0; i--) {
+ TaskRecord tr = mRecentTasks.get(i);
+ recentTaskIntents.add(new Pair<Intent, Integer>(tr.intent, tr.taskId));
+ }
}
// Check the recent tasks and filter out all tasks with components that no longer exist.
Intent tmpI = new Intent();
- for (int i = recentTasks.size() - 1; i >= 0; i--) {
- TaskRecord tr = recentTasks.get(i);
- ComponentName cn = tr.intent.getComponent();
+ for (int i = recentTaskIntents.size() - 1; i >= 0; i--) {
+ Pair<Intent, Integer> p = recentTaskIntents.get(i);
+ ComponentName cn = p.first.getComponent();
if (cn != null && cn.getPackageName().equals(packageName)) {
try {
// Add the task to the list to remove if the component no longer exists
tmpI.setComponent(cn);
if (pm.queryIntentActivities(tmpI, PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
- tasksToRemove.add(tr);
+ tasksToRemove.add(p.second);
}
} catch (Exception e) {}
}
@@ -1884,9 +1888,9 @@ public final class ActivityManagerService extends ActivityManagerNative
// Prune all the tasks with removed components from the list of recent tasks
synchronized (ActivityManagerService.this) {
for (int i = tasksToRemove.size() - 1; i >= 0; i--) {
- TaskRecord tr = tasksToRemove.get(i);
- // Remove the task but don't kill the process
- removeTaskByIdLocked(tr.taskId, 0);
+ // Remove the task but don't kill the process (since other components in that
+ // package may still be running and in the background)
+ removeTaskByIdLocked(tasksToRemove.get(i), 0);
}
}
return true;
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index bea926f..6769c9c 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -2329,7 +2329,10 @@ final class ActivityStack {
mStackSupervisor.moveHomeToTop();
}
}
- mService.setFocusedActivityLocked(mStackSupervisor.topRunningActivityLocked());
+ ActivityRecord top = mStackSupervisor.topRunningActivityLocked();
+ if (top != null) {
+ mService.setFocusedActivityLocked(top);
+ }
}
}