Loading core/java/android/app/TaskInfo.java +10 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,13 @@ public class TaskInfo { */ public int parentTaskId; /** * Parent bounds. * @hide */ public Rect parentBounds; TaskInfo() { // Do nothing } Loading Loading @@ -311,6 +318,7 @@ public class TaskInfo { letterboxActivityBounds = source.readTypedObject(Rect.CREATOR); positionInParent = source.readTypedObject(Point.CREATOR); parentTaskId = source.readInt(); parentBounds = source.readTypedObject(Rect.CREATOR); } /** Loading Loading @@ -345,6 +353,7 @@ public class TaskInfo { dest.writeTypedObject(letterboxActivityBounds, flags); dest.writeTypedObject(positionInParent, flags); dest.writeInt(parentTaskId); dest.writeTypedObject(parentBounds, flags); } @Override Loading @@ -368,6 +377,7 @@ public class TaskInfo { + " letterboxActivityBounds=" + letterboxActivityBounds + " positionInParent=" + positionInParent + " parentTaskId: " + parentTaskId + " parentBounds: " + parentBounds + "}"; } } libs/WindowManager/Shell/res/raw/wm_shell_protolog.json +18 −18 Original line number Diff line number Diff line { "version": "1.0.0", "messages": { "-1993693214": { "message": "Letterbox Task Changed: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/letterbox\/LetterboxTaskListener.java" }, "-1683614271": { "message": "Existing task: id=%d component=%s", "level": "VERBOSE", Loading Loading @@ -67,12 +73,6 @@ "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/ShellTaskOrganizer.java" }, "-848099324": { "message": "Letterbox Task Appeared: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/LetterboxTaskListener.java" }, "-842742255": { "message": "%s onTaskAppeared unknown taskId=%d winMode=%d", "level": "VERBOSE", Loading @@ -97,6 +97,12 @@ "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/splitscreen\/SplitScreenTaskListener.java" }, "-342975160": { "message": "Letterbox Task Vanished: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/letterbox\/LetterboxTaskListener.java" }, "-234284913": { "message": "unpair taskId=%d pair=%s", "level": "VERBOSE", Loading Loading @@ -175,24 +181,12 @@ "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/apppairs\/AppPairsPool.java" }, "1104702476": { "message": "Letterbox Task Changed: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/LetterboxTaskListener.java" }, "1184615936": { "message": "Set drop target window visibility: displayId=%d visibility=%d", "level": "VERBOSE", "group": "WM_SHELL_DRAG_AND_DROP", "at": "com\/android\/wm\/shell\/draganddrop\/DragAndDropController.java" }, "1218010718": { "message": "Letterbox Task Vanished: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/LetterboxTaskListener.java" }, "1481772149": { "message": "Current target: %s", "level": "VERBOSE", Loading @@ -205,6 +199,12 @@ "group": "WM_SHELL_DRAG_AND_DROP", "at": "com\/android\/wm\/shell\/draganddrop\/DragAndDropController.java" }, "1885882094": { "message": "Letterbox Task Appeared: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/letterbox\/LetterboxTaskListener.java" }, "1891981945": { "message": "release entry.taskId=%s listener=%s size=%d", "level": "VERBOSE", Loading libs/WindowManager/Shell/res/values/config.xml +12 −0 Original line number Diff line number Diff line Loading @@ -36,4 +36,16 @@ <!-- Bounds [left top right bottom] on screen for picture-in-picture (PIP) windows, when the PIP menu is shown in center. --> <string translatable="false" name="pip_menu_bounds">"596 280 1324 690"</string> <!-- Gravity of letterboxed apps in portrait screen orientation. Can be Gravity.TOP, Gravity.CENTER or Gravity.BOTTOM. Any other value will result in runtime exception for a letterboxed activity. Default is Gravity.TOP. --> <integer name="config_letterboxPortraitGravity">0x00000030</integer> <!-- Gravity of letterboxed apps in landscape screen orientation. Can be Gravity.LEFT, Gravity.CENTER or Gravity.RIGHT. Any other value will result in runtime exception for a letterboxed activity. Default is Gravity.CENTER. --> <integer name="config_letterboxLandscapeGravity">0x00000011</integer> </resources> libs/WindowManager/Shell/src/com/android/wm/shell/FullscreenTaskListener.java +5 −2 Original line number Diff line number Diff line Loading @@ -32,14 +32,17 @@ import com.android.wm.shell.protolog.ShellProtoLogGroup; import java.io.PrintWriter; class FullscreenTaskListener implements ShellTaskOrganizer.TaskListener { /** * Organizes tasks presented in {@link android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN}. */ public class FullscreenTaskListener implements ShellTaskOrganizer.TaskListener { private static final String TAG = "FullscreenTaskListener"; private final SyncTransactionQueue mSyncQueue; private final ArraySet<Integer> mTasks = new ArraySet<>(); FullscreenTaskListener(SyncTransactionQueue syncQueue) { public FullscreenTaskListener(SyncTransactionQueue syncQueue) { mSyncQueue = syncQueue; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/LetterboxTaskListener.javadeleted 100644 → 0 +0 −110 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell; import android.app.ActivityManager; import android.graphics.Point; import android.graphics.Rect; import android.util.Slog; import android.util.SparseArray; import android.view.SurfaceControl; import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.protolog.ShellProtoLogGroup; /** * Organizes a task in {@link android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN} when * it's presented in the letterbox mode either because orientations of a top activity and a device * don't match or because a top activity is in a size compat mode. */ final class LetterboxTaskListener implements ShellTaskOrganizer.TaskListener { private static final String TAG = "LetterboxTaskListener"; private final SyncTransactionQueue mSyncQueue; private final SparseArray<SurfaceControl> mLeashByTaskId = new SparseArray<>(); LetterboxTaskListener(SyncTransactionQueue syncQueue) { mSyncQueue = syncQueue; } @Override public void onTaskAppeared(ActivityManager.RunningTaskInfo taskInfo, SurfaceControl leash) { synchronized (mLeashByTaskId) { if (mLeashByTaskId.get(taskInfo.taskId) != null) { throw new RuntimeException("Task appeared more than once: #" + taskInfo.taskId); } ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TASK_ORG, "Letterbox Task Appeared: #%d", taskInfo.taskId); mLeashByTaskId.put(taskInfo.taskId, leash); final Rect taskBounds = taskInfo.getConfiguration().windowConfiguration.getBounds(); final Rect activtyBounds = taskInfo.letterboxActivityBounds; final Point taskPositionInParent = taskInfo.positionInParent; mSyncQueue.runInSync(t -> { setPositionAndWindowCrop( t, leash, activtyBounds, taskBounds, taskPositionInParent); if (!Transitions.ENABLE_SHELL_TRANSITIONS) { t.setAlpha(leash, 1f); t.setMatrix(leash, 1, 0, 0, 1); t.show(leash); } }); } } @Override public void onTaskVanished(ActivityManager.RunningTaskInfo taskInfo) { synchronized (mLeashByTaskId) { if (mLeashByTaskId.get(taskInfo.taskId) == null) { Slog.e(TAG, "Task already vanished: #" + taskInfo.taskId); return; } mLeashByTaskId.remove(taskInfo.taskId); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TASK_ORG, "Letterbox Task Vanished: #%d", taskInfo.taskId); } } @Override public void onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo) { synchronized (mLeashByTaskId) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TASK_ORG, "Letterbox Task Changed: #%d", taskInfo.taskId); final SurfaceControl leash = mLeashByTaskId.get(taskInfo.taskId); final Rect taskBounds = taskInfo.getConfiguration().windowConfiguration.getBounds(); final Rect activtyBounds = taskInfo.letterboxActivityBounds; final Point taskPositionInParent = taskInfo.positionInParent; mSyncQueue.runInSync(t -> { setPositionAndWindowCrop( t, leash, activtyBounds, taskBounds, taskPositionInParent); }); } } private static void setPositionAndWindowCrop( SurfaceControl.Transaction transaction, SurfaceControl leash, final Rect activityBounds, final Rect taskBounds, final Point taskPositionInParent) { Rect activtyInTaskCoordinates = new Rect(activityBounds); activtyInTaskCoordinates.offset(-taskBounds.left, -taskBounds.top); transaction.setPosition(leash, taskPositionInParent.x, taskPositionInParent.y); transaction.setWindowCrop(leash, activtyInTaskCoordinates); } } Loading
core/java/android/app/TaskInfo.java +10 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,13 @@ public class TaskInfo { */ public int parentTaskId; /** * Parent bounds. * @hide */ public Rect parentBounds; TaskInfo() { // Do nothing } Loading Loading @@ -311,6 +318,7 @@ public class TaskInfo { letterboxActivityBounds = source.readTypedObject(Rect.CREATOR); positionInParent = source.readTypedObject(Point.CREATOR); parentTaskId = source.readInt(); parentBounds = source.readTypedObject(Rect.CREATOR); } /** Loading Loading @@ -345,6 +353,7 @@ public class TaskInfo { dest.writeTypedObject(letterboxActivityBounds, flags); dest.writeTypedObject(positionInParent, flags); dest.writeInt(parentTaskId); dest.writeTypedObject(parentBounds, flags); } @Override Loading @@ -368,6 +377,7 @@ public class TaskInfo { + " letterboxActivityBounds=" + letterboxActivityBounds + " positionInParent=" + positionInParent + " parentTaskId: " + parentTaskId + " parentBounds: " + parentBounds + "}"; } }
libs/WindowManager/Shell/res/raw/wm_shell_protolog.json +18 −18 Original line number Diff line number Diff line { "version": "1.0.0", "messages": { "-1993693214": { "message": "Letterbox Task Changed: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/letterbox\/LetterboxTaskListener.java" }, "-1683614271": { "message": "Existing task: id=%d component=%s", "level": "VERBOSE", Loading Loading @@ -67,12 +73,6 @@ "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/ShellTaskOrganizer.java" }, "-848099324": { "message": "Letterbox Task Appeared: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/LetterboxTaskListener.java" }, "-842742255": { "message": "%s onTaskAppeared unknown taskId=%d winMode=%d", "level": "VERBOSE", Loading @@ -97,6 +97,12 @@ "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/splitscreen\/SplitScreenTaskListener.java" }, "-342975160": { "message": "Letterbox Task Vanished: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/letterbox\/LetterboxTaskListener.java" }, "-234284913": { "message": "unpair taskId=%d pair=%s", "level": "VERBOSE", Loading Loading @@ -175,24 +181,12 @@ "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/apppairs\/AppPairsPool.java" }, "1104702476": { "message": "Letterbox Task Changed: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/LetterboxTaskListener.java" }, "1184615936": { "message": "Set drop target window visibility: displayId=%d visibility=%d", "level": "VERBOSE", "group": "WM_SHELL_DRAG_AND_DROP", "at": "com\/android\/wm\/shell\/draganddrop\/DragAndDropController.java" }, "1218010718": { "message": "Letterbox Task Vanished: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/LetterboxTaskListener.java" }, "1481772149": { "message": "Current target: %s", "level": "VERBOSE", Loading @@ -205,6 +199,12 @@ "group": "WM_SHELL_DRAG_AND_DROP", "at": "com\/android\/wm\/shell\/draganddrop\/DragAndDropController.java" }, "1885882094": { "message": "Letterbox Task Appeared: #%d", "level": "VERBOSE", "group": "WM_SHELL_TASK_ORG", "at": "com\/android\/wm\/shell\/letterbox\/LetterboxTaskListener.java" }, "1891981945": { "message": "release entry.taskId=%s listener=%s size=%d", "level": "VERBOSE", Loading
libs/WindowManager/Shell/res/values/config.xml +12 −0 Original line number Diff line number Diff line Loading @@ -36,4 +36,16 @@ <!-- Bounds [left top right bottom] on screen for picture-in-picture (PIP) windows, when the PIP menu is shown in center. --> <string translatable="false" name="pip_menu_bounds">"596 280 1324 690"</string> <!-- Gravity of letterboxed apps in portrait screen orientation. Can be Gravity.TOP, Gravity.CENTER or Gravity.BOTTOM. Any other value will result in runtime exception for a letterboxed activity. Default is Gravity.TOP. --> <integer name="config_letterboxPortraitGravity">0x00000030</integer> <!-- Gravity of letterboxed apps in landscape screen orientation. Can be Gravity.LEFT, Gravity.CENTER or Gravity.RIGHT. Any other value will result in runtime exception for a letterboxed activity. Default is Gravity.CENTER. --> <integer name="config_letterboxLandscapeGravity">0x00000011</integer> </resources>
libs/WindowManager/Shell/src/com/android/wm/shell/FullscreenTaskListener.java +5 −2 Original line number Diff line number Diff line Loading @@ -32,14 +32,17 @@ import com.android.wm.shell.protolog.ShellProtoLogGroup; import java.io.PrintWriter; class FullscreenTaskListener implements ShellTaskOrganizer.TaskListener { /** * Organizes tasks presented in {@link android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN}. */ public class FullscreenTaskListener implements ShellTaskOrganizer.TaskListener { private static final String TAG = "FullscreenTaskListener"; private final SyncTransactionQueue mSyncQueue; private final ArraySet<Integer> mTasks = new ArraySet<>(); FullscreenTaskListener(SyncTransactionQueue syncQueue) { public FullscreenTaskListener(SyncTransactionQueue syncQueue) { mSyncQueue = syncQueue; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/LetterboxTaskListener.javadeleted 100644 → 0 +0 −110 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell; import android.app.ActivityManager; import android.graphics.Point; import android.graphics.Rect; import android.util.Slog; import android.util.SparseArray; import android.view.SurfaceControl; import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.protolog.ShellProtoLogGroup; /** * Organizes a task in {@link android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN} when * it's presented in the letterbox mode either because orientations of a top activity and a device * don't match or because a top activity is in a size compat mode. */ final class LetterboxTaskListener implements ShellTaskOrganizer.TaskListener { private static final String TAG = "LetterboxTaskListener"; private final SyncTransactionQueue mSyncQueue; private final SparseArray<SurfaceControl> mLeashByTaskId = new SparseArray<>(); LetterboxTaskListener(SyncTransactionQueue syncQueue) { mSyncQueue = syncQueue; } @Override public void onTaskAppeared(ActivityManager.RunningTaskInfo taskInfo, SurfaceControl leash) { synchronized (mLeashByTaskId) { if (mLeashByTaskId.get(taskInfo.taskId) != null) { throw new RuntimeException("Task appeared more than once: #" + taskInfo.taskId); } ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TASK_ORG, "Letterbox Task Appeared: #%d", taskInfo.taskId); mLeashByTaskId.put(taskInfo.taskId, leash); final Rect taskBounds = taskInfo.getConfiguration().windowConfiguration.getBounds(); final Rect activtyBounds = taskInfo.letterboxActivityBounds; final Point taskPositionInParent = taskInfo.positionInParent; mSyncQueue.runInSync(t -> { setPositionAndWindowCrop( t, leash, activtyBounds, taskBounds, taskPositionInParent); if (!Transitions.ENABLE_SHELL_TRANSITIONS) { t.setAlpha(leash, 1f); t.setMatrix(leash, 1, 0, 0, 1); t.show(leash); } }); } } @Override public void onTaskVanished(ActivityManager.RunningTaskInfo taskInfo) { synchronized (mLeashByTaskId) { if (mLeashByTaskId.get(taskInfo.taskId) == null) { Slog.e(TAG, "Task already vanished: #" + taskInfo.taskId); return; } mLeashByTaskId.remove(taskInfo.taskId); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TASK_ORG, "Letterbox Task Vanished: #%d", taskInfo.taskId); } } @Override public void onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo) { synchronized (mLeashByTaskId) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TASK_ORG, "Letterbox Task Changed: #%d", taskInfo.taskId); final SurfaceControl leash = mLeashByTaskId.get(taskInfo.taskId); final Rect taskBounds = taskInfo.getConfiguration().windowConfiguration.getBounds(); final Rect activtyBounds = taskInfo.letterboxActivityBounds; final Point taskPositionInParent = taskInfo.positionInParent; mSyncQueue.runInSync(t -> { setPositionAndWindowCrop( t, leash, activtyBounds, taskBounds, taskPositionInParent); }); } } private static void setPositionAndWindowCrop( SurfaceControl.Transaction transaction, SurfaceControl leash, final Rect activityBounds, final Rect taskBounds, final Point taskPositionInParent) { Rect activtyInTaskCoordinates = new Rect(activityBounds); activtyInTaskCoordinates.offset(-taskBounds.left, -taskBounds.top); transaction.setPosition(leash, taskPositionInParent.x, taskPositionInParent.y); transaction.setWindowCrop(leash, activtyInTaskCoordinates); } }