diff options
| author | Winson Chung <winsonc@google.com> | 2014-04-23 21:35:32 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-04-23 21:35:33 +0000 |
| commit | 1b244f44a796484866f13e0639420477c3191695 (patch) | |
| tree | fe5a3fb033ca8938a550d5f5f0a9c0825fe238ab /core/java/android | |
| parent | 25a1351831b9912c8316a90444fb3bd1521b5cfc (diff) | |
| parent | 3b3f464445d1d369c8e87f526deba606ca62f76c (diff) | |
| download | frameworks_base-1b244f44a796484866f13e0639420477c3191695.zip frameworks_base-1b244f44a796484866f13e0639420477c3191695.tar.gz frameworks_base-1b244f44a796484866f13e0639420477c3191695.tar.bz2 | |
Merge "Piping through ability for an Activity to remove its own task. (Bug 13735914)"
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/Activity.java | 26 | ||||
| -rw-r--r-- | core/java/android/app/ActivityManagerNative.java | 6 | ||||
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 4 | ||||
| -rw-r--r-- | core/java/android/app/IActivityManager.java | 2 |
4 files changed, 28 insertions, 10 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index a5a06e3..599a608 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -4314,11 +4314,10 @@ public class Activity extends ContextThemeWrapper } /** - * Call this when your activity is done and should be closed. The - * ActivityResult is propagated back to whoever launched you via - * onActivityResult(). + * Finishes the current activity and specifies whether to remove the task associated with this + * activity. */ - public void finish() { + private void finish(boolean finishTask) { if (mParent == null) { int resultCode; Intent resultData; @@ -4332,7 +4331,7 @@ public class Activity extends ContextThemeWrapper resultData.prepareToLeaveProcess(); } if (ActivityManagerNative.getDefault() - .finishActivity(mToken, resultCode, resultData)) { + .finishActivity(mToken, resultCode, resultData, finishTask)) { mFinished = true; } } catch (RemoteException e) { @@ -4344,6 +4343,15 @@ public class Activity extends ContextThemeWrapper } /** + * Call this when your activity is done and should be closed. The + * ActivityResult is propagated back to whoever launched you via + * onActivityResult(). + */ + public void finish() { + finish(false); + } + + /** * Finish this activity as well as all activities immediately below it * in the current task that have the same affinity. This is typically * used when an application can be launched on to another task (such as @@ -4442,6 +4450,14 @@ public class Activity extends ContextThemeWrapper } /** + * Call this when your activity is done and should be closed and the task should be completely + * removed as a part of finishing the Activity. + */ + public void finishAndRemoveTask() { + finish(true); + } + + /** * Called when an activity you launched exits, giving you the requestCode * you started it with, the resultCode it returned, and any additional * data from it. The <var>resultCode</var> will be diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 44c74d8..10831f2 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -263,7 +263,8 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM if (data.readInt() != 0) { resultData = Intent.CREATOR.createFromParcel(data); } - boolean res = finishActivity(token, resultCode, resultData); + boolean finishTask = (data.readInt() != 0); + boolean res = finishActivity(token, resultCode, resultData, finishTask); reply.writeNoException(); reply.writeInt(res ? 1 : 0); return true; @@ -2342,7 +2343,7 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); return result != 0; } - public boolean finishActivity(IBinder token, int resultCode, Intent resultData) + public boolean finishActivity(IBinder token, int resultCode, Intent resultData, boolean finishTask) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); @@ -2355,6 +2356,7 @@ class ActivityManagerProxy implements IActivityManager } else { data.writeInt(0); } + data.writeInt(finishTask ? 1 : 0); mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0); reply.readException(); boolean res = reply.readInt() != 0; diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 965f815..88eae7f 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -2363,7 +2363,7 @@ public final class ActivityThread { // manager to stop us. try { ActivityManagerNative.getDefault() - .finishActivity(r.token, Activity.RESULT_CANCELED, null); + .finishActivity(r.token, Activity.RESULT_CANCELED, null, false); } catch (RemoteException ex) { // Ignore } @@ -2984,7 +2984,7 @@ public final class ActivityThread { // just end this activity. try { ActivityManagerNative.getDefault() - .finishActivity(token, Activity.RESULT_CANCELED, null); + .finishActivity(token, Activity.RESULT_CANCELED, null, false); } catch (RemoteException ex) { } } diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index bfbd339..52003f1 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -79,7 +79,7 @@ public interface IActivityManager extends IInterface { int flagsMask, int flagsValues, Bundle options) throws RemoteException; public boolean startNextMatchingActivity(IBinder callingActivity, Intent intent, Bundle options) throws RemoteException; - public boolean finishActivity(IBinder token, int code, Intent data) + public boolean finishActivity(IBinder token, int code, Intent data, boolean finishTask) throws RemoteException; public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException; public boolean finishActivityAffinity(IBinder token) throws RemoteException; |
