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

Commit 70dd96ce authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Fix letterbox issue when auto-enter-pip from landscape

Included in this CL
- Skip layout of window when in transition to PiP mode
- Pass display cutout info via TaskInfo
- Removed TaskInfoCompat

Video: http://recall/-/aaaaaabFQoRHlzixHdtY/bpKcGg1eoOo5Jz5U6IwBYK
Bug: 191310680
Test: manual, auto-enter-pip from landscape with source rect hint being
      turned on, see the video
Change-Id: Ie657d15d9edb9d07555bd166b5919bb12cb217e6
parent d3e71a78
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -29,11 +29,13 @@ import android.content.LocusId;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Build;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
import android.view.DisplayCutout;
import android.window.TaskSnapshot;
import android.window.WindowContainerToken;

@@ -180,6 +182,15 @@ public class TaskInfo {
    @Nullable
    public PictureInPictureParams pictureInPictureParams;

    /**
     * The {@link Rect} copied from {@link DisplayCutout#getSafeInsets()} if the cutout is not of
     * (LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS),
     * {@code null} otherwise.
     * @hide
     */
    @Nullable
    public Rect displayCutoutInsets;

    /**
     * The activity type of the top activity in this task.
     * @hide
@@ -345,6 +356,7 @@ public class TaskInfo {
                && displayAreaFeatureId == that.displayAreaFeatureId
                && Objects.equals(positionInParent, that.positionInParent)
                && Objects.equals(pictureInPictureParams, that.pictureInPictureParams)
                && Objects.equals(displayCutoutInsets, that.displayCutoutInsets)
                && getWindowingMode() == that.getWindowingMode()
                && Objects.equals(taskDescription, that.taskDescription)
                && isFocused == that.isFocused
@@ -396,6 +408,7 @@ public class TaskInfo {
        token = WindowContainerToken.CREATOR.createFromParcel(source);
        topActivityType = source.readInt();
        pictureInPictureParams = source.readTypedObject(PictureInPictureParams.CREATOR);
        displayCutoutInsets = source.readTypedObject(Rect.CREATOR);
        topActivityInfo = source.readTypedObject(ActivityInfo.CREATOR);
        isResizeable = source.readBoolean();
        source.readBinderList(launchCookies);
@@ -435,6 +448,7 @@ public class TaskInfo {
        token.writeToParcel(dest, flags);
        dest.writeInt(topActivityType);
        dest.writeTypedObject(pictureInPictureParams, flags);
        dest.writeTypedObject(displayCutoutInsets, flags);
        dest.writeTypedObject(topActivityInfo, flags);
        dest.writeBoolean(isResizeable);
        dest.writeBinderList(launchCookies);
@@ -465,6 +479,7 @@ public class TaskInfo {
                + " token=" + token
                + " topActivityType=" + topActivityType
                + " pictureInPictureParams=" + pictureInPictureParams
                + " displayCutoutSafeInsets=" + displayCutoutInsets
                + " topActivityInfo=" + topActivityInfo
                + " launchCookies=" + launchCookies
                + " positionInParent=" + positionInParent
+0 −67
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.systemui.shared.system;

import android.app.ActivityManager;
import android.app.PictureInPictureParams;
import android.app.TaskInfo;
import android.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.graphics.Rect;

public class TaskInfoCompat {

    public static int getUserId(TaskInfo info) {
        return info.userId;
    }

    public static int getActivityType(TaskInfo info) {
        return info.configuration.windowConfiguration.getActivityType();
    }

    public static int getWindowingMode(TaskInfo info) {
        return info.configuration.windowConfiguration.getWindowingMode();
    }

    public static Rect getWindowConfigurationBounds(TaskInfo info) {
        return info.configuration.windowConfiguration.getBounds();
    }

    public static boolean supportsSplitScreenMultiWindow(TaskInfo info) {
        return info.supportsSplitScreenMultiWindow;
    }

    public static ComponentName getTopActivity(TaskInfo info) {
        return info.topActivity;
    }

    public static ActivityManager.TaskDescription getTaskDescription(TaskInfo info) {
        return info.taskDescription;
    }

    public static ActivityInfo getTopActivityInfo(TaskInfo info) {
        return info.topActivityInfo;
    }

    public static boolean isAutoEnterPipEnabled(PictureInPictureParams params) {
        return params.isAutoEnterEnabled();
    }

    public static Rect getPipSourceRectHint(PictureInPictureParams params) {
        return params.getSourceRectHint();
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -830,6 +830,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    // Tracking cookie for the launch of this activity and it's task.
    IBinder mLaunchCookie;

    // Entering PiP is usually done in two phases, we put the task into pinned mode first and
    // SystemUi sets the pinned mode on activity after transition is done.
    boolean mWaitForEnteringPinnedMode;

    private final Runnable mPauseTimeoutRunnable = new Runnable() {
        @Override
        public void run() {
@@ -7894,6 +7898,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // mode (see RootWindowContainer#moveActivityToPinnedRootTask). So once the windowing mode
        // of activity is changed, it is the signal of the last step to update the PiP states.
        if (!wasInPictureInPicture && inPinnedWindowingMode() && task != null) {
            mWaitForEnteringPinnedMode = false;
            mTaskSupervisor.scheduleUpdatePictureInPictureModeIfNeeded(task, task.getBounds());
        }

+4 −0
Original line number Diff line number Diff line
@@ -1648,6 +1648,10 @@ public class DisplayPolicy {
            layoutStatusBar(displayFrames, mBarContentFrames.get(TYPE_STATUS_BAR));
            return;
        }
        if (win.mActivityRecord != null && win.mActivityRecord.mWaitForEnteringPinnedMode) {
            // Skip layout of the window when in transition to pip mode.
            return;
        }
        final WindowManager.LayoutParams attrs = win.getLayoutingAttrs(displayFrames.mRotation);

        final int type = attrs.type;
+1 −0
Original line number Diff line number Diff line
@@ -2192,6 +2192,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            // from doing work and changing the activity visuals while animating
            // TODO(task-org): Figure-out more structured way to do this long term.
            r.setWindowingMode(intermediateWindowingMode);
            r.mWaitForEnteringPinnedMode = true;
            rootTask.setWindowingMode(WINDOWING_MODE_PINNED);
            rootTask.setDeferTaskAppear(false);

Loading