Merge "Notify on task display change." into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
22a5e4e5d9
@@ -169,4 +169,12 @@ oneway interface ITaskStackListener {
|
|||||||
* @param taskInfo info about the task which received the back press
|
* @param taskInfo info about the task which received the back press
|
||||||
*/
|
*/
|
||||||
void onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo);
|
void onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a task is reparented to a stack on a different display.
|
||||||
|
*
|
||||||
|
* @param taskId id of the task which was moved to a different display.
|
||||||
|
* @param newDisplayId id of the new display.
|
||||||
|
*/
|
||||||
|
void onTaskDisplayChanged(int taskId, int newDisplayId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.os.RemoteException;
|
|||||||
/**
|
/**
|
||||||
* Classes interested in observing only a subset of changes using ITaskStackListener can extend
|
* Classes interested in observing only a subset of changes using ITaskStackListener can extend
|
||||||
* this class to avoid having to implement all the methods.
|
* this class to avoid having to implement all the methods.
|
||||||
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public abstract class TaskStackListener extends ITaskStackListener.Stub {
|
public abstract class TaskStackListener extends ITaskStackListener.Stub {
|
||||||
@@ -173,4 +174,8 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
|
|||||||
public void onBackPressedOnTaskRoot(ActivityManager.RunningTaskInfo taskInfo)
|
public void onBackPressedOnTaskRoot(ActivityManager.RunningTaskInfo taskInfo)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTaskDisplayChanged(int taskId, int newDisplayId) throws RemoteException {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -925,6 +925,16 @@ public class CarStatusBar extends StatusBar implements
|
|||||||
Log.e(TAG, "Getting StackInfo from activity manager failed", e);
|
Log.e(TAG, "Getting StackInfo from activity manager failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTaskDisplayChanged(int taskId, int newDisplayId) {
|
||||||
|
try {
|
||||||
|
mCarFacetButtonController.taskChanged(
|
||||||
|
ActivityTaskManager.getService().getAllStackInfos());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Getting StackInfo from activity manager failed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDrivingStateChanged(CarDrivingStateEvent notUsed) {
|
private void onDrivingStateChanged(CarDrivingStateEvent notUsed) {
|
||||||
|
|||||||
@@ -78,6 +78,14 @@ public abstract class TaskStackChangeListener {
|
|||||||
|
|
||||||
public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) { }
|
public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a task is reparented to a stack on a different display.
|
||||||
|
*
|
||||||
|
* @param taskId id of the task which was moved to a different display.
|
||||||
|
* @param newDisplayId id of the new display.
|
||||||
|
*/
|
||||||
|
public void onTaskDisplayChanged(int taskId, int newDisplayId) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that the current user matches the process. Since
|
* Checks that the current user matches the process. Since
|
||||||
* {@link android.app.ITaskStackListener} is not multi-user aware, handlers of
|
* {@link android.app.ITaskStackListener} is not multi-user aware, handlers of
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class TaskStackChangeListeners extends TaskStackListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPinnedActivityRestartAttempt(boolean clearedTask)
|
public void onPinnedActivityRestartAttempt(boolean clearedTask)
|
||||||
throws RemoteException{
|
throws RemoteException {
|
||||||
mHandler.removeMessages(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT);
|
mHandler.removeMessages(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT);
|
||||||
mHandler.obtainMessage(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT, clearedTask ? 1 : 0, 0)
|
mHandler.obtainMessage(H.ON_PINNED_ACTIVITY_RESTART_ATTEMPT, clearedTask ? 1 : 0, 0)
|
||||||
.sendToTarget();
|
.sendToTarget();
|
||||||
@@ -201,6 +201,11 @@ public class TaskStackChangeListeners extends TaskStackListener {
|
|||||||
activityToken).sendToTarget();
|
activityToken).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTaskDisplayChanged(int taskId, int newDisplayId) throws RemoteException {
|
||||||
|
mHandler.obtainMessage(H.ON_TASK_DISPLAY_CHANGED, taskId, newDisplayId).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;
|
||||||
@@ -220,6 +225,7 @@ public class TaskStackChangeListeners extends TaskStackListener {
|
|||||||
private static final int ON_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED = 16;
|
private static final int ON_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED = 16;
|
||||||
private static final int ON_SIZE_COMPAT_MODE_ACTIVITY_CHANGED = 17;
|
private static final int ON_SIZE_COMPAT_MODE_ACTIVITY_CHANGED = 17;
|
||||||
private static final int ON_BACK_PRESSED_ON_TASK_ROOT = 18;
|
private static final int ON_BACK_PRESSED_ON_TASK_ROOT = 18;
|
||||||
|
private static final int ON_TASK_DISPLAY_CHANGED = 19;
|
||||||
|
|
||||||
|
|
||||||
public H(Looper looper) {
|
public H(Looper looper) {
|
||||||
@@ -356,6 +362,12 @@ public class TaskStackChangeListeners extends TaskStackListener {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ON_TASK_DISPLAY_CHANGED: {
|
||||||
|
for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
|
||||||
|
mTaskStackListeners.get(i).onTaskDisplayChanged(msg.arg1, msg.arg2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,6 +348,9 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
|
|||||||
void onDisplayChanged(DisplayContent dc) {
|
void onDisplayChanged(DisplayContent dc) {
|
||||||
adjustBoundsForDisplayChangeIfNeeded(dc);
|
adjustBoundsForDisplayChangeIfNeeded(dc);
|
||||||
super.onDisplayChanged(dc);
|
super.onDisplayChanged(dc);
|
||||||
|
final int displayId = (dc != null) ? dc.getDisplayId() : Display.INVALID_DISPLAY;
|
||||||
|
mWmService.mAtmService.getTaskChangeNotificationController().notifyTaskDisplayChanged(
|
||||||
|
mTaskId, displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class TaskChangeNotificationController {
|
|||||||
private static final int NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED_MSG = 19;
|
private static final int NOTIFY_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED_MSG = 19;
|
||||||
private static final int NOTIFY_SIZE_COMPAT_MODE_ACTIVITY_CHANGED_MSG = 20;
|
private static final int NOTIFY_SIZE_COMPAT_MODE_ACTIVITY_CHANGED_MSG = 20;
|
||||||
private static final int NOTIFY_BACK_PRESSED_ON_TASK_ROOT = 21;
|
private static final int NOTIFY_BACK_PRESSED_ON_TASK_ROOT = 21;
|
||||||
|
private static final int NOTIFY_TASK_DISPLAY_CHANGED_LISTENERS_MSG = 22;
|
||||||
|
|
||||||
// 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;
|
||||||
@@ -154,6 +155,10 @@ class TaskChangeNotificationController {
|
|||||||
l.onSizeCompatModeActivityChanged(m.arg1, (IBinder) m.obj);
|
l.onSizeCompatModeActivityChanged(m.arg1, (IBinder) m.obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final TaskStackConsumer mNotifyTaskDisplayChanged = (l, m) -> {
|
||||||
|
l.onTaskDisplayChanged(m.arg1, m.arg2);
|
||||||
|
};
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface TaskStackConsumer {
|
public interface TaskStackConsumer {
|
||||||
void accept(ITaskStackListener t, Message m) throws RemoteException;
|
void accept(ITaskStackListener t, Message m) throws RemoteException;
|
||||||
@@ -233,6 +238,9 @@ class TaskChangeNotificationController {
|
|||||||
case NOTIFY_BACK_PRESSED_ON_TASK_ROOT:
|
case NOTIFY_BACK_PRESSED_ON_TASK_ROOT:
|
||||||
forAllRemoteListeners(mNotifyBackPressedOnTaskRoot, msg);
|
forAllRemoteListeners(mNotifyBackPressedOnTaskRoot, msg);
|
||||||
break;
|
break;
|
||||||
|
case NOTIFY_TASK_DISPLAY_CHANGED_LISTENERS_MSG:
|
||||||
|
forAllRemoteListeners(mNotifyTaskDisplayChanged, msg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,4 +485,14 @@ class TaskChangeNotificationController {
|
|||||||
forAllLocalListeners(mNotifyBackPressedOnTaskRoot, msg);
|
forAllLocalListeners(mNotifyBackPressedOnTaskRoot, msg);
|
||||||
msg.sendToTarget();
|
msg.sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify listeners that a task is reparented to another display.
|
||||||
|
*/
|
||||||
|
void notifyTaskDisplayChanged(int taskId, int newDisplayId) {
|
||||||
|
final Message msg = mHandler.obtainMessage(NOTIFY_TASK_DISPLAY_CHANGED_LISTENERS_MSG,
|
||||||
|
taskId, newDisplayId);
|
||||||
|
forAllLocalListeners(mNotifyTaskStackChanged, msg);
|
||||||
|
msg.sendToTarget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,6 +162,9 @@ public class SystemServicesTestRule implements TestRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final ActivityTaskManagerService atms = mock(ActivityTaskManagerService.class);
|
final ActivityTaskManagerService atms = mock(ActivityTaskManagerService.class);
|
||||||
|
final TaskChangeNotificationController taskChangeNotificationController = mock(
|
||||||
|
TaskChangeNotificationController.class);
|
||||||
|
doReturn(taskChangeNotificationController).when(atms).getTaskChangeNotificationController();
|
||||||
final WindowManagerGlobalLock wmLock = new WindowManagerGlobalLock();
|
final WindowManagerGlobalLock wmLock = new WindowManagerGlobalLock();
|
||||||
doReturn(wmLock).when(atms).getGlobalLock();
|
doReturn(wmLock).when(atms).getGlobalLock();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user