Merge changes Id34d658b,I484c83c4 into tm-qpr-dev

* changes:
  Remove previous changes for showing bubbles in taskbar
  Change flag to sysprop because we need it in launcher too
This commit is contained in:
Mady Mellor
2023-03-03 17:54:03 +00:00
committed by Android (Google) Code Review
8 changed files with 21 additions and 154 deletions

View File

@@ -61,6 +61,7 @@ import android.os.Binder;
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.service.notification.NotificationListenerService;
@@ -125,6 +126,15 @@ public class BubbleController implements ConfigurationChangeListener {
private static final String SYSTEM_DIALOG_REASON_KEY = "reason";
private static final String SYSTEM_DIALOG_REASON_GESTURE_NAV = "gestureNav";
// TODO(b/256873975) Should use proper flag when available to shell/launcher
/**
* Whether bubbles are showing in the bubble bar from launcher. This is only available
* on large screens and {@link BubbleController#isShowingAsBubbleBar()} should be used
* to check all conditions that indicate if the bubble bar is in use.
*/
private static final boolean BUBBLE_BAR_ENABLED =
SystemProperties.getBoolean("persist.wm.debug.bubble_bar", false);
private final Context mContext;
private final BubblesImpl mImpl = new BubblesImpl();
private Bubbles.BubbleExpandListener mExpandListener;
@@ -150,9 +160,6 @@ public class BubbleController implements ConfigurationChangeListener {
private final ShellExecutor mBackgroundExecutor;
// Whether or not we should show bubbles pinned at the bottom of the screen.
private boolean mIsBubbleBarEnabled;
private BubbleLogger mLogger;
private BubbleData mBubbleData;
@Nullable private BubbleStackView mStackView;
@@ -533,10 +540,10 @@ public class BubbleController implements ConfigurationChangeListener {
mDataRepository.removeBubblesForUser(removedUserId, parentUserId);
}
// TODO(b/256873975): Should pass this into the constructor once flags are available to shell.
/** Sets whether the bubble bar is enabled (i.e. bubbles pinned to bottom on large screens). */
public void setBubbleBarEnabled(boolean enabled) {
mIsBubbleBarEnabled = enabled;
/** Whether bubbles are showing in the bubble bar. */
public boolean isShowingAsBubbleBar() {
// TODO(b/269670598): should also check that we're in gesture nav
return BUBBLE_BAR_ENABLED && mBubblePositioner.isLargeScreen();
}
/** Whether this userId belongs to the current user. */
@@ -605,12 +612,6 @@ public class BubbleController implements ConfigurationChangeListener {
mStackView.setUnbubbleConversationCallback(mSysuiProxy::onUnbubbleConversation);
}
if (mIsBubbleBarEnabled && mBubblePositioner.isLargeScreen()) {
mBubblePositioner.setUsePinnedLocation(true);
} else {
mBubblePositioner.setUsePinnedLocation(false);
}
addToWindowManagerMaybe();
}
@@ -1851,13 +1852,6 @@ public class BubbleController implements ConfigurationChangeListener {
});
}
@Override
public void setBubbleBarEnabled(boolean enabled) {
mMainExecutor.execute(() -> {
BubbleController.this.setBubbleBarEnabled(enabled);
});
}
@Override
public void onNotificationPanelExpandedChanged(boolean expanded) {
mMainExecutor.execute(

View File

@@ -283,7 +283,7 @@ public class BubbleData {
}
boolean isShowingOverflow() {
return mShowingOverflow && (isExpanded() || mPositioner.showingInTaskbar());
return mShowingOverflow && isExpanded();
}
/**

View File

@@ -18,9 +18,6 @@ package com.android.wm.shell.bubbles;
import static android.view.View.LAYOUT_DIRECTION_RTL;
import static java.lang.annotation.RetentionPolicy.SOURCE;
import android.annotation.IntDef;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -39,8 +36,6 @@ import androidx.annotation.VisibleForTesting;
import com.android.launcher3.icons.IconNormalizer;
import com.android.wm.shell.R;
import java.lang.annotation.Retention;
/**
* Keeps track of display size, configuration, and specific bubble sizes. One place for all
* placement and positioning calculations to refer to.
@@ -50,15 +45,6 @@ public class BubblePositioner {
? "BubblePositioner"
: BubbleDebugConfig.TAG_BUBBLES;
@Retention(SOURCE)
@IntDef({TASKBAR_POSITION_NONE, TASKBAR_POSITION_RIGHT, TASKBAR_POSITION_LEFT,
TASKBAR_POSITION_BOTTOM})
@interface TaskbarPosition {}
public static final int TASKBAR_POSITION_NONE = -1;
public static final int TASKBAR_POSITION_RIGHT = 0;
public static final int TASKBAR_POSITION_LEFT = 1;
public static final int TASKBAR_POSITION_BOTTOM = 2;
/** When the bubbles are collapsed in a stack only some of them are shown, this is how many. **/
public static final int NUM_VISIBLE_WHEN_RESTING = 2;
/** Indicates a bubble's height should be the maximum available space. **/
@@ -108,15 +94,9 @@ public class BubblePositioner {
private int mOverflowHeight;
private int mMinimumFlyoutWidthLargeScreen;
private PointF mPinLocation;
private PointF mRestingStackPosition;
private int[] mPaddings = new int[4];
private boolean mShowingInTaskbar;
private @TaskbarPosition int mTaskbarPosition = TASKBAR_POSITION_NONE;
private int mTaskbarIconSize;
private int mTaskbarSize;
public BubblePositioner(Context context, WindowManager windowManager) {
mContext = context;
mWindowManager = windowManager;
@@ -153,27 +133,11 @@ public class BubblePositioner {
+ " insets: " + insets
+ " isLargeScreen: " + mIsLargeScreen
+ " isSmallTablet: " + mIsSmallTablet
+ " bounds: " + bounds
+ " showingInTaskbar: " + mShowingInTaskbar);
+ " bounds: " + bounds);
}
updateInternal(mRotation, insets, bounds);
}
/**
* Updates position information to account for taskbar state.
*
* @param taskbarPosition which position the taskbar is displayed in.
* @param showingInTaskbar whether the taskbar is being shown.
*/
public void updateForTaskbar(int iconSize,
@TaskbarPosition int taskbarPosition, boolean showingInTaskbar, int taskbarSize) {
mShowingInTaskbar = showingInTaskbar;
mTaskbarIconSize = iconSize;
mTaskbarPosition = taskbarPosition;
mTaskbarSize = taskbarSize;
update();
}
@VisibleForTesting
public void updateInternal(int rotation, Insets insets, Rect bounds) {
mRotation = rotation;
@@ -232,10 +196,6 @@ public class BubblePositioner {
R.dimen.bubbles_flyout_min_width_large_screen);
mMaxBubbles = calculateMaxBubbles();
if (mShowingInTaskbar) {
adjustForTaskbar();
}
}
/**
@@ -260,30 +220,6 @@ public class BubblePositioner {
return mDefaultMaxBubbles;
}
/**
* Taskbar insets appear as navigationBar insets, however, unlike navigationBar this should
* not inset bubbles UI as bubbles floats above the taskbar. This adjust the available space
* and insets to account for the taskbar.
*/
// TODO(b/171559950): When the insets are reported correctly we can remove this logic
private void adjustForTaskbar() {
// When bar is showing on edges... subtract that inset because we appear on top
if (mShowingInTaskbar && mTaskbarPosition != TASKBAR_POSITION_BOTTOM) {
WindowInsets metricInsets = mWindowManager.getCurrentWindowMetrics().getWindowInsets();
Insets navBarInsets = metricInsets.getInsetsIgnoringVisibility(
WindowInsets.Type.navigationBars());
int newInsetLeft = mInsets.left;
int newInsetRight = mInsets.right;
if (mTaskbarPosition == TASKBAR_POSITION_LEFT) {
mPositionRect.left -= navBarInsets.left;
newInsetLeft -= navBarInsets.left;
} else if (mTaskbarPosition == TASKBAR_POSITION_RIGHT) {
mPositionRect.right += navBarInsets.right;
newInsetRight -= navBarInsets.right;
}
mInsets = Insets.of(newInsetLeft, mInsets.top, newInsetRight, mInsets.bottom);
}
}
/**
* @return a rect of available screen space accounting for orientation, system bars and cutouts.
@@ -327,14 +263,12 @@ public class BubblePositioner {
* to the left or right side.
*/
public boolean showBubblesVertically() {
return isLandscape() || mShowingInTaskbar || mIsLargeScreen;
return isLandscape() || mIsLargeScreen;
}
/** Size of the bubble. */
public int getBubbleSize() {
return (mShowingInTaskbar && mTaskbarIconSize > 0)
? mTaskbarIconSize
: mBubbleSize;
return mBubbleSize;
}
/** The amount of padding at the top of the screen that the bubbles avoid when being placed. */
@@ -699,9 +633,6 @@ public class BubblePositioner {
/** The position the bubble stack should rest at when collapsed. */
public PointF getRestingPosition() {
if (mPinLocation != null) {
return mPinLocation;
}
if (mRestingStackPosition == null) {
return getDefaultStartPosition();
}
@@ -713,9 +644,6 @@ public class BubblePositioner {
* is being shown.
*/
public PointF getDefaultStartPosition() {
if (mPinLocation != null) {
return mPinLocation;
}
// Start on the left if we're in LTR, right otherwise.
final boolean startOnLeft =
mContext.getResources().getConfiguration().getLayoutDirection()
@@ -730,7 +658,6 @@ public class BubblePositioner {
1 /* default starts with 1 bubble */));
}
/**
* Returns the region that the stack position must stay within. This goes slightly off the left
* and right sides of the screen, below the status bar/cutout and above the navigation bar.
@@ -750,39 +677,6 @@ public class BubblePositioner {
return allowableRegion;
}
/**
* @return whether the bubble stack is pinned to the taskbar.
*/
public boolean showingInTaskbar() {
return mShowingInTaskbar;
}
/**
* @return the taskbar position if set.
*/
public int getTaskbarPosition() {
return mTaskbarPosition;
}
public int getTaskbarSize() {
return mTaskbarSize;
}
/**
* In some situations bubbles will be pinned to a specific onscreen location. This sets whether
* bubbles should be pinned or not.
*/
public void setUsePinnedLocation(boolean usePinnedLocation) {
if (usePinnedLocation) {
mShowingInTaskbar = true;
mPinLocation = new PointF(mPositionRect.right - mBubbleSize,
mPositionRect.bottom - mBubbleSize);
} else {
mPinLocation = null;
mShowingInTaskbar = false;
}
}
/**
* Navigation bar has an area where system gestures can be started from.
*

View File

@@ -680,8 +680,6 @@ public class BubbleStackView extends FrameLayout
// Re-show the expanded view if we hid it.
showExpandedViewIfNeeded();
} else if (mPositioner.showingInTaskbar()) {
mStackAnimationController.snapStackBack();
} else {
// Fling the stack to the edge, and save whether or not it's going to end up on
// the left side of the screen.

View File

@@ -257,11 +257,6 @@ public interface Bubbles {
*/
void onUserRemoved(int removedUserId);
/**
* Sets whether bubble bar should be enabled or not.
*/
void setBubbleBarEnabled(boolean enabled);
/** Listener to find out about stack expansion / collapse events. */
interface BubbleExpandListener {
/**

View File

@@ -416,24 +416,10 @@ public class StackAnimationController extends
return destinationRelativeX;
}
/**
* Snaps the stack back to the previous resting position.
*/
public void snapStackBack() {
if (mLayout == null) {
return;
}
PointF p = getStackPositionAlongNearestHorizontalEdge();
springStackAfterFling(p.x, p.y);
}
/**
* Where the stack would be if it were snapped to the nearest horizontal edge (left or right).
*/
public PointF getStackPositionAlongNearestHorizontalEdge() {
if (mPositioner.showingInTaskbar()) {
return mPositioner.getRestingPosition();
}
final PointF stackPos = getStackPosition();
final boolean onLeft = mLayout.isFirstChildXLeftOfCenter(stackPos.x);
final RectF bounds = mPositioner.getAllowableStackPositionRegion(getBubbleCount());

View File

@@ -441,7 +441,9 @@ object Flags {
)
// TODO(b/256873975): Tracking Bug
@JvmField @Keep val WM_BUBBLE_BAR = unreleasedFlag(1111, "wm_bubble_bar")
@JvmField
@Keep
val WM_BUBBLE_BAR = sysPropBooleanFlag(1111, "persist.wm.debug.bubble_bar", default = false)
// TODO(b/260271148): Tracking bug
@Keep

View File

@@ -25,7 +25,6 @@ import static android.service.notification.NotificationListenerService.REASON_GR
import static android.service.notification.NotificationStats.DISMISSAL_BUBBLE;
import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_NEUTRAL;
import static com.android.systemui.flags.Flags.WM_BUBBLE_BAR;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
@@ -358,7 +357,6 @@ public class BubblesManager {
});
}
};
mBubbles.setBubbleBarEnabled(featureFlags.isEnabled(WM_BUBBLE_BAR));
mBubbles.setSysuiProxy(mSysuiProxy);
}