summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2024-10-07 15:08:52 +0800
committer Riddle Hsu <riddlehsu@google.com> 2024-10-07 15:09:25 +0800
commitb42a35104d86eb81ef100b6f12b41a3667541b64 (patch)
tree5a1a9a33ee6908237d1e012f525eed774e9b8111
parentd8aa9a2a6156c355cae1e2b1e9bc863d09765499 (diff)
Reduce unnecessary invocation of fillTaskInfo
The getTaskInfo invokes fillTaskInfo, which is heavy to fill lots of fields. But the specified caller only needs 2 attributes of the task, which is unnecessary to get entire task info that populates many unrelated fields. Bug: 297502610 Flag: EXEMPT remove unnecessary invocation Test: atest DesktopModeLaunchParamsModifierTests Change-Id: I99a9e5306bf16d614ab4f6791f399b3cfe4ff314
-rw-r--r--services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java13
1 files changed, 6 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java b/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java
index 34b5f6a24d41..1a8f5fc46827 100644
--- a/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java
+++ b/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java
@@ -30,7 +30,6 @@ import static com.android.server.wm.LaunchParamsUtil.calculateLayoutBounds;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityOptions;
-import android.app.TaskInfo;
import android.content.pm.ActivityInfo.ScreenOrientation;
import android.content.pm.ActivityInfo.WindowLayout;
import android.graphics.Rect;
@@ -98,7 +97,6 @@ public final class DesktopModeBoundsCalculator {
private static Rect calculateInitialBounds(@NonNull Task task,
@NonNull ActivityRecord activity, @NonNull Rect stableBounds
) {
- final TaskInfo taskInfo = task.getTaskInfo();
// Display bounds not taking into account insets.
final TaskDisplayArea displayArea = task.getDisplayArea();
final Rect screenBounds = displayArea.getBounds();
@@ -118,14 +116,15 @@ public final class DesktopModeBoundsCalculator {
float appAspectRatio = desktopAppCompatAspectRatioPolicy.calculateAspectRatio(task);
final float tdaWidth = stableBounds.width();
final float tdaHeight = stableBounds.height();
+ final int taskConfigOrientation = task.getConfiguration().orientation;
final int activityOrientation = getActivityOrientation(activity, task);
- final Size initialSize = switch (taskInfo.configuration.orientation) {
+ final Size initialSize = switch (taskConfigOrientation) {
case ORIENTATION_LANDSCAPE -> {
// Device in landscape orientation.
if (appAspectRatio == 0) {
appAspectRatio = 1;
}
- if (canChangeAspectRatio(desktopAppCompatAspectRatioPolicy, taskInfo, task)) {
+ if (canChangeAspectRatio(desktopAppCompatAspectRatioPolicy, task)) {
if (isFixedOrientationPortrait(activityOrientation)) {
// For portrait resizeable activities, respect apps fullscreen width but
// apply ideal size height.
@@ -143,7 +142,7 @@ public final class DesktopModeBoundsCalculator {
// Device in portrait orientation.
final int customPortraitWidthForLandscapeApp = screenBounds.width()
- (DESKTOP_MODE_LANDSCAPE_APP_PADDING * 2);
- if (canChangeAspectRatio(desktopAppCompatAspectRatioPolicy, taskInfo, task)) {
+ if (canChangeAspectRatio(desktopAppCompatAspectRatioPolicy, task)) {
if (isFixedOrientationLandscape(activityOrientation)) {
if (appAspectRatio == 0) {
appAspectRatio = tdaWidth / (tdaWidth - 1);
@@ -182,8 +181,8 @@ public final class DesktopModeBoundsCalculator {
*/
private static boolean canChangeAspectRatio(
@NonNull DesktopAppCompatAspectRatioPolicy desktopAppCompatAspectRatioPolicy,
- @NonNull TaskInfo taskInfo, @NonNull Task task) {
- return taskInfo.isResizeable
+ @NonNull Task task) {
+ return task.isResizeable()
&& !desktopAppCompatAspectRatioPolicy.hasMinAspectRatioOverride(task);
}