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

Commit 8fa39887 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I7f39961f,I91ea7c68 into main

* changes:
  Make App Header visibility follow status bar in full immersive
  Add top-padding to App Header when in full immersive
parents c9d743c5 f2c815d6
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -194,6 +194,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
            ActivityManager.RunningTaskInfo taskInfo,
            ActivityManager.RunningTaskInfo taskInfo,
            boolean applyStartTransactionOnDraw,
            boolean applyStartTransactionOnDraw,
            boolean setTaskCropAndPosition,
            boolean setTaskCropAndPosition,
            boolean isStatusBarVisible,
            boolean isKeyguardVisibleAndOccluded,
            InsetsState displayInsetsState) {
            InsetsState displayInsetsState) {
        relayoutParams.reset();
        relayoutParams.reset();
        relayoutParams.mRunningTaskInfo = taskInfo;
        relayoutParams.mRunningTaskInfo = taskInfo;
@@ -204,6 +206,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
                : R.dimen.freeform_decor_shadow_unfocused_thickness;
                : R.dimen.freeform_decor_shadow_unfocused_thickness;
        relayoutParams.mApplyStartTransactionOnDraw = applyStartTransactionOnDraw;
        relayoutParams.mApplyStartTransactionOnDraw = applyStartTransactionOnDraw;
        relayoutParams.mSetTaskPositionAndCrop = setTaskCropAndPosition;
        relayoutParams.mSetTaskPositionAndCrop = setTaskCropAndPosition;
        relayoutParams.mIsCaptionVisible = taskInfo.isFreeform()
                || (isStatusBarVisible && !isKeyguardVisibleAndOccluded);


        if (TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo)) {
        if (TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo)) {
            // If the app is requesting to customize the caption bar, allow input to fall
            // If the app is requesting to customize the caption bar, allow input to fall
@@ -240,7 +244,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        final WindowContainerTransaction wct = new WindowContainerTransaction();


        updateRelayoutParams(mRelayoutParams, taskInfo, applyStartTransactionOnDraw,
        updateRelayoutParams(mRelayoutParams, taskInfo, applyStartTransactionOnDraw,
                setTaskCropAndPosition, mDisplayController.getInsetsState(taskInfo.displayId));
                setTaskCropAndPosition, mIsStatusBarVisible, mIsKeyguardVisibleAndOccluded,
                mDisplayController.getInsetsState(taskInfo.displayId));


        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, mResult);
        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, mResult);
        // After this line, mTaskInfo is up-to-date and should be used instead of taskInfo
        // After this line, mTaskInfo is up-to-date and should be used instead of taskInfo
+42 −4
Original line number Original line Diff line number Diff line
@@ -51,6 +51,7 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Rect;
@@ -63,10 +64,12 @@ import android.os.UserHandle;
import android.util.Size;
import android.util.Size;
import android.util.Slog;
import android.util.Slog;
import android.view.Choreographer;
import android.view.Choreographer;
import android.view.InsetsState;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.SurfaceControl;
import android.view.View;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewConfiguration;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageButton;
import android.window.TaskSnapshot;
import android.window.TaskSnapshot;
@@ -445,8 +448,11 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            mHandleMenu.relayout(startT, mResult.mCaptionX);
            mHandleMenu.relayout(startT, mResult.mCaptionX);
        }
        }


        final boolean inFullImmersive = mDesktopRepository
                .isTaskInFullImmersiveState(taskInfo.taskId);
        updateRelayoutParams(mRelayoutParams, mContext, taskInfo, applyStartTransactionOnDraw,
        updateRelayoutParams(mRelayoutParams, mContext, taskInfo, applyStartTransactionOnDraw,
                shouldSetTaskPositionAndCrop);
                shouldSetTaskPositionAndCrop, mIsStatusBarVisible, mIsKeyguardVisibleAndOccluded,
                inFullImmersive, mDisplayController.getInsetsState(taskInfo.displayId));


        final WindowDecorLinearLayout oldRootView = mResult.mRootView;
        final WindowDecorLinearLayout oldRootView = mResult.mRootView;
        final SurfaceControl oldDecorationSurface = mDecorationContainerSurface;
        final SurfaceControl oldDecorationSurface = mDecorationContainerSurface;
