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

Commit 8538dcc3 authored by Joe Antonetti's avatar Joe Antonetti Committed by Android (Google) Code Review
Browse files

Merge "Add isHandoffEnabled and setHandoffEnabled to Activity" into main

parents 612ee101 095861d5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4547,6 +4547,8 @@ package android.app {
    method @Deprecated public final boolean isChild();
    method public boolean isDestroyed();
    method public boolean isFinishing();
    method @FlaggedApi("android.companion.enable_task_continuity") public final boolean isHandoffEnabled();
    method @FlaggedApi("android.companion.enable_task_continuity") public final boolean isHandoffFullTaskRecreationAllowed();
    method public boolean isImmersive();
    method public boolean isInMultiWindowMode();
    method public boolean isInPictureInPictureMode();
@@ -4691,6 +4693,7 @@ package android.app {
    method public final void setFeatureDrawableResource(int, @DrawableRes int);
    method public final void setFeatureDrawableUri(int, android.net.Uri);
    method public void setFinishOnTouchOutside(boolean);
    method @FlaggedApi("android.companion.enable_task_continuity") public final void setHandoffEnabled(boolean, boolean);
    method public void setImmersive(boolean);
    method public void setInheritShowWhenLocked(boolean);
    method public void setIntent(android.content.Intent);
+56 −0
Original line number Diff line number Diff line
@@ -7641,6 +7641,62 @@ public class Activity extends ContextThemeWrapper
        onActivityResult(requestCode, resultCode, data);
    }

    /**
     * Returns if Handoff has been enabled for this Activity. See
     * {@link #setHandoffEnabled} to change if Handoff is enabled on this
     * Activity.
     *
     * When Handoff is enabled, the user may request this Activity to be sent to
     * other devices that they owe. The system will request data from this
     * Activity to recreate it on the other device.
     * TODO (b/412338142): Add link to onHandoffActivityDataRequested once
     * method is added.
     *
     * @return Whether Handoff is enabled for the Activity
     */
    @FlaggedApi(android.companion.Flags.FLAG_ENABLE_TASK_CONTINUITY)
    public final boolean isHandoffEnabled() {
        return ActivityClient.getInstance().isHandoffEnabled(mToken);
    }

    /**
     * Returns {@code true} if handing off this activity should also hand off
     * all activities in the task of this activity. If this is {@code false} for
     * any activity in the task, only the topmost activity in the task will be
     * handed off.
     *
     * This method will return {@code false} if {@link #isHandoffEnabled}
     * is {@code false}.
     *
     * @return if full task recreation is allowed
     */
    @FlaggedApi(android.companion.Flags.FLAG_ENABLE_TASK_CONTINUITY)
    public final boolean isHandoffFullTaskRecreationAllowed() {
        return ActivityClient
            .getInstance()
            .isHandoffFullTaskRecreationAllowed(mToken);
    }

    /**
     * Sets if Handoff is enabled for this Activity. See
     * {@link #isHandoffEnabled} to get if Handoff is currently enabled on this
     * Activity.
     *
     * Note: if Handoff is disabled for the topmost Activity in a task, it will
     * be disabled for all Activities in the task.
     *
     * @param handoffEnabled Whether Handoff should be enabled for this Activity.
     * @param allowFullTaskRecreation Whether activities below this one in the
     *                                task should be handed off as well.
     */
    @FlaggedApi(android.companion.Flags.FLAG_ENABLE_TASK_CONTINUITY)
    public final void setHandoffEnabled(
            boolean handoffEnabled,
            boolean allowFullTaskRecreation) {
        ActivityClient.getInstance().setHandoffEnabled(
                mToken, handoffEnabled, allowFullTaskRecreation);
    }

    /**
     * Called when an activity you launched with an activity transition exposes this
     * Activity through a returning activity transition, giving you the resultCode
+30 −0
Original line number Diff line number Diff line
@@ -370,6 +370,36 @@ public class ActivityClient {
        }
    }

    boolean isHandoffEnabled(IBinder token) {
        try {
            return getActivityClientController().isHandoffEnabled(token);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    boolean isHandoffFullTaskRecreationAllowed(IBinder token) {
        try {
            return getActivityClientController().isHandoffFullTaskRecreationAllowed(token);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    void setHandoffEnabled(
            IBinder token,
            boolean handoffEnabled,
            boolean allowFullTaskRecreation) {
        try {
            getActivityClientController().setHandoffEnabled(
                    token,
                    handoffEnabled,
                    allowFullTaskRecreation);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    boolean isImmersive(IBinder token) {
        try {
            return getActivityClientController().isImmersive(token);
+7 −0
Original line number Diff line number Diff line
@@ -105,6 +105,13 @@ interface IActivityClientController {
    boolean isImmersive(in IBinder token);
    void setImmersive(in IBinder token, boolean immersive);

    boolean isHandoffEnabled(in IBinder token);
    boolean isHandoffFullTaskRecreationAllowed(in IBinder token);
    void setHandoffEnabled(
        in IBinder token,
        boolean handoffEnabled,
        boolean allowFullTaskRecreation);

    boolean enterPictureInPictureMode(in IBinder token, in PictureInPictureParams params);
    void setPictureInPictureParams(in IBinder token, in PictureInPictureParams params);
    oneway void setShouldDockBigOverlays(in IBinder token, in boolean shouldDockBigOverlays);
+43 −0
Original line number Diff line number Diff line
@@ -329,6 +329,49 @@ class ActivityClientController extends IActivityClientController.Stub {
        Binder.restoreCallingIdentity(origId);
    }

    @Override
    public boolean isHandoffEnabled(IBinder token) {
        final long origId = Binder.clearCallingIdentity();
        boolean isHandoffEnabled = false;
        synchronized (mGlobalLock) {
            final ActivityRecord r = ActivityRecord.forTokenLocked(token);
            if (r != null) {
                isHandoffEnabled = r.isHandoffEnabled();
            }
        }
        Binder.restoreCallingIdentity(origId);
        return isHandoffEnabled;
    }

    @Override
    public boolean isHandoffFullTaskRecreationAllowed(IBinder token) {
        final long origId = Binder.clearCallingIdentity();
        boolean isHandoffFullTaskRecreationAllowed = false;
        synchronized (mGlobalLock) {
            final ActivityRecord r = ActivityRecord.forTokenLocked(token);
            if (r != null) {
                isHandoffFullTaskRecreationAllowed = r.isHandoffFullTaskRecreationAllowed();
            }
        }
        Binder.restoreCallingIdentity(origId);
        return isHandoffFullTaskRecreationAllowed;
    }

    @Override
    public void setHandoffEnabled(
            IBinder token,
            boolean handoffEnabled,
            boolean allowFullTaskRecreation) {
        final long origId = Binder.clearCallingIdentity();
        synchronized (mGlobalLock) {
            final ActivityRecord r = ActivityRecord.forTokenLocked(token);
            if (r != null) {
                r.setHandoffEnabled(handoffEnabled, allowFullTaskRecreation);
            }
        }
        Binder.restoreCallingIdentity(origId);
    }

    @Override
    public void reportSizeConfigurations(IBinder token,
            SizeConfigurationBuckets sizeConfigurations) {
Loading