Merge "Handle insets for letterboxing correctly" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-03-27 15:10:27 +00:00
committed by Android (Google) Code Review
5 changed files with 94 additions and 14 deletions

View File

@@ -51,6 +51,7 @@ import android.view.SurfaceControl.Transaction;
import com.google.android.collect.Sets;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
import com.android.server.wm.utils.InsetUtils;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -400,9 +401,11 @@ public class RecentsAnimationController {
if (mainWindow == null) {
return null;
}
final Rect insets = new Rect(mainWindow.mContentInsets);
InsetUtils.addInsets(insets, mainWindow.mAppToken.getLetterboxInsets());
mTarget = new RemoteAnimationTarget(mTask.mTaskId, MODE_CLOSING, mCapturedLeash,
!mTask.fillsParent(), mainWindow.mWinAnimator.mLastClipRect,
mainWindow.mContentInsets, mTask.getPrefixOrderIndex(), position, bounds,
insets, mTask.getPrefixOrderIndex(), position, bounds,
mTask.getWindowConfiguration(), mIsRecentTaskInvisible);
return mTarget;
}

View File

@@ -37,6 +37,7 @@ import android.view.SurfaceControl.Transaction;
import com.android.internal.util.FastPrintWriter;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
import com.android.server.wm.utils.InsetUtils;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -235,9 +236,11 @@ class RemoteAnimationController {
|| mCapturedLeash == null) {
return null;
}
final Rect insets = new Rect(mainWindow.mContentInsets);
InsetUtils.addInsets(insets, mAppWindowToken.getLetterboxInsets());
mTarget = new RemoteAnimationTarget(task.mTaskId, getMode(),
mCapturedLeash, !mAppWindowToken.fillsParent(),
mainWindow.mWinAnimator.mLastClipRect, mainWindow.mContentInsets,
mainWindow.mWinAnimator.mLastClipRect, insets,
mAppWindowToken.getPrefixOrderIndex(), mPosition, mStackBounds,
task.getWindowConfiguration(), false /*isNotInRecents*/);
return mTarget;

View File

@@ -27,7 +27,6 @@ import android.app.ActivityManager;
import android.app.ActivityManager.TaskSnapshot;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.GraphicBuffer;
import android.graphics.Rect;
import android.os.Environment;
@@ -45,6 +44,7 @@ import com.android.internal.graphics.ColorUtils;
import com.android.server.policy.WindowManagerPolicy.ScreenOffListener;
import com.android.server.policy.WindowManagerPolicy.StartingSurface;
import com.android.server.wm.TaskSnapshotSurface.SystemBarBackgroundPainter;
import com.android.server.wm.utils.InsetUtils;
import com.google.android.collect.Sets;
@@ -273,7 +273,7 @@ class TaskSnapshotController {
return null;
}
return new TaskSnapshot(buffer, top.getConfiguration().orientation,
getInsetsFromTaskBounds(mainWindow, task),
getInsets(mainWindow),
isLowRamDevice /* reduced */, scaleFraction /* scale */,
true /* isRealSnapshot */);
}
@@ -282,11 +282,11 @@ class TaskSnapshotController {
return mIsRunningOnWear || mIsRunningOnTv || mIsRunningOnIoT;
}
private Rect getInsetsFromTaskBounds(WindowState state, Task task) {
private Rect getInsets(WindowState state) {
// XXX(b/72757033): These are insets relative to the window frame, but we're really
// interested in the insets relative to the task bounds.
Rect insets = minRect(state.mContentInsets, state.mStableInsets);
insets = maxRect(insets, state.mAppToken.getLetterboxInsets());
final Rect insets = minRect(state.mContentInsets, state.mStableInsets);
InsetUtils.addInsets(insets, state.mAppToken.getLetterboxInsets());
return insets;
}
@@ -297,13 +297,6 @@ class TaskSnapshotController {
Math.min(rect1.bottom, rect2.bottom));
}
private Rect maxRect(Rect rect1, Rect rect2) {
return new Rect(Math.max(rect1.left, rect2.left),
Math.max(rect1.top, rect2.top),
Math.max(rect1.right, rect2.right),
Math.max(rect1.bottom, rect2.bottom));
}
/**
* Retrieves all closing tasks based on the list of closing apps during an app transition.
*/

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2018 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.server.wm.utils;
import android.graphics.Rect;
/**
* Utility methods to handle insets represented as rects.
*/
public class InsetUtils {
private InsetUtils() {
}
/**
* Adds {@code insetsToAdd} to {@code inOutInsets}.
*/
public static void addInsets(Rect inOutInsets, Rect insetsToAdd) {
inOutInsets.left += insetsToAdd.left;
inOutInsets.top += insetsToAdd.top;
inOutInsets.right += insetsToAdd.right;
inOutInsets.bottom += insetsToAdd.bottom;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2018 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.server.wm.utils;
import static junit.framework.Assert.assertEquals;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.util.Pair;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
@Presubmit
public class InsetUtilsTest {
@Test
public void testAdd() throws Exception {
final Rect rect1 = new Rect(10, 20, 30, 40);
final Rect rect2 = new Rect(50, 60, 70, 80);
InsetUtils.addInsets(rect1, rect2);
assertEquals(new Rect(60, 80, 100, 120), rect1);
}
}