Merge "Fix letterbox issue when auto-enter-pip from landscape" into sc-v2-dev
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2197,6 +2197,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);
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.Display.INVALID_DISPLAY;
|
||||
import static android.view.SurfaceControl.METADATA_TASK_ID;
|
||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
|
||||
import static android.view.WindowManager.TRANSIT_CHANGE;
|
||||
import static android.view.WindowManager.TRANSIT_CLOSE;
|
||||
@@ -3335,6 +3337,7 @@ class Task extends TaskFragment {
|
||||
info.positionInParent = getRelativePosition();
|
||||
|
||||
info.pictureInPictureParams = getPictureInPictureParams(top);
|
||||
info.displayCutoutInsets = getDisplayCutoutInsets(top);
|
||||
info.topActivityInfo = mReuseActivitiesReport.top != null
|
||||
? mReuseActivitiesReport.top.info
|
||||
: null;
|
||||
@@ -3370,6 +3373,18 @@ class Task extends TaskFragment {
|
||||
? null : new PictureInPictureParams(topMostActivity.pictureInPictureArgs);
|
||||
}
|
||||
|
||||
private Rect getDisplayCutoutInsets(Task top) {
|
||||
if (top == null || top.mDisplayContent == null
|
||||
|| top.getDisplayInfo().displayCutout == null) return null;
|
||||
final WindowState w = top.getTopVisibleAppMainWindow();
|
||||
final int displayCutoutMode = w == null
|
||||
? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
|
||||
: w.getAttrs().layoutInDisplayCutoutMode;
|
||||
return (displayCutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
|
||||
|| displayCutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES)
|
||||
? null : top.getDisplayInfo().displayCutout.getSafeInsets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link TaskInfo} with information from this task.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user