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

Commit 4098172f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ensure we use the fullscreen stack bounds when expanding PiP."

parents 57611581 55893331
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -7694,7 +7694,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                            aspectRatio);
                    mStackSupervisor.moveActivityToPinnedStackLocked(r, "enterPictureInPictureMode",
                            bounds, true /* moveHomeStackToFront */);
                    final ActivityStack stack = mStackSupervisor.getStack(PINNED_STACK_ID);
                    final PinnedActivityStack stack = mStackSupervisor.getStack(PINNED_STACK_ID);
                    stack.setPictureInPictureAspectRatio(aspectRatio);
                    stack.setPictureInPictureActions(actions);
@@ -7748,9 +7748,9 @@ public class ActivityManagerService extends IActivityManager.Stub
                // Only update the saved args from the args that are set
                r.pictureInPictureArgs.copyOnlySet(args);
                final ActivityStack stack = r.getStack();
                if (stack.getStackId() == PINNED_STACK_ID) {
                if (r.getStack().getStackId() == PINNED_STACK_ID) {
                    // If the activity is already in picture-in-picture, update the pinned stack now
                    final PinnedActivityStack stack = r.getStack();
                    stack.setPictureInPictureAspectRatio(r.pictureInPictureArgs.getAspectRatio());
                    stack.setPictureInPictureActions(r.pictureInPictureArgs.getActions());
                }
@@ -10312,7 +10312,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            synchronized (this) {
                if (animate) {
                    if (stackId == PINNED_STACK_ID) {
                        final ActivityStack pinnedStack =
                        final PinnedActivityStack pinnedStack =
                                mStackSupervisor.getStack(PINNED_STACK_ID);
                        pinnedStack.animateResizePinnedStack(bounds, animationDuration);
                    } else {
+2 −2
Original line number Diff line number Diff line
@@ -880,8 +880,8 @@ final class ActivityRecord implements AppWindowContainerListener {
    /**
     * @return Stack value from current task, null if there is no task.
     */
    ActivityStack getStack() {
        return task != null ? task.getStack() : null;
    <T extends ActivityStack> T getStack() {
        return task != null ? (T) task.getStack() : null;
    }

    boolean changeWindowTranslucency(boolean toOpaque) {
+10 −18
Original line number Diff line number Diff line
@@ -84,7 +84,6 @@ import android.app.ActivityManager.StackId;
import android.app.ActivityOptions;
import android.app.AppGlobals;
import android.app.IActivityController;
import android.app.RemoteAction;
import android.app.ResultInfo;
import android.content.ComponentName;
import android.content.Intent;
@@ -135,7 +134,8 @@ import java.util.Set;
/**
 * State and management of a single stack of activities.
 */
final class ActivityStack extends ConfigurationContainer implements StackWindowListener {
class ActivityStack<T extends StackWindowController> extends ConfigurationContainer
        implements StackWindowListener {

    private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityStack" : TAG_AM;
    private static final String TAG_ADD_REMOVE = TAG + POSTFIX_ADD_REMOVE;
@@ -247,7 +247,7 @@ final class ActivityStack extends ConfigurationContainer implements StackWindowL

    final ActivityManagerService mService;
    private final WindowManagerService mWindowManager;
    private StackWindowController mWindowContainerController;
    T mWindowContainerController;
    private final RecentTasks mRecentTasks;

    /**
@@ -462,14 +462,18 @@ final class ActivityStack extends ConfigurationContainer implements StackWindowL
                ? new LaunchingTaskPositioner() : null;
        final ActivityStackSupervisor.ActivityDisplay display = mActivityContainer.mActivityDisplay;
        mTmpRect2.setEmpty();
        mWindowContainerController = new StackWindowController(mStackId, this,
                display.mDisplayId, onTop, mTmpRect2);
        mWindowContainerController = createStackWindowController(display.mDisplayId, onTop,
                mTmpRect2);
        activityContainer.mStack = this;
        mStackSupervisor.mActivityContainers.put(mStackId, activityContainer);
        postAddToDisplay(display, mTmpRect2.isEmpty() ? null : mTmpRect2, onTop);
    }

    StackWindowController getWindowContainerController() {
    T createStackWindowController(int displayId, boolean onTop, Rect outBounds) {
        return (T) new StackWindowController(mStackId, this, displayId, onTop, outBounds);
    }

    T getWindowContainerController() {
        return mWindowContainerController;
    }

@@ -540,18 +544,6 @@ final class ActivityStack extends ConfigurationContainer implements StackWindowL
        mActivityContainer.mActivityDisplay.mDisplay.getSize(out);
    }

    void animateResizePinnedStack(Rect bounds, int animationDuration) {
        mWindowContainerController.animateResizePinnedStack(bounds, animationDuration);
    }

    void setPictureInPictureAspectRatio(float aspectRatio) {
        mWindowContainerController.setPictureInPictureAspectRatio(aspectRatio);
    }

    void setPictureInPictureActions(List<RemoteAction> actions) {
        mWindowContainerController.setPictureInPictureActions(actions);
    }

    void getStackDockedModeBounds(Rect outBounds, Rect outTempBounds, Rect outTempInsetBounds,
            boolean ignoreVisibility) {
        mWindowContainerController.getStackDockedModeBounds(outBounds, outTempBounds,
+15 −9
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
@@ -153,7 +152,6 @@ import android.provider.Settings.SettingNotFoundException;
import android.service.voice.IVoiceInteractionSession;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.IntArray;
import android.util.Slog;
@@ -2037,19 +2035,20 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
                || mService.mSupportsFreeformWindowManagement;
    }

    ActivityStack getStack(int stackId) {
    protected <T extends ActivityStack> T getStack(int stackId) {
        return getStack(stackId, !CREATE_IF_NEEDED, !ON_TOP);
    }

    ActivityStack getStack(int stackId, boolean createStaticStackIfNeeded, boolean createOnTop) {
    protected <T extends ActivityStack> T getStack(int stackId, boolean createStaticStackIfNeeded,
            boolean createOnTop) {
        final ActivityContainer activityContainer = mActivityContainers.get(stackId);
        if (activityContainer != null) {
            return activityContainer.mStack;
            return (T) activityContainer.mStack;
        }
        if (!createStaticStackIfNeeded || !StackId.isStaticStack(stackId)) {
            return null;
        }
        return createStackOnDisplay(stackId, DEFAULT_DISPLAY, createOnTop);
        return (T) createStackOnDisplay(stackId, DEFAULT_DISPLAY, createOnTop);
    }

    /**
@@ -2856,7 +2855,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D

        mWindowManager.deferSurfaceLayout();
        // Need to make sure the pinned stack exist so we can resize it below...
        final ActivityStack stack = getStack(PINNED_STACK_ID, CREATE_IF_NEEDED, ON_TOP);
        final PinnedActivityStack stack = getStack(PINNED_STACK_ID, CREATE_IF_NEEDED, ON_TOP);

        try {
            final TaskRecord task = r.task;
@@ -2906,7 +2905,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
        resumeFocusedStackTopActivityLocked();

        stack.animateResizePinnedStack(bounds, -1);
        stack.animateResizePinnedStack(bounds, -1 /* animationDuration */);
        mService.mTaskChangeNotificationController.notifyActivityPinned();
    }

@@ -4367,7 +4366,14 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            synchronized (mService) {
                mStackId = stackId;
                mActivityDisplay = activityDisplay;
                switch (mStackId) {
                    case PINNED_STACK_ID:
                        new PinnedActivityStack(this, mRecentTasks, onTop);
                        break;
                    default:
                        new ActivityStack(this, mRecentTasks, onTop);
                        break;
                }
                mIdString = "ActivtyContainer{" + mStackId + "}";
                if (DEBUG_STACK) Slog.d(TAG_STACK, "Creating " + this);
            }
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.am;

import android.app.RemoteAction;
import android.graphics.Rect;

import com.android.server.am.ActivityStackSupervisor.ActivityContainer;
import com.android.server.wm.PinnedStackWindowController;
import com.android.server.wm.StackWindowController;

import java.util.List;

/**
 * State and management of the pinned stack of activities.
 */
class PinnedActivityStack extends ActivityStack<PinnedStackWindowController> {

    PinnedActivityStack(ActivityContainer activityContainer,
            RecentTasks recentTasks, boolean onTop) {
        super(activityContainer, recentTasks, onTop);
    }

    @Override
    PinnedStackWindowController createStackWindowController(int displayId, boolean onTop,
            Rect outBounds) {
        return new PinnedStackWindowController(mStackId, this, displayId, onTop, outBounds);
    }

    void animateResizePinnedStack(Rect bounds, int animationDuration) {
        getWindowContainerController().animateResizePinnedStack(bounds, animationDuration);
    }

    void setPictureInPictureAspectRatio(float aspectRatio) {
        getWindowContainerController().setPictureInPictureAspectRatio(aspectRatio);
    }

    void setPictureInPictureActions(List<RemoteAction> actions) {
        getWindowContainerController().setPictureInPictureActions(actions);
    }
}
Loading