summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-02-28 14:44:19 -0800
committerDianne Hackborn <hackbod@google.com>2012-02-28 14:45:23 -0800
commit5c607433e3d609e1a023adb496018fd1389a8ec8 (patch)
tree021b1e5bac436fd2b89b16a377001438cacf305d
parentee329930956c88d3c2cbcbb6da01abde4b40b2e8 (diff)
downloadframeworks_base-5c607433e3d609e1a023adb496018fd1389a8ec8.zip
frameworks_base-5c607433e3d609e1a023adb496018fd1389a8ec8.tar.gz
frameworks_base-5c607433e3d609e1a023adb496018fd1389a8ec8.tar.bz2
Fix issue #6073913: onActivityResult() not getting called...
...if the process is killed and restarted Try to ensure that in all cases we deliver an activity result if one was requested. Change-Id: Id43e830d2ee782f98ed1e3b68e5e16f3258d4ad8
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java9
-rw-r--r--services/java/com/android/server/am/ActivityStack.java55
2 files changed, 31 insertions, 33 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index df58e83..87eb65e 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2730,14 +2730,7 @@ public final class ActivityManagerService extends ActivityManagerNative
r.task.taskId, r.shortComponentName,
"proc died without state saved");
}
- r.makeFinishing();
- mMainStack.mHistory.remove(i);
- r.takeFromHistory();
- mWindowManager.removeAppToken(r.appToken);
- if (VALIDATE_TOKENS) {
- mMainStack.validateAppTokensLocked();
- }
- r.removeUriPermissionsLocked();
+ mMainStack.removeActivityFromHistoryLocked(r);
} else {
// We have the current state for this activity, so
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 6c11953..a7bf7e1 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -3362,6 +3362,33 @@ final class ActivityStack {
return true;
}
+ final void finishActivityResultsLocked(ActivityRecord r, int resultCode, Intent resultData) {
+ // send the result
+ ActivityRecord resultTo = r.resultTo;
+ if (resultTo != null) {
+ if (DEBUG_RESULTS) Slog.v(TAG, "Adding result to " + resultTo
+ + " who=" + r.resultWho + " req=" + r.requestCode
+ + " res=" + resultCode + " data=" + resultData);
+ if (r.info.applicationInfo.uid > 0) {
+ mService.grantUriPermissionFromIntentLocked(r.info.applicationInfo.uid,
+ resultTo.packageName, resultData,
+ resultTo.getUriPermissionsLocked());
+ }
+ resultTo.addResultLocked(r, r.resultWho, r.requestCode, resultCode,
+ resultData);
+ r.resultTo = null;
+ }
+ else if (DEBUG_RESULTS) Slog.v(TAG, "No result destination from " + r);
+
+ // Make sure this HistoryRecord is not holding on to other resources,
+ // because clients have remote IPC references to this object so we
+ // can't assume that will go away and want to avoid circular IPC refs.
+ r.results = null;
+ r.pendingResults = null;
+ r.newIntents = null;
+ r.icicle = null;
+ }
+
/**
* @return Returns true if this activity has been removed from the history
* list, or false if it is still in the list and will be removed later.
@@ -3400,30 +3427,7 @@ final class ActivityStack {
}
}
- // send the result
- ActivityRecord resultTo = r.resultTo;
- if (resultTo != null) {
- if (DEBUG_RESULTS) Slog.v(TAG, "Adding result to " + resultTo
- + " who=" + r.resultWho + " req=" + r.requestCode
- + " res=" + resultCode + " data=" + resultData);
- if (r.info.applicationInfo.uid > 0) {
- mService.grantUriPermissionFromIntentLocked(r.info.applicationInfo.uid,
- resultTo.packageName, resultData,
- resultTo.getUriPermissionsLocked());
- }
- resultTo.addResultLocked(r, r.resultWho, r.requestCode, resultCode,
- resultData);
- r.resultTo = null;
- }
- else if (DEBUG_RESULTS) Slog.v(TAG, "No result destination from " + r);
-
- // Make sure this HistoryRecord is not holding on to other resources,
- // because clients have remote IPC references to this object so we
- // can't assume that will go away and want to avoid circular IPC refs.
- r.results = null;
- r.pendingResults = null;
- r.newIntents = null;
- r.icicle = null;
+ finishActivityResultsLocked(r, resultCode, resultData);
if (mService.mPendingThumbnails.size() > 0) {
// There are clients waiting to receive thumbnails so, in case
@@ -3586,8 +3590,9 @@ final class ActivityStack {
mHandler.removeMessages(DESTROY_TIMEOUT_MSG, r);
}
- private final void removeActivityFromHistoryLocked(ActivityRecord r) {
+ final void removeActivityFromHistoryLocked(ActivityRecord r) {
if (r.state != ActivityState.DESTROYED) {
+ finishActivityResultsLocked(r, Activity.RESULT_CANCELED, null);
r.makeFinishing();
if (DEBUG_ADD_REMOVE) {
RuntimeException here = new RuntimeException("here");