Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dce2d161 authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

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

Also make sure that the bounds passed to stacks and tasks are not bogus,
as these would mess up the configuration.

Bug: 26512887
Change-Id: I1a3a9c867a2c258a326b31df2bac614ccbb00579
parent bc9029f1
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -4757,8 +4757,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,
@@ -4814,10 +4813,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;
    }
+5 −3
Original line number Diff line number Diff line
@@ -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).
+1 −1
Original line number Diff line number Diff line
@@ -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;
+14 −0
Original line number Diff line number Diff line
@@ -1310,6 +1310,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);
+7 −1
Original line number Diff line number Diff line
@@ -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) {