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

Commit e75553ab authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge changes Ibb3157da,Ia4d2b3a7,I338f50f0

* changes:
  Don't crop home activity windows to stack bounds.
  Use stack bounds to determine input bounds for window.
  Fixed issue with docked stack not showing when recents is up.
parents 7b9bfaf7 61b009e0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -98,11 +98,12 @@ interface IWindowManager
     * @param taskBounds Bounds to use when creating a new Task with the input task Id if
     *                   the task doesn't exist yet.
     * @param configuration Configuration that is being used with this task.
     * @param cropWindowsToStack True if the app windows should be cropped to the stack bounds.
     */
    void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId,
            int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId,
            int configChanges, boolean voiceInteraction, boolean launchTaskBehind,
            in Rect taskBounds, in Configuration configuration);
            in Rect taskBounds, in Configuration configuration, boolean cropWindowsToStack);
    /**
     *
     * @param token The token we are adding to the input task Id.
+55 −54
Original line number Diff line number Diff line
@@ -17,8 +17,11 @@
package com.android.server.am;

import static android.app.ActivityManager.DOCKED_STACK_ID;
import static android.app.ActivityManager.FIRST_STATIC_STACK_ID;
import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.HOME_STACK_ID;
import static android.app.ActivityManager.LAST_STATIC_STACK_ID;
import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;

import static com.android.server.am.ActivityManagerDebugConfig.*;
@@ -30,7 +33,7 @@ import static com.android.server.am.ActivityStackSupervisor.MOVING;

import android.graphics.Rect;
import android.util.ArraySet;
import android.view.IApplicationToken;

import com.android.internal.app.IVoiceInteractor;
import com.android.internal.content.ReferrerIntent;
import com.android.internal.os.BatteryStatsImpl;
@@ -1278,28 +1281,27 @@ final class ActivityStack {
        return false;
    }

    /** Return true if this stack is hidden by the presence of a docked stack. */
    private boolean isHiddenByDockedStack() {
        final ActivityStack dockedStack = mStackSupervisor.getStack(DOCKED_STACK_ID);
        if (dockedStack != null) {
            final int dockedStackIndex = mStacks.indexOf(dockedStack);
            final int stackIndex = mStacks.indexOf(this);
            if (dockedStackIndex > stackIndex) {
                // Fullscreen stacks or stacks with fullscreen task below the docked stack are not
                // visible. We do this so we don't have the 2 stacks and their tasks overlap.
                if (mFullscreen) {
                    return true;
                }
    private boolean hasTranslucentActivity(ActivityStack stack) {
        final ArrayList<TaskRecord> tasks = stack.getAllTasks();
        for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
            final TaskRecord task = tasks.get(taskNdx);
            final ArrayList<ActivityRecord> activities = task.mActivities;
            for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                final ActivityRecord r = activities.get(activityNdx);

                // We need to also check the tasks in the stack because they can be fullscreen
                // even though their stack isn't due to their root activity not been resizeable
                // (i.e. doesn't support multi-window mode).
                if (hasFullscreenTask()) {
                    return true;
                // Conditions for an activity to obscure the stack we're
                // examining:
                // 1. Not Finishing AND Visible AND:
                // 2. Either:
                // - Full Screen Activity OR
                // - On top of Home and our stack is NOT home
                if (!r.finishing && r.visible && (r.fullscreen ||
                        (!isHomeStack() && r.frontOfTask && task.isOverHomeStack()))) {
                    return false;
                }
            }
        }
        return false;
        return true;
    }

    /** Returns true if the stack is considered visible. */
@@ -1320,56 +1322,55 @@ final class ActivityStack {
            return false;
        }

        if (isHiddenByDockedStack()) {
        final ActivityStack focusedStack = mStackSupervisor.getFocusedStack();
        final int focusedStackId = focusedStack.mStackId;

        if (mStackId == DOCKED_STACK_ID) {
            // Docked stack is always visible, except in the case where the home activity
            // is the top running activity in the focused home stack.
            if (focusedStackId != HOME_STACK_ID) {
                return true;
            }
            ActivityRecord topHomeActivity = focusedStack.topRunningActivityLocked(null);
            return topHomeActivity == null || !topHomeActivity.isHomeActivity();
        }

        if (focusedStackId == DOCKED_STACK_ID
                && stackIndex == (mStacks.indexOf(focusedStack) - 1)) {
            // Stacks directly behind the docked stack are always visible.
            return true;
        }

        if (mStackId == HOME_STACK_ID && focusedStackId == FULLSCREEN_WORKSPACE_STACK_ID) {
            // Home stack is always visible behind the fullscreen stack with a translucent activity.
            // This is done so that the home stack can act as a background to the translucent
            // activity.
            return hasTranslucentActivity(focusedStack);
        }

        if (mStackId >= FIRST_STATIC_STACK_ID && mStackId <= LAST_STATIC_STACK_ID) {
            // Visibility of any static stack should have been determined by the conditions above.
            return false;
        }

        /**
         * Start at the task above this one and go up, looking for a visible
         * fullscreen activity, or a translucent activity that requested the
         * wallpaper to be shown behind it.
         */
        for (int i = stackIndex + 1; i < mStacks.size(); i++) {
            final ActivityStack stack = mStacks.get(i);
            final ArrayList<TaskRecord> tasks = stack.getAllTasks();

            if (!stack.mFullscreen && !stack.hasFullscreenTask()) {
                continue;
            }

            if (stack.mStackId == FREEFORM_WORKSPACE_STACK_ID
                    || stack.mStackId == HOME_STACK_ID) {
                // The freeform and home stacks can't have any other stack visible behind them
                // when they are fullscreen since they act as base/cut-off points for visibility.
                // NOTE: we don't cut-off at the FULLSCREEN_WORKSPACE_STACK_ID because the home
                // stack sometimes needs to be visible behind it when it is displaying a dialog
                // activity. We let it fall through to the logic below to determine visibility.
                    || stack.mStackId == HOME_STACK_ID
                    || stack.mStackId == FULLSCREEN_WORKSPACE_STACK_ID) {
                // These stacks can't have any dynamic stacks visible behind them.
                return false;
            }

            for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
                final TaskRecord task = tasks.get(taskNdx);
                // task above isn't fullscreen, so, we assume we're still visible.
                if (!task.mFullscreen) {
                    continue;
                }
                final ArrayList<ActivityRecord> activities = task.mActivities;
                for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                    final ActivityRecord r = activities.get(activityNdx);

                    // Conditions for an activity to obscure the stack we're
                    // examining:
                    // 1. Not Finishing AND Visible AND:
                    // 2. Either:
                    // - Full Screen Activity OR
                    // - On top of Home and our stack is NOT home
                    if (!r.finishing && r.visible && (r.fullscreen ||
                            (!isHomeStack() && r.frontOfTask && task.isOverHomeStack()))) {
            if (!hasTranslucentActivity(stack)) {
                return false;
            }
        }
            }
        }

        return true;
    }
@@ -4605,7 +4606,7 @@ final class ActivityStack {
                r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen,
                (r.info.flags & ActivityInfo.FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId,
                r.info.configChanges, task.voiceSession != null, r.mLaunchTaskBehind,
                bounds, task.mOverrideConfig);
                bounds, task.mOverrideConfig, !r.isHomeActivity());
        r.taskConfigOverride = task.mOverrideConfig;
    }

