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

Commit 0e1d4e23 authored by Nick Chameyev's avatar Nick Chameyev
Browse files

Synchronize display change with the Shell

This CL adds synchronization of applying of the window
container transaction with split-screen layout changes after
the display size change. This is needed for the unfold
animation to have the split screen layout ready
for the first frame of the unfold animation on foldable
devices.

The flow is similar to the display rotation synchonization,
now it is triggered on both physical display change and
rotation.

Bug: 204925795
Test: folding/unfolding, rotating with a split layout
  when Shell transitions enabled/disabled
Change-Id: I30f391dae69cf38768daf49361660d87165f886d
parent c3565a50
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -17,13 +17,15 @@
package android.view;

import android.window.WindowContainerTransaction;
import android.window.DisplayAreaInfo;

/**
 * Interface to be invoked by the controller when it has finished preparing for a display rotation.
 * Interface to be invoked by the controller when it has finished preparing for a display
 * size change.
 *
 * @see IDisplayWindowRotationController
 * @see IDisplayChangeWindowController
 * @hide
 */
interface IDisplayWindowRotationCallback {
    void continueRotateDisplay(int targetRotation, in WindowContainerTransaction t);
interface IDisplayChangeWindowCallback {
    void continueDisplayChange(in WindowContainerTransaction t);
}
+13 −11
Original line number Diff line number Diff line
@@ -16,11 +16,12 @@

package android.view;

import android.view.IDisplayWindowRotationCallback;
import android.view.IDisplayChangeWindowCallback;
import android.window.DisplayAreaInfo;

/**
 * Singular controller of a "remote" display rotation. When a display rotation is started, WM
 * freezes the screen. It will then call into this controller and wait for a response via the
 * Singular controller of a "remote" display change. When a display rotation or change is started,
 * WM freezes the screen. It will then call into this controller and wait for a response via the
 * callback.
 *
 * This needs to provide configuration changes because those changes need to be applied in sync
@@ -36,17 +37,18 @@ import android.view.IDisplayWindowRotationCallback;
 *
 * @hide
 */
oneway interface IDisplayWindowRotationController {
oneway interface IDisplayChangeWindowController {

    /**
     * Called when WM needs to know how to update tasks in response to a display rotation.
     * If this isn't called, a timeout will continue the rotation in WM.
     * Called when WM needs to know how to update tasks in response to a display change.
     * If this isn't called, a timeout will continue the change in WM.
     *
     * @param displayId the display that is rotating.
     * @param fromRotation the rotation the display is rotating from.
     * @param toRotation the rotation the display is rotating to.
     * @param fromRotation the old rotation
     * @param newRotation the new rotation
     * @param newDisplayAreaInfo the new display area info after the change
     * @param callback A callback to be called when this has calculated updated configs.
     */
    void onRotateDisplay(int displayId, int fromRotation, int toRotation,
            in IDisplayWindowRotationCallback callback);
    void onDisplayChange(int displayId, int fromRotation, int toRotation,
            in DisplayAreaInfo newDisplayAreaInfo, in IDisplayChangeWindowCallback callback);

}
+2 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ import android.view.ICrossWindowBlurEnabledListener;
import android.view.IDisplayWindowInsetsController;
import android.view.IDisplayWindowListener;
import android.view.IDisplayFoldListener;
import android.view.IDisplayWindowRotationController;
import android.view.IDisplayChangeWindowController;
import android.view.IOnKeyguardExitResult;
import android.view.IPinnedTaskListener;
import android.view.IScrollCaptureResponseListener;
@@ -146,7 +146,7 @@ interface IWindowManager
     * controller is called after the display has "frozen" for a rotation and display rotation will
     * only continue once the controller has finished calculating associated configurations.
     */
    void setDisplayWindowRotationController(IDisplayWindowRotationController controller);
    void setDisplayChangeWindowController(IDisplayChangeWindowController controller);

    /**
     * Adds a root container that a client shell can populate with its own windows (usually via
+24 −6
Original line number Diff line number Diff line
@@ -469,6 +469,12 @@
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/ResetTargetTaskHelper.java"
    },
    "-1635750891": {
      "message": "Received remote change for Display[%d], applied: [%dx%d, rot = %d]",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONFIGURATION",
      "at": "com\/android\/server\/wm\/RemoteDisplayChangeController.java"
    },
    "-1633115609": {
      "message": "Key dispatch not paused for screen off",
      "level": "VERBOSE",
@@ -3391,12 +3397,6 @@
      "group": "WM_DEBUG_BOOT",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "1246035185": {
      "message": "stopFreezingDisplayLocked: Returning waitingForConfig=%b, waitingForRemoteRotation=%b, mAppsFreezingScreen=%d, mWindowsFreezingScreen=%d, mClientFreezingScreen=%b, mOpeningApps.size()=%d",
      "level": "DEBUG",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "1252594551": {
      "message": "Window types in WindowContext and LayoutParams.type should match! Type from LayoutParams is %d, but type from WindowContext is %d",
      "level": "WARN",
@@ -3493,6 +3493,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ScreenRotationAnimation.java"
    },
    "1360176455": {
      "message": "stopFreezingDisplayLocked: Returning waitingForConfig=%b, waitingForRemoteDisplayChange=%b, mAppsFreezingScreen=%d, mWindowsFreezingScreen=%d, mClientFreezingScreen=%b, mOpeningApps.size()=%d",
      "level": "DEBUG",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "1364126018": {
      "message": "Resumed activity; dropping state of: %s",
      "level": "INFO",
@@ -3517,6 +3523,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/TaskDisplayArea.java"
    },
    "1393721079": {
      "message": "Starting remote display change: from [rot = %d], to [%dx%d, rot = %d]",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONFIGURATION",
      "at": "com\/android\/server\/wm\/RemoteDisplayChangeController.java"
    },
    "1396893178": {
      "message": "createRootTask unknown displayId=%d",
      "level": "ERROR",
@@ -3859,6 +3871,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowStateAnimator.java"
    },
    "1764619787": {
      "message": "Remote change for Display[%d]: timeout reached",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONFIGURATION",
      "at": "com\/android\/server\/wm\/RemoteDisplayChangeController.java"
    },
    "1774661765": {
      "message": "Devices still not ready after waiting %d milliseconds before attempting to detect safe mode.",
      "level": "WARN",
+7 −13
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.window.WindowContainerTransaction;

import androidx.annotation.MainThread;
import androidx.annotation.Nullable;
@@ -89,7 +88,6 @@ import com.android.internal.statusbar.IStatusBarService;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.TaskViewTransitions;
import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.common.DisplayChangeController;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.FloatingContentCoordinator;
import com.android.wm.shell.common.ShellExecutor;
@@ -423,10 +421,7 @@ public class BubbleController {
        });

        mDisplayController.addDisplayChangingController(
                new DisplayChangeController.OnDisplayChangingListener() {
                    @Override
                    public void onRotateDisplay(int displayId, int fromRotation, int toRotation,
                            WindowContainerTransaction t) {
                (displayId, fromRotation, toRotation, newDisplayAreaInfo, t) -> {
                    // This is triggered right before the rotation is applied
                    if (fromRotation != toRotation) {
                        if (mStackView != null) {
@@ -435,7 +430,6 @@ public class BubbleController {
                            mStackView.onOrientationChanged();
                        }
                    }
                    }
                });

        mOneHandedOptional.ifPresent(this::registerOneHandedState);
Loading