@@ -494,8 +500,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            ));
            ));
        } else {
        } else {
            mWindowDecorViewHolder.bindData(new AppHeaderViewHolder.HeaderData(
            mWindowDecorViewHolder.bindData(new AppHeaderViewHolder.HeaderData(
                    mTaskInfo, TaskInfoKt.getRequestingImmersive(mTaskInfo),
                    mTaskInfo, TaskInfoKt.getRequestingImmersive(mTaskInfo), inFullImmersive
                    mDesktopRepository.isTaskInFullImmersiveState(mTaskInfo.taskId)
            ));
            ));
        }
        }
        Trace.endSection();
        Trace.endSection();
@@ -758,7 +763,11 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            Context context,
            Context context,
            ActivityManager.RunningTaskInfo taskInfo,
            ActivityManager.RunningTaskInfo taskInfo,
            boolean applyStartTransactionOnDraw,
            boolean applyStartTransactionOnDraw,
            boolean shouldSetTaskPositionAndCrop) {
            boolean shouldSetTaskPositionAndCrop,
            boolean isStatusBarVisible,
            boolean isKeyguardVisibleAndOccluded,
            boolean inFullImmersiveMode,
            @NonNull InsetsState displayInsetsState) {
        final int captionLayoutId = getDesktopModeWindowDecorLayoutId(taskInfo.getWindowingMode());
        final int captionLayoutId = getDesktopModeWindowDecorLayoutId(taskInfo.getWindowingMode());
        final boolean isAppHeader =
        final boolean isAppHeader =
                captionLayoutId == R.layout.desktop_mode_app_header;
                captionLayoutId == R.layout.desktop_mode_app_header;
@@ -769,6 +778,28 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        relayoutParams.mCaptionHeightId = getCaptionHeightIdStatic(taskInfo.getWindowingMode());
        relayoutParams.mCaptionHeightId = getCaptionHeightIdStatic(taskInfo.getWindowingMode());
        relayoutParams.mCaptionWidthId = getCaptionWidthId(relayoutParams.mLayoutResId);
        relayoutParams.mCaptionWidthId = getCaptionWidthId(relayoutParams.mLayoutResId);


        final boolean showCaption;
        if (Flags.enableFullyImmersiveInDesktop()) {
            if (inFullImmersiveMode) {
                showCaption = isStatusBarVisible && !isKeyguardVisibleAndOccluded;
            } else {
                showCaption = taskInfo.isFreeform()
                        || (isStatusBarVisible && !isKeyguardVisibleAndOccluded);
            }
        } else {
            // Caption should always be visible in freeform mode. When not in freeform,
            // align with the status bar except when showing over keyguard (where it should not
            // shown).
            //  TODO(b/356405803): Investigate how it's possible for the status bar visibility to
            //   be false while a freeform window is open if the status bar is always
            //   forcibly-shown. It may be that the InsetsState (from which |mIsStatusBarVisible|
            //   is set) still contains an invisible insets source in immersive cases even if the
            //   status bar is shown?
            showCaption = taskInfo.isFreeform()
                    || (isStatusBarVisible && !isKeyguardVisibleAndOccluded);
        }
        relayoutParams.mIsCaptionVisible = showCaption;

        if (isAppHeader) {
        if (isAppHeader) {
            if (TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo)) {
            if (TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo)) {
                // If the app is requesting to customize the caption bar, allow input to fall
                // If the app is requesting to customize the caption bar, allow input to fall
@@ -787,6 +818,13 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                // including non-immersive apps that just don't handle caption insets properly.
                // including non-immersive apps that just don't handle caption insets properly.
                relayoutParams.mInsetSourceFlags |= FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR;
                relayoutParams.mInsetSourceFlags |= FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR;
            }
            }
            if (Flags.enableFullyImmersiveInDesktop() && inFullImmersiveMode) {
                final Insets systemBarInsets = displayInsetsState.calculateInsets(
                        taskInfo.getConfiguration().windowConfiguration.getBounds(),
                        WindowInsets.Type.systemBars() & ~WindowInsets.Type.captionBar(),
                        false /* ignoreVisibility */);
                relayoutParams.mCaptionTopPadding = systemBarInsets.top;
            }
            // Report occluding elements as bounding rects to the insets system so that apps can
            // Report occluding elements as bounding rects to the insets system so that apps can
            // draw in the empty space in the center:
            // draw in the empty space in the center:
            //   First, the "app chip" section of the caption bar (+ some extra margins).
            //   First, the "app chip" section of the caption bar (+ some extra margins).
+8 −13
Original line number Original line Diff line number Diff line
@@ -144,8 +144,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
    TaskDragResizer mTaskDragResizer;
    TaskDragResizer mTaskDragResizer;
    boolean mIsCaptionVisible;
    boolean mIsCaptionVisible;


    private boolean mIsStatusBarVisible;
    boolean mIsStatusBarVisible;
    private boolean mIsKeyguardVisibleAndOccluded;
    boolean mIsKeyguardVisibleAndOccluded;


    /** The most recent set of insets applied to this window decoration. */
    /** The most recent set of insets applied to this window decoration. */
    private WindowDecorationInsets mWindowDecorationInsets;
    private WindowDecorationInsets mWindowDecorationInsets;
@@ -241,7 +241,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
        }
        }
        rootView = null; // Clear it just in case we use it accidentally
        rootView = null; // Clear it just in case we use it accidentally


        updateCaptionVisibility(outResult.mRootView);
        updateCaptionVisibility(outResult.mRootView, params);


        final Rect taskBounds = mTaskInfo.getConfiguration().windowConfiguration.getBounds();
        final Rect taskBounds = mTaskInfo.getConfiguration().windowConfiguration.getBounds();
        outResult.mWidth = taskBounds.width();
        outResult.mWidth = taskBounds.width();
