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

Commit e2f45fa9 authored by Joseph Antonetti's avatar Joseph Antonetti
Browse files

Add IsHandoffEnabled to ActivityRecord

Track if Handoff is enabled on the ActivityRecord

Flag: android.companion.enable_task_continuity
Test: Added unit tests

Change-Id: I520f5e9ea5bd28315dab1a0f2c65ce53f055ebb3
parent 90e30314
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -504,6 +504,9 @@ final class ActivityRecord extends WindowToken {
    WindowProcessController app;      // if non-null, hosting application
    private State mState;    // current state we are in
    private Bundle mIcicle;         // last saved activity state
    private boolean mHandoffEnabled = false; // if Handoff is enabled for this activity
    private boolean mAllowFullTaskRecreation = false; // if the entire task stack can be recreated
                                                      // during handoff of this activity.
    private PersistableBundle mPersistentState; // last persistently saved activity state
    private boolean mHaveState = true; // Indicates whether the last saved state of activity is
                                       // preserved. This starts out 'true', since the initial state
@@ -1280,6 +1283,35 @@ final class ActivityRecord extends WindowToken {
        return true;
    }

    /** Update if handoff is enabled for this activity. */
    void setHandoffEnabled(boolean handoffEnabled, boolean allowFullTaskRecreation) {
        mHandoffEnabled = handoffEnabled;
        mAllowFullTaskRecreation = allowFullTaskRecreation;
    }

    /**
     * Get if Handoff is enabled for this Activity.
     * @see #setHandoffEnabled() to change if Handoff is enabled.
     * @return if Handoff is enabled.
     */
    boolean isHandoffEnabled() {
        return mHandoffEnabled;
    }

    /**
     * Get if the entire task will be recreated when handing off this activity.
     * @see #setHandoffEnabled() to change this parameter. If Handoff is disabled for this
     * activity, this will return false.
     * @return if the entire task will be recreated when handing off this activity.
     */
    boolean allowFullTaskRecreation() {
        if (!isHandoffEnabled()) {
            return false;
        }

        return mAllowFullTaskRecreation;
    }

    /** Update the saved state of an activity. */
    void setSavedState(@Nullable Bundle savedState) {
        mIcicle = savedState;
+10 −0
Original line number Diff line number Diff line
@@ -913,6 +913,16 @@ public class ActivityRecordTests extends WindowTestsBase {
        assertEquals(STARTED, activity.getState());
    }

    @Test
    public void testSetHandoffEnabled() {
        final ActivityRecord activity = createActivityWithTask();
        assertFalse(activity.isHandoffEnabled());
        assertFalse(activity.allowFullTaskRecreation());
        activity.setHandoffEnabled(true, true);
        assertTrue(activity.isHandoffEnabled());
        assertTrue(activity.allowFullTaskRecreation());
    }

    @Test
    public void testTakeSceneTransitionInfo() {
        final ActivityRecord activity = createActivityWithTask();