+3 −0
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@ class AppWindowToken extends WindowToken {
    boolean mLaunchTaskBehind;
    boolean mEnteringAnimation;

    // True if the windows associated with this token should be cropped to their stack bounds.
    boolean mCropWindowsToStack;

    // This application will have its window replaced due to relaunch. This allows window manager
    // to differentiate between simple removal of a window and replacement. In the latter case it
    // will preserve the old window until the new one is drawn.
+1 −1
Original line number Diff line number Diff line
@@ -415,7 +415,7 @@ class DragState {
                continue;
            }

            child.getTaskBounds(mTmpRect, !BOUNDS_FOR_TOUCH);
            child.getVisibleBounds(mTmpRect, !BOUNDS_FOR_TOUCH);
            if (!mTmpRect.contains(x, y)) {
                // outside of this window's activity stack == don't tell about drags
                continue;
+1 −1
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
        if (modal && child.mAppToken != null) {
            // Limit the outer touch to the activity stack region.
            flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
            child.getTaskBounds(mTmpRect, BOUNDS_FOR_TOUCH);
            child.getVisibleBounds(mTmpRect, BOUNDS_FOR_TOUCH);
            inputWindowHandle.touchableRegion.set(mTmpRect);
        } else {
            // Not modal or full screen modal
Loading