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

Commit d024368b authored by Winson Chung's avatar Winson Chung
Browse files

Only abort activity options when failing to bring a task to front

- If the activity options has a start callback, abort will prematurely
  call the callback prior to the app actually being good to go (and starting
  the app transition)
- Also exposing custom activity options call with callback to Launcher

Bug: 111896388
Test: Make change with launcher to defer hiding the task view until the
      transition-start callback, check that swiping down does not flicker

Change-Id: Ie19a38ed81b62057957b3ebfc119d5348468818b
parent c3c71728
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LE
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;

import android.app.ActivityOptions;
import android.content.Context;
import android.os.Handler;

/**
 * Wrapper around internal ActivityOptions creation.
@@ -43,4 +45,17 @@ public abstract class ActivityOptionsCompat {
            RemoteAnimationAdapterCompat remoteAnimationAdapter) {
        return ActivityOptions.makeRemoteAnimation(remoteAnimationAdapter.getWrapped());
    }

    public static ActivityOptions makeCustomAnimation(Context context, int enterResId,
            int exitResId, final Runnable callback, final Handler callbackHandler) {
        return ActivityOptions.makeCustomAnimation(context, enterResId, exitResId, callbackHandler,
                new ActivityOptions.OnAnimationStartedListener() {
                    @Override
                    public void onAnimationStarted() {
                        if (callback != null) {
                            callbackHandler.post(callback);
                        }
                    }
                });
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -1956,10 +1956,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
            if (task == null) {
                Slog.d(TAG, "Could not find task for id: "+ taskId);
                SafeActivityOptions.abort(options);
                return;
            }
            if (getLockTaskController().isLockTaskModeViolation(task)) {
                Slog.e(TAG, "moveTaskToFront: Attempt to violate Lock Task Mode");
                SafeActivityOptions.abort(options);
                return;
            }
            ActivityOptions realOptions = options != null
@@ -1979,7 +1981,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
        SafeActivityOptions.abort(options);
    }

    boolean checkAppSwitchAllowedLocked(int sourcePid, int sourceUid,