summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Garfield Tan <xutan@google.com> 2024-04-11 17:59:18 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-04-11 17:59:18 +0000
commit77a60f901d9506d0086db0a2f502d3135a74f73c (patch)
tree80a0ae4265de971b7130d7d060aae881c7ffc67e
parenta57a70b9144213dc987a30bbf64be80e2112c092 (diff)
parent912782ea48539cb4ad78bcd55e5de835004a1ebc (diff)
Merge "Remove DecorCaptionView and CAPTION_ON_SHELL flag" into main
-rw-r--r--core/java/android/view/InsetsController.java48
-rw-r--r--core/java/android/view/PendingInsetsController.java9
-rw-r--r--core/java/android/view/ViewRootImpl.java27
-rw-r--r--core/java/android/view/WindowInsetsController.java9
-rw-r--r--core/java/com/android/internal/policy/BackdropFrameRenderer.java27
-rw-r--r--core/java/com/android/internal/policy/DecorView.java241
-rw-r--r--core/java/com/android/internal/policy/PhoneWindow.java11
-rw-r--r--core/java/com/android/internal/widget/DecorCaptionView.java418
-rw-r--r--core/tests/coretests/src/android/view/InsetsControllerTest.java45
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java98
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java19
-rw-r--r--packages/SystemUI/src/com/android/systemui/flags/Flags.kt5
12 files changed, 71 insertions, 886 deletions
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index b52003f437da..1f6cecafd68f 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -22,7 +22,6 @@ import static android.view.InsetsControllerProto.CONTROL;
import static android.view.InsetsControllerProto.STATE;
import static android.view.InsetsSource.ID_IME;
import static android.view.InsetsSource.ID_IME_CAPTION_BAR;
-import static android.view.ViewRootImpl.CAPTION_ON_SHELL;
import static android.view.WindowInsets.Type.FIRST;
import static android.view.WindowInsets.Type.LAST;
import static android.view.WindowInsets.Type.all;
@@ -685,9 +684,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
@Override
public void onIdNotFoundInState2(int index1, InsetsSource source1) {
- if (!CAPTION_ON_SHELL && source1.getType() == captionBar()) {
- return;
- }
if (source1.getId() == ID_IME_CAPTION_BAR) {
return;
}
@@ -848,15 +844,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
}
public boolean onStateChanged(InsetsState state) {
- boolean stateChanged = false;
- if (!CAPTION_ON_SHELL) {
- stateChanged = !mState.equals(state, true /* excludesCaptionBar */,
- false /* excludesInvisibleIme */)
- || captionInsetsUnchanged();
- } else {
- stateChanged = !mState.equals(state, false /* excludesCaptionBar */,
- false /* excludesInvisibleIme */);
- }
+ boolean stateChanged = !mState.equals(state, false /* excludesCaptionBar */,
+ false /* excludesInvisibleIme */);
if (!stateChanged && mLastDispatchedState.equals(state)) {
return false;
}
@@ -924,21 +913,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
}
}
- private boolean captionInsetsUnchanged() {
- if (CAPTION_ON_SHELL) {
- return false;
- }
- final InsetsSource source = mState.peekSource(ID_CAPTION_BAR);
- if (source == null && mCaptionInsetsHeight == 0) {
- return false;
- }
- if (source != null && mCaptionInsetsHeight == source.getFrame().height()) {
- return false;
- }
-
- return true;
- }
-
/**
* @see InsetsState#calculateInsets(Rect, InsetsState, boolean, int, int, int, int, int,
* android.util.SparseIntArray)
@@ -1889,24 +1863,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
}
@Override
- public void setCaptionInsetsHeight(int height) {
- // This method is to be removed once the caption is moved to the shell.
- if (CAPTION_ON_SHELL) {
- return;
- }
- if (mCaptionInsetsHeight != height) {
- mCaptionInsetsHeight = height;
- if (mCaptionInsetsHeight != 0) {
- mState.getOrCreateSource(ID_CAPTION_BAR, captionBar()).setFrame(
- mFrame.left, mFrame.top, mFrame.right, mFrame.top + mCaptionInsetsHeight);
- } else {
- mState.removeSource(ID_CAPTION_BAR);
- }
- mHost.notifyInsetsChanged();
- }
- }
-
- @Override
public void setImeCaptionBarInsetsHeight(int height) {
if (!ENABLE_HIDE_IME_CAPTION_BAR) {
return;
diff --git a/core/java/android/view/PendingInsetsController.java b/core/java/android/view/PendingInsetsController.java
index 00a58063f078..5f461c56baff 100644
--- a/core/java/android/view/PendingInsetsController.java
+++ b/core/java/android/view/PendingInsetsController.java
@@ -45,7 +45,6 @@ public class PendingInsetsController implements WindowInsetsController {
private InsetsController mReplayedInsetsController;
private ArrayList<OnControllableInsetsChangedListener> mControllableInsetsChangedListeners
= new ArrayList<>();
- private int mCaptionInsetsHeight = 0;
private int mImeCaptionBarInsetsHeight = 0;
private WindowInsetsAnimationControlListener mLoggingListener;
private @InsetsType int mRequestedVisibleTypes = WindowInsets.Type.defaultVisible();
@@ -99,11 +98,6 @@ public class PendingInsetsController implements WindowInsetsController {
}
@Override
- public void setCaptionInsetsHeight(int height) {
- mCaptionInsetsHeight = height;
- }
-
- @Override
public void setImeCaptionBarInsetsHeight(int height) {
mImeCaptionBarInsetsHeight = height;
}
@@ -187,9 +181,6 @@ public class PendingInsetsController implements WindowInsetsController {
controller.setSystemBarsAppearanceFromResource(
mAppearanceFromResource, mAppearanceFromResourceMask);
}
- if (mCaptionInsetsHeight != 0) {
- controller.setCaptionInsetsHeight(mCaptionInsetsHeight);
- }
if (mImeCaptionBarInsetsHeight != 0) {
controller.setImeCaptionBarInsetsHeight(mImeCaptionBarInsetsHeight);
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index f039a19bf91f..cd0602cd0e36 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -257,7 +257,6 @@ import com.android.internal.inputmethod.ImeTracing;
import com.android.internal.inputmethod.InputMethodDebug;
import com.android.internal.os.IResultReceiver;
import com.android.internal.os.SomeArgs;
-import com.android.internal.policy.DecorView;
import com.android.internal.policy.PhoneFallbackEventHandler;
import com.android.internal.view.BaseSurfaceHolder;
import com.android.internal.view.RootViewSurfaceTaker;
@@ -335,13 +334,6 @@ public final class ViewRootImpl implements ViewParent,
private static final boolean USE_ASYNC_PERFORM_HAPTIC_FEEDBACK = true;
/**
- * Whether the caption is drawn by the shell.
- * @hide
- */
- public static final boolean CAPTION_ON_SHELL =
- SystemProperties.getBoolean("persist.wm.debug.caption_on_shell", true);
-
- /**
* Whether the client (system UI) is handling the transient gesture and the corresponding
* animation.
* @hide
@@ -3176,22 +3168,6 @@ public final class ViewRootImpl implements ViewParent,
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
}
- private boolean updateCaptionInsets() {
- if (CAPTION_ON_SHELL) {
- return false;
- }
- if (!(mView instanceof DecorView)) return false;
- final int captionInsetsHeight = ((DecorView) mView).getCaptionInsetsHeight();
- final Rect captionFrame = new Rect();
- if (captionInsetsHeight != 0) {
- captionFrame.set(mWinFrame.left, mWinFrame.top, mWinFrame.right,
- mWinFrame.top + captionInsetsHeight);
- }
- if (mAttachInfo.mCaptionInsets.equals(captionFrame)) return false;
- mAttachInfo.mCaptionInsets.set(captionFrame);
- return true;
- }
-
private boolean shouldDispatchCutout() {
return mWindowAttributes.layoutInDisplayCutoutMode
== LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
@@ -3645,9 +3621,6 @@ public final class ViewRootImpl implements ViewParent,
mAttachInfo.mAlwaysConsumeSystemBars = mPendingAlwaysConsumeSystemBars;
dispatchApplyInsets = true;
}
- if (updateCaptionInsets()) {
- dispatchApplyInsets = true;
- }
if (dispatchApplyInsets || mLastSystemUiVisibility !=
mAttachInfo.mSystemUiVisibility || mApplyInsetsRequested) {
mLastSystemUiVisibility = mAttachInfo.mSystemUiVisibility;
diff --git a/core/java/android/view/WindowInsetsController.java b/core/java/android/view/WindowInsetsController.java
index 1ffffb303e71..19c98a2f12b7 100644
--- a/core/java/android/view/WindowInsetsController.java
+++ b/core/java/android/view/WindowInsetsController.java
@@ -284,15 +284,6 @@ public interface WindowInsetsController {
@Appearance int getSystemBarsAppearance();
/**
- * Notify the caption insets height change. The information will be used on the client side to,
- * make sure the InsetsState has the correct caption insets.
- *
- * @param height the height of caption bar insets.
- * @hide
- */
- void setCaptionInsetsHeight(int height);
-
- /**
* Sets the insets height for the IME caption bar, which corresponds to the
* "fake" IME navigation bar.
*
diff --git a/core/java/com/android/internal/policy/BackdropFrameRenderer.java b/core/java/com/android/internal/policy/BackdropFrameRenderer.java
index 684864638e90..c6e8bf75dbcd 100644
--- a/core/java/com/android/internal/policy/BackdropFrameRenderer.java
+++ b/core/java/com/android/internal/policy/BackdropFrameRenderer.java
@@ -56,7 +56,6 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
// during a configuration change.
private int mLastContentWidth;
private int mLastContentHeight;
- private int mLastCaptionHeight;
private int mLastXOffset;
private int mLastYOffset;
@@ -269,7 +268,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
final boolean firstCall = mLastContentWidth == 0;
// The current content buffer is drawn here.
mLastContentWidth = xSize;
- mLastContentHeight = ySize - mLastCaptionHeight;
+ mLastContentHeight = ySize;
mLastXOffset = xOffset;
mLastYOffset = yOffset;
@@ -278,12 +277,11 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
mLastXOffset,
mLastYOffset,
mLastXOffset + mLastContentWidth,
- mLastYOffset + mLastCaptionHeight + mLastContentHeight);
+ mLastYOffset + mLastContentHeight);
// If this was the first call and redrawLocked got already called prior
// to us, we should re-issue a redrawLocked now.
- return firstCall
- && (mLastCaptionHeight != 0 || !mDecorView.isShowingCaption());
+ return firstCall;
}
}
@@ -303,22 +301,9 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
*/
private void redrawLocked(Rect newBounds, boolean fullscreen) {
- // While a configuration change is taking place the view hierarchy might become
- // inaccessible. For that case we remember the previous metrics to avoid flashes.
- // Note that even when there is no visible caption, the caption child will exist.
- final int captionHeight = mDecorView.getCaptionHeight();
-
- // The caption height will probably never dynamically change while we are resizing.
- // Once set to something other then 0 it should be kept that way.
- if (captionHeight != 0) {
- // Remember the height of the caption.
- mLastCaptionHeight = captionHeight;
- }
-
// Make sure that the other thread has already prepared the render draw calls for the
// content. If any size is 0, we have to wait for it to be drawn first.
- if ((mLastCaptionHeight == 0 && mDecorView.isShowingCaption()) ||
- mLastContentWidth == 0 || mLastContentHeight == 0) {
+ if (mLastContentWidth == 0 || mLastContentHeight == 0) {
return;
}
@@ -337,13 +322,13 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
? mUserCaptionBackgroundDrawable : mCaptionBackgroundDrawable;
if (drawable != null) {
- drawable.setBounds(0, 0, left + width, top + mLastCaptionHeight);
+ drawable.setBounds(0, 0, left + width, top);
drawable.draw(canvas);
}
// The backdrop: clear everything with the background. Clipping is done elsewhere.
if (mResizingBackgroundDrawable != null) {
- mResizingBackgroundDrawable.setBounds(0, mLastCaptionHeight, left + width, top + height);
+ mResizingBackgroundDrawable.setBounds(0, 0, left + width, top + height);
mResizingBackgroundDrawable.draw(canvas);
}
mFrameAndBackdropNode.endRecording();
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index a65a1bb18303..ab372522fce4 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -26,9 +26,6 @@ import static android.view.View.MeasureSpec.EXACTLY;
import static android.view.View.MeasureSpec.getMode;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-import static android.view.ViewRootImpl.CAPTION_ON_SHELL;
-import static android.view.Window.DECOR_CAPTION_SHADE_DARK;
-import static android.view.Window.DECOR_CAPTION_SHADE_LIGHT;
import static android.view.WindowInsetsController.APPEARANCE_FORCE_LIGHT_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
@@ -38,9 +35,6 @@ import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
-import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
-import static android.view.WindowManager.LayoutParams.TYPE_DRAWN_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static com.android.internal.policy.PhoneWindow.FEATURE_OPTIONS_PANEL;
@@ -83,7 +77,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.PendingInsetsController;
-import android.view.ThreadedRenderer;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
@@ -116,7 +109,6 @@ import com.android.internal.view.menu.ContextMenuBuilder;
import com.android.internal.view.menu.MenuHelper;
import com.android.internal.widget.ActionBarContextView;
import com.android.internal.widget.BackgroundFallback;
-import com.android.internal.widget.DecorCaptionView;
import com.android.internal.widget.floatingtoolbar.FloatingToolbar;
import java.util.List;
@@ -189,8 +181,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
private final Rect mFrameOffsets = new Rect();
- private boolean mHasCaption = false;
-
private boolean mChanging;
private Drawable mMenuBackground;
@@ -247,11 +237,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
private Rect mTempRect;
- // This is the caption view for the window, containing the caption and window control
- // buttons. The visibility of this decor depends on the workspace and the window type.
- // If the window type does not require such a view, this member might be null.
- private DecorCaptionView mDecorCaptionView;
-
private boolean mWindowResizeCallbacksAdded = false;
private Drawable.Callback mLastBackgroundDrawableCb = null;
private BackdropFrameRenderer mBackdropFrameRenderer = null;
@@ -524,24 +509,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
int action = event.getAction();
- if (mHasCaption && isShowingCaption()) {
- // Don't dispatch ACTION_DOWN to the captionr if the window is resizable and the event
- // was (starting) outside the window. Window resizing events should be handled by
- // WindowManager.
- // TODO: Investigate how to handle the outside touch in window manager
- // without generating these events.
- // Currently we receive these because we need to enlarge the window's
- // touch region so that the monitor channel receives the events
- // in the outside touch area.
- if (action == MotionEvent.ACTION_DOWN) {
- final int x = (int) event.getX();
- final int y = (int) event.getY();
- if (isOutOfInnerBounds(x, y)) {
- return true;
- }
- }
- }
-
if (mFeatureId >= 0) {
if (action == MotionEvent.ACTION_DOWN) {
int x = (int)event.getX();
@@ -1041,7 +1008,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
@Override
public void onWindowSystemUiVisibilityChanged(int visible) {
updateColorViews(null /* insets */, true /* animate */);
- updateDecorCaptionStatus(getResources().getConfiguration());
if (mStatusGuard != null && mStatusGuard.getVisibility() == VISIBLE) {
updateStatusGuardColor();
@@ -1214,11 +1180,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
mLastTopInset, false /* matchVertical */, statusBarNeedsLeftInset,
statusBarSideInset, animate && !disallowAnimate,
mForceWindowDrawsBarBackgrounds, requestedVisibleTypes);
-
- if (mHasCaption) {
- mDecorCaptionView.getCaption().setBackgroundColor(statusBarColor);
- updateDecorCaptionShade();
- }
}
// When we expand the window with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS or
@@ -1483,7 +1444,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
mWindow.getAttributes().flags, force);
boolean show = state.attributes.isVisible(state.present, color,
mWindow.getAttributes().flags, force);
- boolean showView = show && !isResizing() && !mHasCaption && size > 0;
+ boolean showView = show && !isResizing() && size > 0;
boolean visibilityChanged = false;
View view = state.view;
@@ -1950,9 +1911,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
@Override
public void onRootViewScrollYChanged(int rootScrollY) {
mRootScrollY = rootScrollY;
- if (mDecorCaptionView != null) {
- mDecorCaptionView.onRootViewScrollYChanged(rootScrollY);
- }
updateColorViewTranslations();
}
@@ -2141,31 +2099,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
.addOnPreDrawListener(mFloatingToolbarPreDrawListener);
}
- /**
- * Informs the decor if the caption is attached and visible.
- * @param attachedAndVisible true when the decor is visible.
- * Note that this will even be called if there is no caption.
- **/
- void enableCaption(boolean attachedAndVisible) {
- if (mHasCaption != attachedAndVisible) {
- mHasCaption = attachedAndVisible;
- if (getForeground() != null) {
- drawableChanged();
- }
- notifyCaptionHeightChanged();
- }
- }
-
- /**
- * An interface to be called when the caption visibility or height changed, to report the
- * corresponding insets change to the InsetsController.
- */
- public void notifyCaptionHeightChanged() {
- if (!CAPTION_ON_SHELL) {
- getWindowInsetsController().setCaptionInsetsHeight(getCaptionInsetsHeight());
- }
- }
-
void setWindow(PhoneWindow phoneWindow) {
mWindow = phoneWindow;
Context context = getContext();
@@ -2191,8 +2124,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- updateDecorCaptionStatus(newConfig);
-
initializeElevation();
}
@@ -2214,29 +2145,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
& View.SYSTEM_UI_FLAG_FULLSCREEN));
}
- private void updateDecorCaptionStatus(Configuration config) {
- final boolean displayWindowDecor = config.windowConfiguration.hasWindowDecorCaption()
- && !isFillingScreen(config);
- if (mDecorCaptionView == null && displayWindowDecor) {
- // Configuration now requires a caption.
- final LayoutInflater inflater = mWindow.getLayoutInflater();
- mDecorCaptionView = createDecorCaptionView(inflater);
- if (mDecorCaptionView != null) {
- if (mDecorCaptionView.getParent() == null) {
- addView(mDecorCaptionView, 0,
- new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
- }
- removeView(mContentRoot);
- mDecorCaptionView.addView(mContentRoot,
- new ViewGroup.MarginLayoutParams(MATCH_PARENT, MATCH_PARENT));
- }
- } else if (mDecorCaptionView != null) {
- // We might have to change the kind of surface before we do anything else.
- mDecorCaptionView.onConfigurationChanged(displayWindowDecor);
- enableCaption(displayWindowDecor);
- }
- }
-
void onResourcesLoaded(LayoutInflater inflater, int layoutResource) {
if (mBackdropFrameRenderer != null) {
loadBackgroundDrawablesIfNeeded();
@@ -2246,20 +2154,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
getCurrentColor(mNavigationColorViewState));
}
- mDecorCaptionView = createDecorCaptionView(inflater);
final View root = inflater.inflate(layoutResource, null);
- if (mDecorCaptionView != null) {
- if (mDecorCaptionView.getParent() == null) {
- addView(mDecorCaptionView,
- new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
- }
- mDecorCaptionView.addView(root,
- new ViewGroup.MarginLayoutParams(MATCH_PARENT, MATCH_PARENT));
- } else {
- // Put it below the color views.
- addView(root, 0, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
- }
+ // Put it below the color views.
+ addView(root, 0, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
mContentRoot = (ViewGroup) root;
initializeElevation();
}
@@ -2285,89 +2183,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
}
- // Free floating overlapping windows require a caption.
- private DecorCaptionView createDecorCaptionView(LayoutInflater inflater) {
- DecorCaptionView decorCaptionView = null;
- for (int i = getChildCount() - 1; i >= 0 && decorCaptionView == null; i--) {
- View view = getChildAt(i);
- if (view instanceof DecorCaptionView) {
- // The decor was most likely saved from a relaunch - so reuse it.
- decorCaptionView = (DecorCaptionView) view;
- removeViewAt(i);
- }
- }
- final WindowManager.LayoutParams attrs = mWindow.getAttributes();
- final boolean isApplication = attrs.type == TYPE_BASE_APPLICATION ||
- attrs.type == TYPE_APPLICATION || attrs.type == TYPE_DRAWN_APPLICATION;
- final WindowConfiguration winConfig = getResources().getConfiguration().windowConfiguration;
- // Only a non floating application window on one of the allowed workspaces can get a caption
- if (!mWindow.isFloating() && isApplication && winConfig.hasWindowDecorCaption()
- && !CAPTION_ON_SHELL) {
- // Dependent on the brightness of the used title we either use the
- // dark or the light button frame.
- if (decorCaptionView == null) {
- decorCaptionView = inflateDecorCaptionView(inflater);
- }
- decorCaptionView.setPhoneWindow(mWindow, true /*showDecor*/);
- } else {
- decorCaptionView = null;
- }
-
- // Tell the decor if it has a visible caption.
- enableCaption(decorCaptionView != null);
- return decorCaptionView;
- }
-
- private DecorCaptionView inflateDecorCaptionView(LayoutInflater inflater) {
- final Context context = getContext();
- // We make a copy of the inflater, so it has the right context associated with it.
- inflater = inflater.from(context);
- final DecorCaptionView view = (DecorCaptionView) inflater.inflate(R.layout.decor_caption,
- null);
- setDecorCaptionShade(view);
- return view;
- }
-
- private void setDecorCaptionShade(DecorCaptionView view) {
- final int shade = mWindow.getDecorCaptionShade();
- switch (shade) {
- case DECOR_CAPTION_SHADE_LIGHT:
- setLightDecorCaptionShade(view);
- break;
- case DECOR_CAPTION_SHADE_DARK:
- setDarkDecorCaptionShade(view);
- break;
- default: {
- if ((getWindowSystemUiVisibility() & SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0) {
- setDarkDecorCaptionShade(view);
- } else {
- setLightDecorCaptionShade(view);
- }
- break;
- }
- }
- }
-
- void updateDecorCaptionShade() {
- if (mDecorCaptionView != null) {
- setDecorCaptionShade(mDecorCaptionView);
- }
- }
-
- private void setLightDecorCaptionShade(DecorCaptionView view) {
- view.findViewById(R.id.maximize_window).setBackgroundResource(
- R.drawable.decor_maximize_button_light);
- view.findViewById(R.id.close_window).setBackgroundResource(
- R.drawable.decor_close_button_light);
- }
-
- private void setDarkDecorCaptionShade(DecorCaptionView view) {
- view.findViewById(R.id.maximize_window).setBackgroundResource(
- R.drawable.decor_maximize_button_dark);
- view.findViewById(R.id.close_window).setBackgroundResource(
- R.drawable.decor_close_button_dark);
- }
-
/**
* Returns the color used to fill areas the app has not rendered content to yet when the
* user is resizing the window of an activity in multi-window mode.
@@ -2405,17 +2220,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
void clearContentView() {
- if (mDecorCaptionView != null) {
- mDecorCaptionView.removeContentView();
- } else {
- // This window doesn't have caption, so we need to remove everything except our views
- // we might have added.
- for (int i = getChildCount() - 1; i >= 0; i--) {
- View v = getChildAt(i);
- if (v != mStatusColorViewState.view && v != mNavigationColorViewState.view
- && v != mStatusGuard) {
- removeViewAt(i);
- }
+ for (int i = getChildCount() - 1; i >= 0; i--) {
+ View v = getChildAt(i);
+ if (v != mStatusColorViewState.view && v != mNavigationColorViewState.view
+ && v != mStatusGuard) {
+ removeViewAt(i);
}
}
}
@@ -2439,23 +2248,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
if (mBackdropFrameRenderer != null) {
return;
}
- final ThreadedRenderer renderer = getThreadedRenderer();
- if (renderer != null && !CAPTION_ON_SHELL) {
- loadBackgroundDrawablesIfNeeded();
- WindowInsets rootInsets = getRootWindowInsets();
- mBackdropFrameRenderer = new BackdropFrameRenderer(this, renderer,
- initialBounds, mResizingBackgroundDrawable, mCaptionBackgroundDrawable,
- mUserCaptionBackgroundDrawable, getCurrentColor(mStatusColorViewState),
- getCurrentColor(mNavigationColorViewState), fullscreen,
- rootInsets.getInsets(WindowInsets.Type.systemBars()));
-
- // Get rid of the shadow while we are resizing. Shadow drawing takes considerable time.
- // If we want to get the shadow shown while resizing, we would need to elevate a new
- // element which owns the caption and has the elevation.
- updateElevation();
-
- updateColorViews(null /* insets */, false);
- }
getViewRootImpl().requestInvalidateRootRenderNode();
}
@@ -2576,23 +2368,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
}
- boolean isShowingCaption() {
- return mDecorCaptionView != null && mDecorCaptionView.isCaptionShowing();
- }
-
- int getCaptionHeight() {
- return isShowingCaption() ? mDecorCaptionView.getCaptionHeight() : 0;
- }
-
- /**
- * @hide
- * @return the height of insets covering the top of window content area.
- */
- public int getCaptionInsetsHeight() {
- if (!mWindow.isOverlayWithDecorCaptionEnabled()) return 0;
- return getCaptionHeight();
- }
-
/**
* Converts a DIP measure into physical pixels.
* @param dip The dip value.
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index e6a2a6c375f7..18413530d575 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -363,8 +363,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
private boolean mIsStartingWindow;
private int mTheme = -1;
- private int mDecorCaptionShade = DECOR_CAPTION_SHADE_AUTO;
-
private boolean mUseDecorContext = false;
/** @see ViewRootImpl#mActivityConfigCallback */
@@ -4048,14 +4046,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
@Override
public void setDecorCaptionShade(int decorCaptionShade) {
- mDecorCaptionShade = decorCaptionShade;
- if (mDecor != null) {
- mDecor.updateDecorCaptionShade();
- }
- }
-
- int getDecorCaptionShade() {
- return mDecorCaptionShade;
+ // TODO(b/328668781): Make proper treatment to this public API per the outcome of the bug.
}
@Override
diff --git a/core/java/com/android/internal/widget/DecorCaptionView.java b/core/java/com/android/internal/widget/DecorCaptionView.java
deleted file mode 100644
index 362fd7b4e937..000000000000
--- a/core/java/com/android/internal/widget/DecorCaptionView.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Copyright (C) 2015 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.internal.widget;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewConfiguration;
-import android.view.ViewGroup;
-import android.view.ViewOutlineProvider;
-import android.view.Window;
-
-import com.android.internal.R;
-import com.android.internal.policy.DecorView;
-import com.android.internal.policy.PhoneWindow;
-
-import java.util.ArrayList;
-
-/**
- * This class represents the special screen elements to control a window on freeform
- * environment.
- * As such this class handles the following things:
- * <ul>
- * <li>The caption, containing the system buttons like maximize, close and such as well as
- * allowing the user to drag the window around.</li>
- * </ul>
- * After creating the view, the function {@link #setPhoneWindow} needs to be called to make
- * the connection to it's owning PhoneWindow.
- * Note: At this time the application can change various attributes of the DecorView which
- * will break things (in subtle/unexpected ways):
- * <ul>
- * <li>setOutlineProvider</li>
- * <li>setSurfaceFormat</li>
- * <li>..</li>
- * </ul>
- *
- * Here describe the behavior of overlaying caption on the content and drawing.
- *
- * First, no matter where the content View gets added, it will always be the first child and the
- * caption will be the second. This way the caption will always be drawn on top of the content when
- * overlaying is enabled.
- *
- * Second, the touch dispatch is customized to handle overlaying. This is what happens when touch
- * is dispatched on the caption area while overlaying it on content:
- * <ul>
- * <li>DecorCaptionView.onInterceptTouchEvent() will try intercepting the touch events if the
- * down action is performed on top close or maximize buttons; the reason for that is we want these
- * buttons to always work.</li>
- * <li>The caption view will try to consume the event to apply the dragging logic.</li>
- * <li>If the touch event is not consumed by the caption, the content View will receive the touch
- * event</li>
- * </ul>
- */
-public class DecorCaptionView extends ViewGroup implements View.OnTouchListener,
- GestureDetector.OnGestureListener {
- private PhoneWindow mOwner = null;
- private boolean mShow = false;
-
- // True if the window is being dragged.
- private boolean mDragging = false;
-
- private boolean mOverlayWithAppContent = false;
-
- private View mCaption;
- private View mContent;
- private View mMaximize;
- private View mClose;
-
- // Fields for detecting drag events.
- private int mTouchDownX;
- private int mTouchDownY;
- private boolean mCheckForDragging;
- private int mDragSlop;
-
- // Fields for detecting and intercepting click events on close/maximize.
- private ArrayList<View> mTouchDispatchList = new ArrayList<>(2);
- // We use the gesture detector to detect clicks on close/maximize buttons and to be consistent
- // with existing click detection.
- private GestureDetector mGestureDetector;
- private final Rect mCloseRect = new Rect();
- private final Rect mMaximizeRect = new Rect();
- private View mClickTarget;
- private int mRootScrollY;
-
- public DecorCaptionView(Context context) {
- super(context);
- init(context);
- }
-
- public DecorCaptionView(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context);
- }
-
- public DecorCaptionView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init(context);
- }
-
- private void init(Context context) {
- mDragSlop = ViewConfiguration.get(context).getScaledTouchSlop();
- mGestureDetector = new GestureDetector(context, this);
- setContentDescription(context.getString(R.string.accessibility_freeform_caption,
- context.getPackageManager().getApplicationLabel(context.getApplicationInfo())));
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mCaption = getChildAt(0);
- }
-
- public void setPhoneWindow(PhoneWindow owner, boolean show) {
- mOwner = owner;
- mShow = show;
- mOverlayWithAppContent = owner.isOverlayWithDecorCaptionEnabled();
- updateCaptionVisibility();
- // By changing the outline provider to BOUNDS, the window can remove its
- // background without removing the shadow.
- mOwner.getDecorView().setOutlineProvider(ViewOutlineProvider.BOUNDS);
- mMaximize = findViewById(R.id.maximize_window);
- mClose = findViewById(R.id.close_window);
- }
-
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- // If the user starts touch on the maximize/close buttons, we immediately intercept, so
- // that these buttons are always clickable.
- if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- final int x = (int) ev.getX();
- final int y = (int) ev.getY();
- // Only offset y for containment tests because the actual views are already translated.
- if (mMaximizeRect.contains(x, y - mRootScrollY)) {
- mClickTarget = mMaximize;
- }
- if (mCloseRect.contains(x, y - mRootScrollY)) {
- mClickTarget = mClose;
- }
- }
- return mClickTarget != null;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (mClickTarget != null) {
- mGestureDetector.onTouchEvent(event);
- final int action = event.getAction();
- if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
- mClickTarget = null;
- }
- return true;
- }
- return false;
- }
-
- @Override
- public boolean onTouch(View v, MotionEvent e) {
- // Note: There are no mixed events. When a new device gets used (e.g. 1. Mouse, 2. touch)
- // the old input device events get cancelled first. So no need to remember the kind of
- // input device we are listening to.
- final int x = (int) e.getX();
- final int y = (int) e.getY();
- final boolean fromMouse = e.getToolType(e.getActionIndex()) == MotionEvent.TOOL_TYPE_MOUSE;
- final boolean primaryButton = (e.getButtonState() & MotionEvent.BUTTON_PRIMARY) != 0;
- final int actionMasked = e.getActionMasked();
- switch (actionMasked) {
- case MotionEvent.ACTION_DOWN:
- if (!mShow) {
- // When there is no caption we should not react to anything.
- return false;
- }
- // Checking for a drag action is started if we aren't dragging already and the
- // starting event is either a left mouse button or any other input device.
- if (!fromMouse || primaryButton) {
- mCheckForDragging = true;
- mTouchDownX = x;
- mTouchDownY = y;
- }
- break;
-
- case MotionEvent.ACTION_MOVE:
- if (!mDragging && mCheckForDragging && (fromMouse || passedSlop(x, y))) {
- mCheckForDragging = false;
- mDragging = true;
- startMovingTask(e.getRawX(), e.getRawY());
- // After the above call the framework will take over the input.
- // This handler will receive ACTION_CANCEL soon (possible after a few spurious
- // ACTION_MOVE events which are safe to ignore).
- }
- break;
-
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_CANCEL:
- if (!mDragging) {
- break;
- }
- // Abort the ongoing dragging.
- if (actionMasked == MotionEvent.ACTION_UP) {
- // If it receives ACTION_UP event, the dragging is already finished and also
- // the system can not end drag on ACTION_UP event. So request to finish
- // dragging.
- finishMovingTask();
- }
- mDragging = false;
- return !mCheckForDragging;
- }
- return mDragging || mCheckForDragging;
- }
-
- @Override
- public boolean shouldDelayChildPressedState() {
- return false;
- }
-
- private boolean passedSlop(int x, int y) {
- return Math.abs(x - mTouchDownX) > mDragSlop || Math.abs(y - mTouchDownY) > mDragSlop;
- }
-
- /**
- * The phone window configuration has changed and the caption needs to be updated.
- * @param show True if the caption should be shown.
- */
- public void onConfigurationChanged(boolean show) {
- mShow = show;
- updateCaptionVisibility();
- }
-
- @Override
- public void addView(View child, int index, ViewGroup.LayoutParams params) {
- if (!(params instanceof MarginLayoutParams)) {
- throw new IllegalArgumentException(
- "params " + params + " must subclass MarginLayoutParams");
- }
- // Make sure that we never get more then one client area in our view.
- if (index >= 2 || getChildCount() >= 2) {
- throw new IllegalStateException("DecorCaptionView can only handle 1 client view");
- }
- // To support the overlaying content in the caption, we need to put the content view as the
- // first child to get the right Z-Ordering.
- super.addView(child, 0, params);
- mContent = child;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final int captionHeight;
- if (mCaption.getVisibility() != View.GONE) {
- measureChildWithMargins(mCaption, widthMeasureSpec, 0, heightMeasureSpec, 0);
- captionHeight = mCaption.getMeasuredHeight();
- } else {
- captionHeight = 0;
- }
- if (mContent != null) {
- if (mOverlayWithAppContent) {
- measureChildWithMargins(mContent, widthMeasureSpec, 0, heightMeasureSpec, 0);
- } else {
- measureChildWithMargins(mContent, widthMeasureSpec, 0, heightMeasureSpec,
- captionHeight);
- }
- }
-
- setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec),
- MeasureSpec.getSize(heightMeasureSpec));
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- final int captionHeight;
- if (mCaption.getVisibility() != View.GONE) {
- mCaption.layout(0, 0, mCaption.getMeasuredWidth(), mCaption.getMeasuredHeight());
- captionHeight = mCaption.getBottom() - mCaption.getTop();
- mMaximize.getHitRect(mMaximizeRect);
- mClose.getHitRect(mCloseRect);
- } else {
- captionHeight = 0;
- mMaximizeRect.setEmpty();
- mCloseRect.setEmpty();
- }
-
- if (mContent != null) {
- if (mOverlayWithAppContent) {
- mContent.layout(0, 0, mContent.getMeasuredWidth(), mContent.getMeasuredHeight());
- } else {
- mContent.layout(0, captionHeight, mContent.getMeasuredWidth(),
- captionHeight + mContent.getMeasuredHeight());
- }
- }
-
- ((DecorView) mOwner.getDecorView()).notifyCaptionHeightChanged();
-
- // This assumes that the caption bar is at the top.
- mOwner.notifyRestrictedCaptionAreaCallback(mMaximize.getLeft(), mMaximize.getTop(),
- mClose.getRight(), mClose.getBottom());
- }
-
- /**
- * Updates the visibility of the caption.
- **/
- private void updateCaptionVisibility() {
- mCaption.setVisibility(mShow ? VISIBLE : GONE);
- mCaption.setOnTouchListener(this);
- }
-
- /**
- * Maximize or restore the window by moving it to the maximized or freeform workspace stack.
- **/
- private void toggleFreeformWindowingMode() {
- Window.WindowControllerCallback callback = mOwner.getWindowControllerCallback();
- if (callback != null) {
- callback.toggleFreeformWindowingMode();
- }
- }
-
- public boolean isCaptionShowing() {
- return mShow;
- }
-
- public int getCaptionHeight() {
- return (mCaption != null) ? mCaption.getHeight() : 0;
- }
-
- public void removeContentView() {
- if (mContent != null) {
- removeView(mContent);
- mContent = null;
- }
- }
-
- public View getCaption() {
- return mCaption;
- }
-
- @Override
- public LayoutParams generateLayoutParams(AttributeSet attrs) {
- return new MarginLayoutParams(getContext(), attrs);
- }
-
- @Override
- protected LayoutParams generateDefaultLayoutParams() {
- return new MarginLayoutParams(MarginLayoutParams.MATCH_PARENT,
- MarginLayoutParams.MATCH_PARENT);
- }
-
- @Override
- protected LayoutParams generateLayoutParams(LayoutParams p) {
- return new MarginLayoutParams(p);
- }
-
- @Override
- protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
- return p instanceof MarginLayoutParams;
- }
-
- @Override
- public boolean onDown(MotionEvent e) {
- return false;
- }
-
- @Override
- public void onShowPress(MotionEvent e) {
-
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent e) {
- if (mClickTarget == mMaximize) {
- toggleFreeformWindowingMode();
- } else if (mClickTarget == mClose) {
- mOwner.dispatchOnWindowDismissed(
- true /*finishTask*/, false /*suppressWindowTransition*/);
- }
- return true;
- }
-
- @Override
- public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
- return false;
- }
-
- @Override
- public void onLongPress(MotionEvent e) {
-
- }
-
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
- return false;
- }
-
- /**
- * Called when {@link android.view.ViewRootImpl} scrolls for adjustPan.
- */
- public void onRootViewScrollYChanged(int scrollY) {
- // Offset the caption opposite the root scroll. This keeps the caption at the
- // top of the window during adjustPan.
- if (mCaption != null) {
- mRootScrollY = scrollY;
- mCaption.setTranslationY(scrollY);
- }
- }
-}
diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java
index 97f894f8dcac..4fb85c1fa7ff 100644
--- a/core/tests/coretests/src/android/view/InsetsControllerTest.java
+++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java
@@ -25,9 +25,7 @@ import static android.view.InsetsSource.FLAG_ANIMATE_RESIZING;
import static android.view.InsetsSource.ID_IME;
import static android.view.InsetsSourceConsumer.ShowResult.IME_SHOW_DELAYED;
import static android.view.InsetsSourceConsumer.ShowResult.SHOW_IMMEDIATELY;
-import static android.view.ViewRootImpl.CAPTION_ON_SHELL;
import static android.view.WindowInsets.Type.all;
-import static android.view.WindowInsets.Type.captionBar;
import static android.view.WindowInsets.Type.defaultVisible;
import static android.view.WindowInsets.Type.ime;
import static android.view.WindowInsets.Type.navigationBars;
@@ -49,7 +47,6 @@ import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -805,48 +802,6 @@ public class InsetsControllerTest {
}
@Test
- public void testCaptionInsetsStateAssemble() {
- if (CAPTION_ON_SHELL) {
- // For this case, the test is covered by WindowContainerInsetsSourceProviderTest, This
- // test can be removed after the caption is moved to shell completely.
- return;
- }
- InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
- final Rect frame = new Rect(0, 0, 100, 300);
- final int captionBarHeight = 100;
- final InsetsState state = mController.getState();
- mController.onFrameChanged(frame);
- mController.setCaptionInsetsHeight(captionBarHeight);
- // The caption bar insets height should be the same as the caption bar height.
- assertEquals(captionBarHeight, state.calculateInsets(frame, captionBar(), false).top);
- // Test update to remove the caption bar
- mController.setCaptionInsetsHeight(0);
- // The caption bar source should not be there at all, because we don't add empty
- // caption to the state from the server.
- for (int i = state.sourceSize() - 1; i >= 0; i--) {
- assertNotEquals(captionBar(), state.sourceAt(i).getType());
- }
- });
- }
-
- @Test
- public void testNotifyCaptionInsetsOnlyChange() {
- if (CAPTION_ON_SHELL) {
- // For this case, the test is covered by WindowContainerInsetsSourceProviderTest, This
- // test can be removed after the caption is moved to shell completely.
- return;
- }
- InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
- reset(mTestHost);
- mController.setCaptionInsetsHeight(100);
- verify(mTestHost).notifyInsetsChanged();
- reset(mTestHost);
- mController.setCaptionInsetsHeight(0);
- verify(mTestHost).notifyInsetsChanged();
- });
- }
-
- @Test
public void testRequestedState() {
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
mController.hide(statusBars() | navigationBars());
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java
index 32c2d1e9b257..51b0a246f3e9 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java
@@ -40,7 +40,6 @@ import android.view.LayoutInflater;
import android.view.SurfaceControl;
import android.view.SurfaceControlViewHost;
import android.view.View;
-import android.view.ViewRootImpl;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowlessWindowManager;
@@ -293,60 +292,56 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
.setLayer(mCaptionContainerSurface, CAPTION_LAYER_Z_ORDER)
.show(mCaptionContainerSurface);
- if (ViewRootImpl.CAPTION_ON_SHELL) {
- outResult.mRootView.setTaskFocusState(mTaskInfo.isFocused);
-
- // Caption insets
- if (mIsCaptionVisible) {
- // Caption inset is the full width of the task with the |captionHeight| and
- // positioned at the top of the task bounds, also in absolute coordinates.
- // So just reuse the task bounds and adjust the bottom coordinate.
- mCaptionInsetsRect.set(taskBounds);
- mCaptionInsetsRect.bottom = mCaptionInsetsRect.top + outResult.mCaptionHeight;
-
- // Caption bounding rectangles: these are optional, and are used to present finer
- // insets than traditional |Insets| to apps about where their content is occluded.
- // These are also in absolute coordinates.
- final Rect[] boundingRects;
- final int numOfElements = params.mOccludingCaptionElements.size();
- if (numOfElements == 0) {
- boundingRects = null;
- } else {
- // The customizable region can at most be equal to the caption bar.
+ outResult.mRootView.setTaskFocusState(mTaskInfo.isFocused);
+
+ // Caption insets
+ if (mIsCaptionVisible) {
+ // Caption inset is the full width of the task with the |captionHeight| and
+ // positioned at the top of the task bounds, also in absolute coordinates.
+ // So just reuse the task bounds and adjust the bottom coordinate.
+ mCaptionInsetsRect.set(taskBounds);
+ mCaptionInsetsRect.bottom = mCaptionInsetsRect.top + outResult.mCaptionHeight;
+
+ // Caption bounding rectangles: these are optional, and are used to present finer
+ // insets than traditional |Insets| to apps about where their content is occluded.
+ // These are also in absolute coordinates.
+ final Rect[] boundingRects;
+ final int numOfElements = params.mOccludingCaptionElements.size();
+ if (numOfElements == 0) {
+ boundingRects = null;
+ } else {
+ // The customizable region can at most be equal to the caption bar.
+ if (params.mAllowCaptionInputFallthrough) {
+ outResult.mCustomizableCaptionRegion.set(mCaptionInsetsRect);
+ }
+ boundingRects = new Rect[numOfElements];
+ for (int i = 0; i < numOfElements; i++) {
+ final OccludingCaptionElement element =
+ params.mOccludingCaptionElements.get(i);
+ final int elementWidthPx =
+ resources.getDimensionPixelSize(element.mWidthResId);
+ boundingRects[i] =
+ calculateBoundingRect(element, elementWidthPx, mCaptionInsetsRect);
+ // Subtract the regions used by the caption elements, the rest is
+ // customizable.
if (params.mAllowCaptionInputFallthrough) {
- outResult.mCustomizableCaptionRegion.set(mCaptionInsetsRect);
- }
- boundingRects = new Rect[numOfElements];
- for (int i = 0; i < numOfElements; i++) {
- final OccludingCaptionElement element =
- params.mOccludingCaptionElements.get(i);
- final int elementWidthPx =
- resources.getDimensionPixelSize(element.mWidthResId);
- boundingRects[i] =
- calculateBoundingRect(element, elementWidthPx, mCaptionInsetsRect);
- // Subtract the regions used by the caption elements, the rest is
- // customizable.
- if (params.mAllowCaptionInputFallthrough) {
- outResult.mCustomizableCaptionRegion.op(boundingRects[i],
- Region.Op.DIFFERENCE);
- }
+ outResult.mCustomizableCaptionRegion.op(boundingRects[i],
+ Region.Op.DIFFERENCE);
}
}
- // Add this caption as an inset source.
- wct.addInsetsSource(mTaskInfo.token,
- mOwner, 0 /* index */, WindowInsets.Type.captionBar(), mCaptionInsetsRect,
- boundingRects);
- wct.addInsetsSource(mTaskInfo.token,
- mOwner, 0 /* index */, WindowInsets.Type.mandatorySystemGestures(),
- mCaptionInsetsRect, null /* boundingRects */);
- } else {
- wct.removeInsetsSource(mTaskInfo.token, mOwner, 0 /* index */,
- WindowInsets.Type.captionBar());
- wct.removeInsetsSource(mTaskInfo.token, mOwner, 0 /* index */,
- WindowInsets.Type.mandatorySystemGestures());
}
+ // Add this caption as an inset source.
+ wct.addInsetsSource(mTaskInfo.token,
+ mOwner, 0 /* index */, WindowInsets.Type.captionBar(), mCaptionInsetsRect,
+ boundingRects);
+ wct.addInsetsSource(mTaskInfo.token,
+ mOwner, 0 /* index */, WindowInsets.Type.mandatorySystemGestures(),
+ mCaptionInsetsRect, null /* boundingRects */);
} else {
- startT.hide(mCaptionContainerSurface);
+ wct.removeInsetsSource(mTaskInfo.token, mOwner, 0 /* index */,
+ WindowInsets.Type.captionBar());
+ wct.removeInsetsSource(mTaskInfo.token, mOwner, 0 /* index */,
+ WindowInsets.Type.mandatorySystemGestures());
}
// Task surface itself
@@ -594,8 +589,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
*/
public void addCaptionInset(WindowContainerTransaction wct) {
final int captionHeightId = getCaptionHeightId(mTaskInfo.getWindowingMode());
- if (!ViewRootImpl.CAPTION_ON_SHELL || captionHeightId == Resources.ID_NULL
- || !mIsCaptionVisible) {
+ if (captionHeightId == Resources.ID_NULL || !mIsCaptionVisible) {
return;
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java
index 228b25ccb1ba..546493746da6 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java
@@ -61,7 +61,6 @@ import android.view.InsetsState;
import android.view.SurfaceControl;
import android.view.SurfaceControlViewHost;
import android.view.View;
-import android.view.ViewRootImpl;
import android.view.WindowInsets;
import android.view.WindowManager.LayoutParams;
import android.window.SurfaceSyncGroup;
@@ -252,16 +251,14 @@ public class WindowDecorationTests extends ShellTestCase {
argThat(lp -> lp.height == 64
&& lp.width == 300
&& (lp.flags & LayoutParams.FLAG_NOT_FOCUSABLE) != 0));
- if (ViewRootImpl.CAPTION_ON_SHELL) {
- verify(mMockView).setTaskFocusState(true);
- verify(mMockWindowContainerTransaction).addInsetsSource(
- eq(taskInfo.token),
- any(),
- eq(0 /* index */),
- eq(WindowInsets.Type.captionBar()),
- eq(new Rect(100, 300, 400, 364)),
- any());
- }
+ verify(mMockView).setTaskFocusState(true);
+ verify(mMockWindowContainerTransaction).addInsetsSource(
+ eq(taskInfo.token),
+ any(),
+ eq(0 /* index */),
+ eq(WindowInsets.Type.captionBar()),
+ eq(new Rect(100, 300, 400, 364)),
+ any());
verify(mMockSurfaceControlStartT).setCornerRadius(mMockTaskSurface, CORNER_RADIUS);
verify(mMockSurfaceControlFinishT).setCornerRadius(mMockTaskSurface, CORNER_RADIUS);
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
index 612ae6c875f4..db6b8fea9235 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
@@ -337,11 +337,6 @@ object Flags {
namespace = DeviceConfig.NAMESPACE_WINDOW_MANAGER,
)
- @Keep
- @JvmField
- val WM_CAPTION_ON_SHELL =
- sysPropBooleanFlag("persist.wm.debug.caption_on_shell", default = true)
-
// TODO(b/256873975): Tracking Bug
@JvmField
@Keep