Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b3f4644 authored by Winson Chung's avatar Winson Chung
Browse files

Piping through ability for an Activity to remove its own task. (Bug 13735914)

Change-Id: Iefcd4fbe68748195de8ee37ee2b6edef55276603
parent f74de0b6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3175,6 +3175,7 @@ package android.app {
    method public void finishActivity(int);
    method public void finishActivityFromChild(android.app.Activity, int);
    method public void finishAffinity();
    method public void finishAndRemoveTask();
    method public void finishFromChild(android.app.Activity);
    method public void finishWithTransition();
    method public android.app.ActionBar getActionBar();
+21 −5
Original line number Diff line number Diff line
@@ -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) {
@@ -4343,6 +4342,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
@@ -4441,6 +4449,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
+4 −2
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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) {
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -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;
Loading