Skip to content

Commit 27e20cc

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue #6073913: onActivityResult() not getting called..." into ics-mr1
2 parents e4ef9b1 + 5c60743 commit 27e20cc

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,14 +2730,7 @@ private final void handleAppDiedLocked(ProcessRecord app,
27302730
r.task.taskId, r.shortComponentName,
27312731
"proc died without state saved");
27322732
}
2733-
r.makeFinishing();
2734-
mMainStack.mHistory.remove(i);
2735-
r.takeFromHistory();
2736-
mWindowManager.removeAppToken(r.appToken);
2737-
if (VALIDATE_TOKENS) {
2738-
mMainStack.validateAppTokensLocked();
2739-
}
2740-
r.removeUriPermissionsLocked();
2733+
mMainStack.removeActivityFromHistoryLocked(r);
27412734

27422735
} else {
27432736
// We have the current state for this activity, so

services/java/com/android/server/am/ActivityStack.java

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3362,6 +3362,33 @@ final boolean requestFinishActivityLocked(IBinder token, int resultCode,
33623362
return true;
33633363
}
33643364

3365+
final void finishActivityResultsLocked(ActivityRecord r, int resultCode, Intent resultData) {
3366+
// send the result
3367+
ActivityRecord resultTo = r.resultTo;
3368+
if (resultTo != null) {
3369+
if (DEBUG_RESULTS) Slog.v(TAG, "Adding result to " + resultTo
3370+
+ " who=" + r.resultWho + " req=" + r.requestCode
3371+
+ " res=" + resultCode + " data=" + resultData);
3372+
if (r.info.applicationInfo.uid > 0) {
3373+
mService.grantUriPermissionFromIntentLocked(r.info.applicationInfo.uid,
3374+
resultTo.packageName, resultData,
3375+
resultTo.getUriPermissionsLocked());
3376+
}
3377+
resultTo.addResultLocked(r, r.resultWho, r.requestCode, resultCode,
3378+
resultData);
3379+
r.resultTo = null;
3380+
}
3381+
else if (DEBUG_RESULTS) Slog.v(TAG, "No result destination from " + r);
3382+
3383+
// Make sure this HistoryRecord is not holding on to other resources,
3384+
// because clients have remote IPC references to this object so we
3385+
// can't assume that will go away and want to avoid circular IPC refs.
3386+
r.results = null;
3387+
r.pendingResults = null;
3388+
r.newIntents = null;
3389+
r.icicle = null;
3390+
}
3391+
33653392
/**
33663393
* @return Returns true if this activity has been removed from the history
33673394
* list, or false if it is still in the list and will be removed later.
@@ -3400,30 +3427,7 @@ final boolean finishActivityLocked(ActivityRecord r, int index,
34003427
}
34013428
}
34023429

3403-
// send the result
3404-
ActivityRecord resultTo = r.resultTo;
3405-
if (resultTo != null) {
3406-
if (DEBUG_RESULTS) Slog.v(TAG, "Adding result to " + resultTo
3407-
+ " who=" + r.resultWho + " req=" + r.requestCode
3408-
+ " res=" + resultCode + " data=" + resultData);
3409-
if (r.info.applicationInfo.uid > 0) {
3410-
mService.grantUriPermissionFromIntentLocked(r.info.applicationInfo.uid,
3411-
resultTo.packageName, resultData,
3412-
resultTo.getUriPermissionsLocked());
3413-
}
3414-
resultTo.addResultLocked(r, r.resultWho, r.requestCode, resultCode,
3415-
resultData);
3416-
r.resultTo = null;
3417-
}
3418-
else if (DEBUG_RESULTS) Slog.v(TAG, "No result destination from " + r);
3419-
3420-
// Make sure this HistoryRecord is not holding on to other resources,
3421-
// because clients have remote IPC references to this object so we
3422-
// can't assume that will go away and want to avoid circular IPC refs.
3423-
r.results = null;
3424-
r.pendingResults = null;
3425-
r.newIntents = null;
3426-
r.icicle = null;
3430+
finishActivityResultsLocked(r, resultCode, resultData);
34273431

34283432
if (mService.mPendingThumbnails.size() > 0) {
34293433
// There are clients waiting to receive thumbnails so, in case
@@ -3586,8 +3590,9 @@ final void cleanUpActivityLocked(ActivityRecord r, boolean cleanServices,
35863590
mHandler.removeMessages(DESTROY_TIMEOUT_MSG, r);
35873591
}
35883592

3589-
private final void removeActivityFromHistoryLocked(ActivityRecord r) {
3593+
final void removeActivityFromHistoryLocked(ActivityRecord r) {
35903594
if (r.state != ActivityState.DESTROYED) {
3595+
finishActivityResultsLocked(r, Activity.RESULT_CANCELED, null);
35913596
r.makeFinishing();
35923597
if (DEBUG_ADD_REMOVE) {
35933598
RuntimeException here = new RuntimeException("here");

0 commit comments

Comments
 (0)