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

Commit c9db89ac authored by Vinit Nayak's avatar Vinit Nayak Committed by Automerger Merge Worker
Browse files

Merge "Add new callback for when activity rotates" into rvc-dev am: 38dbc979

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11396809

Change-Id: Ia1cef2adf65b7c595168c9fda674105885e7bec8
parents be9c1153 38dbc979
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -216,4 +216,14 @@ oneway interface ITaskStackListener {
     *                             in {@link android.content.pm.ActivityInfo}.
     */
     void onTaskRequestedOrientationChanged(int taskId, int requestedOrientation);

    /**
     * Called when a rotation is about to start on the foreground activity.
     * This applies for:
     *   * free sensor rotation
     *   * forced rotation
     *   * rotation settings set through adb command line
     *   * rotation that occurs when rotation tile is toggled in quick settings
     */
     void onActivityRotation();
}
+4 −0
Original line number Diff line number Diff line
@@ -199,4 +199,8 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
    @Override
    public void onTaskRequestedOrientationChanged(int taskId, int requestedOrientation) {
    }

    @Override
    public void onActivityRotation() {
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -114,4 +114,7 @@ public abstract class TaskStackChangeListener {

    /** @see ITaskStackListener#onRecentTaskListFrozenChanged(boolean) */
    public void onRecentTaskListFrozenChanged(boolean frozen) { }

    /** @see ITaskStackListener#onActivityRotation()*/
    public void onActivityRotation() { }
}
+12 −0
Original line number Diff line number Diff line
@@ -237,6 +237,11 @@ public class TaskStackChangeListeners extends TaskStackListener {
        mHandler.obtainMessage(H.ON_TASK_DESCRIPTION_CHANGED, taskInfo).sendToTarget();
    }

    @Override
    public void onActivityRotation() {
        mHandler.obtainMessage(H.ON_ACTIVITY_ROTATION).sendToTarget();
    }

    private final class H extends Handler {
        private static final int ON_TASK_STACK_CHANGED = 1;
        private static final int ON_TASK_SNAPSHOT_CHANGED = 2;
@@ -260,6 +265,7 @@ public class TaskStackChangeListeners extends TaskStackListener {
        private static final int ON_SINGLE_TASK_DISPLAY_EMPTY = 22;
        private static final int ON_TASK_LIST_FROZEN_UNFROZEN = 23;
        private static final int ON_TASK_DESCRIPTION_CHANGED = 24;
        private static final int ON_ACTIVITY_ROTATION = 25;


        public H(Looper looper) {
@@ -427,6 +433,12 @@ public class TaskStackChangeListeners extends TaskStackListener {
                        }
                        break;
                    }
                    case ON_ACTIVITY_ROTATION: {
                        for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
                            mTaskStackListeners.get(i).onActivityRotation();
                        }
                        break;
                    }
                }
            }
            if (msg.obj instanceof SomeArgs) {
+15 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ class TaskChangeNotificationController {
    private static final int NOTIFY_TASK_LIST_FROZEN_UNFROZEN_MSG = 26;
    private static final int NOTIFY_TASK_FOCUS_CHANGED_MSG = 27;
    private static final int NOTIFY_TASK_REQUESTED_ORIENTATION_CHANGED_MSG = 28;
    private static final int NOTIFY_ACTIVITY_ROTATED_MSG = 29;

    // Delay in notifying task stack change listeners (in millis)
    private static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100;
@@ -183,6 +184,10 @@ class TaskChangeNotificationController {
        l.onTaskRequestedOrientationChanged(m.arg1, m.arg2);
    };

    private final TaskStackConsumer mNotifyOnActivityRotation = (l, m) -> {
        l.onActivityRotation();
    };

    @FunctionalInterface
    public interface TaskStackConsumer {
        void accept(ITaskStackListener t, Message m) throws RemoteException;
@@ -277,6 +282,9 @@ class TaskChangeNotificationController {
                case NOTIFY_TASK_REQUESTED_ORIENTATION_CHANGED_MSG:
                    forAllRemoteListeners(mNotifyTaskRequestedOrientationChanged, msg);
                    break;
                case NOTIFY_ACTIVITY_ROTATED_MSG:
                    forAllRemoteListeners(mNotifyOnActivityRotation, msg);
                    break;
            }
            if (msg.obj instanceof SomeArgs) {
                ((SomeArgs) msg.obj).recycle();
@@ -574,4 +582,11 @@ class TaskChangeNotificationController {
        forAllLocalListeners(mNotifyTaskRequestedOrientationChanged, msg);
        msg.sendToTarget();
    }

    /** @see android.app.ITaskStackListener#onActivityRotation() */
    void notifyOnActivityRotation() {
        final Message msg = mHandler.obtainMessage(NOTIFY_ACTIVITY_ROTATED_MSG);
        forAllLocalListeners(mNotifyOnActivityRotation, msg);
        msg.sendToTarget();
    }
}
Loading