@@ -527,17 +527,10 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
    }
    }


    /**
    /**
     * Checks if task has entered/exited immersive mode and requires a change in caption visibility.
     * Update caption visibility state and views.
     */
     */
    private void updateCaptionVisibility(View rootView) {
    private void updateCaptionVisibility(View rootView, @NonNull RelayoutParams params) {
        // Caption should always be visible in freeform mode. When not in freeform, align with the
        mIsCaptionVisible = params.mIsCaptionVisible;
        // status bar except when showing over keyguard (where it should not shown).
        //  TODO(b/356405803): Investigate how it's possible for the status bar visibility to be
        //   false while a freeform window is open if the status bar is always forcibly-shown. It
        //   may be that the InsetsState (from which |mIsStatusBarVisible| is set) still contains
        //   an invisible insets source in immersive cases even if the status bar is shown?
        mIsCaptionVisible = mTaskInfo.isFreeform()
                || (mIsStatusBarVisible && !mIsKeyguardVisibleAndOccluded);
        setCaptionVisibility(rootView, mIsCaptionVisible);
        setCaptionVisibility(rootView, mIsCaptionVisible);
    }
    }


@@ -737,6 +730,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
        int mCornerRadius;
        int mCornerRadius;


        int mCaptionTopPadding;
        int mCaptionTopPadding;
        boolean mIsCaptionVisible;


        Configuration mWindowDecorConfig;
        Configuration mWindowDecorConfig;


@@ -755,6 +749,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
            mCornerRadius = 0;
            mCornerRadius = 0;


            mCaptionTopPadding = 0;
            mCaptionTopPadding = 0;
            mIsCaptionVisible = false;


            mApplyStartTransactionOnDraw = false;
            mApplyStartTransactionOnDraw = false;
            mSetTaskPositionAndCrop = false;
            mSetTaskPositionAndCrop = false;
+6 −0
Original line number Original line Diff line number Diff line
@@ -47,6 +47,8 @@ class CaptionWindowDecorationTests : ShellTestCase() {
            taskInfo,
            taskInfo,
            true,
            true,
            false,
            false,
            true /* isStatusBarVisible */,
            false /* isKeyguardVisibleAndOccluded */,
            InsetsState()
            InsetsState()
        )
        )


@@ -66,6 +68,8 @@ class CaptionWindowDecorationTests : ShellTestCase() {
            taskInfo,
            taskInfo,
            true,
            true,
            false,
            false,
            true /* isStatusBarVisible */,
            false /* isKeyguardVisibleAndOccluded */,
            InsetsState()
            InsetsState()
        )
        )


@@ -81,6 +85,8 @@ class CaptionWindowDecorationTests : ShellTestCase() {
            taskInfo,
            taskInfo,
            true,
            true,
            false,
            false,
            true /* isStatusBarVisible */,
            false /* isKeyguardVisibleAndOccluded */,
            InsetsState()
            InsetsState()
        )
        )
        Truth.assertThat(relayoutParams.mOccludingCaptionElements.size).isEqualTo(2)
        Truth.assertThat(relayoutParams.mOccludingCaptionElements.size).isEqualTo(2)
+252 −18

File changed.

Preview size limit exceeded, changes collapsed.

Loading