Add new Activity.finishAffinity() method.
It's cool!
Change-Id: I9fdcd9535b7f1ca2b311d3a1b23e5d058977b095
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 6c99cdb..429c3c4 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2697,29 +2697,21 @@
public final void finishSubActivity(IBinder token, String resultWho,
int requestCode) {
synchronized(this) {
- ActivityRecord self = mMainStack.isInStackLocked(token);
- if (self == null) {
- return;
- }
-
final long origId = Binder.clearCallingIdentity();
-
- int i;
- for (i=mMainStack.mHistory.size()-1; i>=0; i--) {
- ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i);
- if (r.resultTo == self && r.requestCode == requestCode) {
- if ((r.resultWho == null && resultWho == null) ||
- (r.resultWho != null && r.resultWho.equals(resultWho))) {
- mMainStack.finishActivityLocked(r, i,
- Activity.RESULT_CANCELED, null, "request-sub");
- }
- }
- }
-
+ mMainStack.finishSubActivityLocked(token, resultWho, requestCode);
Binder.restoreCallingIdentity(origId);
}
}
+ public boolean finishActivityAffinity(IBinder token) {
+ synchronized(this) {
+ final long origId = Binder.clearCallingIdentity();
+ boolean res = mMainStack.finishActivityAffinityLocked(token);
+ Binder.restoreCallingIdentity(origId);
+ return res;
+ }
+ }
+
public boolean willActivityBeVisible(IBinder token) {
synchronized(this) {
int i;