Merge "Only request stack resize after non full screen bounds were set."

This commit is contained in:
Filip Gruszczynski
2016-01-13 19:31:31 +00:00
committed by Android (Google) Code Review
5 changed files with 30 additions and 10 deletions

View File

@@ -4753,8 +4753,7 @@ final class ActivityStack {
}
void addConfigOverride(ActivityRecord r, TaskRecord task) {
final Rect bounds = task.getLaunchBounds();
task.updateOverrideConfiguration(bounds);
final Rect bounds = task.updateOverrideConfigurationFromLaunchBounds();
mWindowManager.addAppToken(task.mActivities.indexOf(r), r.appToken,
r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen,
(r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges,
@@ -4810,10 +4809,9 @@ final class ActivityStack {
}
private void setAppTask(ActivityRecord r, TaskRecord task) {
final Rect bounds = task.getLaunchBounds();
task.updateOverrideConfiguration(bounds);
final Rect bounds = task.updateOverrideConfigurationFromLaunchBounds();
mWindowManager.setAppTask(
r.appToken, task.taskId, mStackId, task.getLaunchBounds(), task.mOverrideConfig);
r.appToken, task.taskId, mStackId, bounds, task.mOverrideConfig);
mWindowManager.setTaskResizeable(task.taskId, task.mResizeable);
r.taskConfigOverride = task.mOverrideConfig;
}

View File

@@ -1673,7 +1673,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
if (task.mResizeable && options != null) {
int stackId = options.getLaunchStackId();
if (canUseActivityOptionsLaunchBounds(options, stackId)) {
Rect bounds = options.getLaunchBounds();
final Rect bounds = TaskRecord.validateBounds(options.getLaunchBounds());
task.updateOverrideConfiguration(bounds);
if (stackId == INVALID_STACK_ID) {
stackId = task.getLaunchStackId();
@@ -1841,6 +1841,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
// can have the right fullscreen state.
bounds = null;
}
bounds = TaskRecord.validateBounds(bounds);
mTmpBounds.clear();
mTmpConfigs.clear();
@@ -1857,8 +1858,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
fitWithinBounds(tempRect2, bounds);
task.updateOverrideConfiguration(tempRect2);
} else {
task.updateOverrideConfiguration(tempTaskBounds != null
? tempTaskBounds : bounds);
task.updateOverrideConfiguration(
tempTaskBounds != null ? tempTaskBounds : bounds);
}
}
@@ -1973,6 +1974,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
// Nothing to do here...
return true;
}
bounds = TaskRecord.validateBounds(bounds);
if (!mWindowManager.isValidTaskId(task.taskId)) {
// Task doesn't exist in window manager yet (e.g. was restored from recents).

View File

@@ -1739,7 +1739,7 @@ class ActivityStarter {
if (options != null && (r.isResizeable() || (inTask != null && inTask.mResizeable))) {
if (mSupervisor.canUseActivityOptionsLaunchBounds(
options, options.getLaunchStackId())) {
newBounds = options.getLaunchBounds();
newBounds = TaskRecord.validateBounds(options.getLaunchBounds());
}
}
return newBounds;

View File

@@ -1311,6 +1311,20 @@ final class TaskRecord {
return !mOverrideConfig.equals(oldConfig) ? mOverrideConfig : null;
}
Rect updateOverrideConfigurationFromLaunchBounds() {
final Rect bounds = validateBounds(getLaunchBounds());
updateOverrideConfiguration(bounds);
return bounds;
}
static Rect validateBounds(Rect bounds) {
if (bounds != null && bounds.isEmpty()) {
Slog.wtf(TAG, "Received strange task bounds: " + bounds, new Throwable());
return null;
}
return bounds;
}
private void reportMultiWindowModeChange() {
for (int i = mActivities.size() - 1; i >= 0; i--) {
final ActivityRecord r = mActivities.get(i);

View File

@@ -18,7 +18,6 @@ package com.android.server.wm;
import android.app.ActivityManager.StackId;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Debug;
import android.util.EventLog;
@@ -89,6 +88,7 @@ public class TaskStack implements DimLayer.DimLayerUser {
/** Detach this stack from its display when animation completes. */
boolean mDeferDetach;
private boolean mUpdateBoundsAfterRotation = false;
TaskStack(WindowManagerService service, int stackId) {
mService = service;
@@ -239,6 +239,7 @@ public class TaskStack implements DimLayer.DimLayerUser {
}
void updateDisplayInfo(Rect bounds) {
mUpdateBoundsAfterRotation = false;
if (mDisplayContent != null) {
for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent);
@@ -248,6 +249,7 @@ public class TaskStack implements DimLayer.DimLayerUser {
} else if (mFullscreen) {
setBounds(null);
} else {
mUpdateBoundsAfterRotation = true;
mTmpRect2.set(mBounds);
final int newRotation = mDisplayContent.getDisplayInfo().rotation;
if (mRotation == newRotation) {
@@ -265,6 +267,10 @@ public class TaskStack implements DimLayer.DimLayerUser {
* yet.
*/
void updateBoundsAfterRotation() {
if (!mUpdateBoundsAfterRotation) {
return;
}
mUpdateBoundsAfterRotation = false;
final int newRotation = getDisplayInfo().rotation;
mDisplayContent.rotateBounds(mRotation, newRotation, mTmpRect2);
if (mStackId == DOCKED_STACK_ID) {