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

Commit c007b7f5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove custom lifecycle transitions for onNewIntent callback" into qt-dev

parents 7fe981bf 92d1652f
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -820,8 +820,6 @@ public class Activity extends ContextThemeWrapper
    /** {@code true} if the activity lifecycle is in a state which supports picture-in-picture.
     * This only affects the client-side exception, the actual state check still happens in AMS. */
    private boolean mCanEnterPictureInPicture = false;
    /** true if the activity is going through a transient pause */
    /*package*/ boolean mTemporaryPause = false;
    /** true if the activity is being destroyed in order to recreate it with a new configuration */
    /*package*/ boolean mChangingConfigurations = false;
    @UnsupportedAppUsage
+2 −25
Original line number Diff line number Diff line
@@ -615,7 +615,6 @@ public final class ActivityThread extends ClientTransactionHandler {
                sb.append(", finished=").append(activity.isFinishing());
                sb.append(", destroyed=").append(activity.isDestroyed());
                sb.append(", startedActivity=").append(activity.mStartedActivity);
                sb.append(", temporaryPause=").append(activity.mTemporaryPause);
                sb.append(", changingConfigurations=").append(activity.mChangingConfigurations);
                sb.append("}");
            }
@@ -3319,35 +3318,15 @@ public final class ActivityThread extends ClientTransactionHandler {
        }
    }

    @UnsupportedAppUsage
    void performNewIntents(IBinder token, List<ReferrerIntent> intents, boolean andPause) {
    @Override
    public void handleNewIntent(IBinder token, List<ReferrerIntent> intents) {
        final ActivityClientRecord r = mActivities.get(token);
        if (r == null) {
            return;
        }

        final boolean resumed = !r.paused;
        if (resumed) {
            r.activity.mTemporaryPause = true;
            performPauseActivityIfNeeded(r, "performNewIntents");
        }
        checkAndBlockForNetworkAccess();
        deliverNewIntents(r, intents);
        if (resumed) {
            performResumeActivity(token, false, "performNewIntents");
            r.activity.mTemporaryPause = false;
        } else if (andPause) {
            // In this case the activity was in the paused state when we delivered the intent,
            // to guarantee onResume gets called after onNewIntent we temporarily resume the
            // activity and pause again as the caller wanted.
            performResumeActivity(token, false, "performNewIntents");
            performPauseActivityIfNeeded(r, "performNewIntents");
        }
    }

    @Override
    public void handleNewIntent(IBinder token, List<ReferrerIntent> intents, boolean andPause) {
        performNewIntents(token, intents, andPause);
    }

    public void handleRequestAssistContextExtras(RequestAssistContextExtras cmd) {
@@ -4662,7 +4641,6 @@ public final class ActivityThread extends ClientTransactionHandler {
                try {
                    // Now we are idle.
                    r.activity.mCalled = false;
                    r.activity.mTemporaryPause = true;
                    mInstrumentation.callActivityOnPause(r.activity);
                    if (!r.activity.mCalled) {
                        throw new SuperNotCalledException(
@@ -4684,7 +4662,6 @@ public final class ActivityThread extends ClientTransactionHandler {
            deliverResults(r, results, reason);
            if (resumed) {
                r.activity.performResume(false, reason);
                r.activity.mTemporaryPause = false;
            }
        }
    }
+1 −2
Original line number Diff line number Diff line
@@ -150,8 +150,7 @@ public abstract class ClientTransactionHandler {
            Configuration overrideConfig);

    /** Deliver new intent. */
    public abstract void handleNewIntent(IBinder token, List<ReferrerIntent> intents,
            boolean andPause);
    public abstract void handleNewIntent(IBinder token, List<ReferrerIntent> intents);

    /** Deliver picture-in-picture mode change notification. */
    public abstract void handlePictureInPictureModeChanged(IBinder token, boolean isInPipMode,
+1 −1
Original line number Diff line number Diff line
@@ -339,7 +339,7 @@ public class LocalActivityManager {
                    ArrayList<ReferrerIntent> intents = new ArrayList<>(1);
                    intents.add(new ReferrerIntent(intent, mParent.getPackageName()));
                    if (localLOGV) Log.v(TAG, r.id + ": new intent");
                    mActivityThread.performNewIntents(r, intents, false /* andPause */);
                    mActivityThread.handleNewIntent(r, intents);
                    r.intent = intent;
                    moveToState(r, mCurState);
                    if (mSingleMode) {
+8 −13
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app.servertransaction;

import static android.app.servertransaction.ActivityLifecycleItem.ON_RESUME;

import android.annotation.UnsupportedAppUsage;
import android.app.ClientTransactionHandler;
import android.os.IBinder;
@@ -36,19 +38,17 @@ public class NewIntentItem extends ClientTransactionItem {

    @UnsupportedAppUsage
    private List<ReferrerIntent> mIntents;
    private boolean mPause;

    // TODO(lifecycler): Switch new intent handling to this scheme.
    /*@Override
    @Override
    public int getPostExecutionState() {
        return ON_RESUME;
    }*/
    }

    @Override
    public void execute(ClientTransactionHandler client, IBinder token,
            PendingTransactionActions pendingActions) {
        Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityNewIntent");
        client.handleNewIntent(token, mIntents, mPause);
        client.handleNewIntent(token, mIntents);
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
    }

@@ -58,13 +58,12 @@ public class NewIntentItem extends ClientTransactionItem {
    private NewIntentItem() {}

    /** Obtain an instance initialized with provided params. */
    public static NewIntentItem obtain(List<ReferrerIntent> intents, boolean pause) {
    public static NewIntentItem obtain(List<ReferrerIntent> intents) {
        NewIntentItem instance = ObjectPool.obtain(NewIntentItem.class);
        if (instance == null) {
            instance = new NewIntentItem();
        }
        instance.mIntents = intents;
        instance.mPause = pause;

        return instance;
    }
@@ -72,7 +71,6 @@ public class NewIntentItem extends ClientTransactionItem {
    @Override
    public void recycle() {
        mIntents = null;
        mPause = false;
        ObjectPool.recycle(this);
    }

@@ -82,13 +80,11 @@ public class NewIntentItem extends ClientTransactionItem {
    /** Write to Parcel. */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeBoolean(mPause);
        dest.writeTypedList(mIntents, flags);
    }

    /** Read from Parcel. */
    private NewIntentItem(Parcel in) {
        mPause = in.readBoolean();
        mIntents = in.createTypedArrayList(ReferrerIntent.CREATOR);
    }

@@ -112,19 +108,18 @@ public class NewIntentItem extends ClientTransactionItem {
            return false;
        }
        final NewIntentItem other = (NewIntentItem) o;
        return mPause == other.mPause && Objects.equals(mIntents, other.mIntents);
        return Objects.equals(mIntents, other.mIntents);
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + (mPause ? 1 : 0);
        result = 31 * result + mIntents.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "NewIntentItem{pause=" + mPause + ",intents=" + mIntents + "}";
        return "NewIntentItem{intents=" + mIntents + "}";
    }
}
Loading