Merge "Add new callback for when activity rotates" into rvc-dev am: 38dbc97939
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11396809 Change-Id: I16d2689f35a21899955b9913e34c373d2a2954b6
This commit is contained in:
@@ -216,4 +216,14 @@ oneway interface ITaskStackListener {
|
|||||||
* in {@link android.content.pm.ActivityInfo}.
|
* in {@link android.content.pm.ActivityInfo}.
|
||||||
*/
|
*/
|
||||||
void onTaskRequestedOrientationChanged(int taskId, int requestedOrientation);
|
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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,4 +199,8 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
|
|||||||
@Override
|
@Override
|
||||||
public void onTaskRequestedOrientationChanged(int taskId, int requestedOrientation) {
|
public void onTaskRequestedOrientationChanged(int taskId, int requestedOrientation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityRotation() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,4 +114,7 @@ public abstract class TaskStackChangeListener {
|
|||||||
|
|
||||||
/** @see ITaskStackListener#onRecentTaskListFrozenChanged(boolean) */
|
/** @see ITaskStackListener#onRecentTaskListFrozenChanged(boolean) */
|
||||||
public void onRecentTaskListFrozenChanged(boolean frozen) { }
|
public void onRecentTaskListFrozenChanged(boolean frozen) { }
|
||||||
|
|
||||||
|
/** @see ITaskStackListener#onActivityRotation()*/
|
||||||
|
public void onActivityRotation() { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,6 +237,11 @@ public class TaskStackChangeListeners extends TaskStackListener {
|
|||||||
mHandler.obtainMessage(H.ON_TASK_DESCRIPTION_CHANGED, taskInfo).sendToTarget();
|
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 final class H extends Handler {
|
||||||
private static final int ON_TASK_STACK_CHANGED = 1;
|
private static final int ON_TASK_STACK_CHANGED = 1;
|
||||||
private static final int ON_TASK_SNAPSHOT_CHANGED = 2;
|
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_SINGLE_TASK_DISPLAY_EMPTY = 22;
|
||||||
private static final int ON_TASK_LIST_FROZEN_UNFROZEN = 23;
|
private static final int ON_TASK_LIST_FROZEN_UNFROZEN = 23;
|
||||||
private static final int ON_TASK_DESCRIPTION_CHANGED = 24;
|
private static final int ON_TASK_DESCRIPTION_CHANGED = 24;
|
||||||
|
private static final int ON_ACTIVITY_ROTATION = 25;
|
||||||
|
|
||||||
|
|
||||||
public H(Looper looper) {
|
public H(Looper looper) {
|
||||||
@@ -427,6 +433,12 @@ public class TaskStackChangeListeners extends TaskStackListener {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ON_ACTIVITY_ROTATION: {
|
||||||
|
for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
|
||||||
|
mTaskStackListeners.get(i).onActivityRotation();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.obj instanceof SomeArgs) {
|
if (msg.obj instanceof SomeArgs) {
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class TaskChangeNotificationController {
|
|||||||
private static final int NOTIFY_TASK_LIST_FROZEN_UNFROZEN_MSG = 26;
|
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_FOCUS_CHANGED_MSG = 27;
|
||||||
private static final int NOTIFY_TASK_REQUESTED_ORIENTATION_CHANGED_MSG = 28;
|
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)
|
// Delay in notifying task stack change listeners (in millis)
|
||||||
private static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100;
|
private static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100;
|
||||||
@@ -183,6 +184,10 @@ class TaskChangeNotificationController {
|
|||||||
l.onTaskRequestedOrientationChanged(m.arg1, m.arg2);
|
l.onTaskRequestedOrientationChanged(m.arg1, m.arg2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final TaskStackConsumer mNotifyOnActivityRotation = (l, m) -> {
|
||||||
|
l.onActivityRotation();
|
||||||
|
};
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface TaskStackConsumer {
|
public interface TaskStackConsumer {
|
||||||
void accept(ITaskStackListener t, Message m) throws RemoteException;
|
void accept(ITaskStackListener t, Message m) throws RemoteException;
|
||||||
@@ -277,6 +282,9 @@ class TaskChangeNotificationController {
|
|||||||
case NOTIFY_TASK_REQUESTED_ORIENTATION_CHANGED_MSG:
|
case NOTIFY_TASK_REQUESTED_ORIENTATION_CHANGED_MSG:
|
||||||
forAllRemoteListeners(mNotifyTaskRequestedOrientationChanged, msg);
|
forAllRemoteListeners(mNotifyTaskRequestedOrientationChanged, msg);
|
||||||
break;
|
break;
|
||||||
|
case NOTIFY_ACTIVITY_ROTATED_MSG:
|
||||||
|
forAllRemoteListeners(mNotifyOnActivityRotation, msg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (msg.obj instanceof SomeArgs) {
|
if (msg.obj instanceof SomeArgs) {
|
||||||
((SomeArgs) msg.obj).recycle();
|
((SomeArgs) msg.obj).recycle();
|
||||||
@@ -574,4 +582,11 @@ class TaskChangeNotificationController {
|
|||||||
forAllLocalListeners(mNotifyTaskRequestedOrientationChanged, msg);
|
forAllLocalListeners(mNotifyTaskRequestedOrientationChanged, msg);
|
||||||
msg.sendToTarget();
|
msg.sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @see android.app.ITaskStackListener#onActivityRotation() */
|
||||||
|
void notifyOnActivityRotation() {
|
||||||
|
final Message msg = mHandler.obtainMessage(NOTIFY_ACTIVITY_ROTATED_MSG);
|
||||||
|
forAllLocalListeners(mNotifyOnActivityRotation, msg);
|
||||||
|
msg.sendToTarget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3848,6 +3848,11 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
final boolean rotationChanged = displayContent.updateRotationUnchecked();
|
final boolean rotationChanged = displayContent.updateRotationUnchecked();
|
||||||
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
||||||
|
|
||||||
|
if (rotationChanged) {
|
||||||
|
mAtmService.getTaskChangeNotificationController()
|
||||||
|
.notifyOnActivityRotation();
|
||||||
|
}
|
||||||
|
|
||||||
if (!rotationChanged || forceRelayout) {
|
if (!rotationChanged || forceRelayout) {
|
||||||
displayContent.setLayoutNeeded();
|
displayContent.setLayoutNeeded();
|
||||||
layoutNeeded = true;
|
layoutNeeded = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user