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

Commit 55893331 authored by Winson Chung's avatar Winson Chung
Browse files

Ensure we use the fullscreen stack bounds when expanding PiP.



- When in split screen, the PiP needs to animate to the fullscreen stack
  bounds when expanding.
- Created PinnedStackWindowController to house pinned-stack specific
  logic.

Bug: 35396882
Test: Expand PiP activity while split

Change-Id: If7397843743ce11b676f5566eba90e3442289fec
Signed-off-by: default avatarWinson Chung <winsonc@google.com>
parent 4a04f0fb
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -361,7 +361,6 @@ import com.android.server.SystemServiceManager;
import com.android.server.Watchdog;
import com.android.server.am.ActivityStack.ActivityState;
import com.android.server.firewall.IntentFirewall;
import com.android.server.net.NetworkPolicyManagerService;
import com.android.server.pm.Installer;
import com.android.server.pm.Installer.InstallerException;
import com.android.server.statusbar.StatusBarManagerInternal;
@@ -7722,7 +7721,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);
@@ -7776,9 +7775,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());
                }
@@ -10340,7 +10339,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);
    }

    /**
@@ -2854,7 +2853,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;
@@ -2904,7 +2903,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();
    }

@@ -4365,7 +4364,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