Merge "Add folders in all apps aconfig flag" into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 1a3c497..74d2d60 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -424,14 +424,15 @@
      * @see android.view.WindowInsets.Type#systemBars()
      */
     public int getContentHeightToReportToApps() {
-        if ((mActivity.isPhoneMode() && !mActivity.isThreeButtonNav())
-                || DisplayController.isTransientTaskbar(mActivity)) {
+        if (mActivity.isUserSetupComplete() && (mActivity.isPhoneGestureNavMode()
+                || DisplayController.isTransientTaskbar(mActivity))) {
             return getStashedHeight();
         }
 
         if (supportsVisualStashing() && hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) {
             DeviceProfile dp = mActivity.getDeviceProfile();
-            if (hasAnyFlag(FLAG_STASHED_IN_APP_SETUP) && dp.isTaskbarPresent) {
+            if (hasAnyFlag(FLAG_STASHED_IN_APP_SETUP) && (dp.isTaskbarPresent
+                    || mActivity.isPhoneGestureNavMode())) {
                 // We always show the back button in SUW but in portrait the SUW layout may not
                 // be wide enough to support overlapping the nav bar with its content.
                 // We're sending different res values in portrait vs landscape
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
index 46c2e25..046f5b6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
@@ -31,8 +31,6 @@
 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING;
 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED;
 
-import static java.lang.Math.abs;
-
 import android.annotation.BinderThread;
 import android.annotation.Nullable;
 import android.app.Notification;
@@ -47,7 +45,6 @@
 import android.graphics.Matrix;
 import android.graphics.Path;
 import android.graphics.Point;
-import android.graphics.Rect;
 import android.graphics.drawable.AdaptiveIconDrawable;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
@@ -67,7 +64,6 @@
 import com.android.launcher3.icons.BitmapInfo;
 import com.android.launcher3.icons.BubbleIconFactory;
 import com.android.launcher3.shortcuts.ShortcutRequest;
-import com.android.launcher3.util.DisplayController;
 import com.android.launcher3.util.Executors.SimpleThreadFactory;
 import com.android.quickstep.SystemUiProxy;
 import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
@@ -153,8 +149,8 @@
     private BubbleStashedHandleViewController mBubbleStashedHandleViewController;
     private BubblePinController mBubblePinController;
 
-    // Keep track of bubble bar bounds sent to shell to avoid sending duplicate updates
-    private final Rect mLastSentBubbleBarBounds = new Rect();
+    // Cache last sent top coordinate to avoid sending duplicate updates to shell
+    private int mLastSentBubbleBarTop;
 
     /**
      * Similar to {@link BubbleBarUpdate} but rather than {@link BubbleInfo}s it uses
@@ -445,9 +441,8 @@
                         info.getFlags() | Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION);
                 mSelectedBubble.getView().updateDotVisibility(true /* animate */);
             }
-            Rect bounds = getExpandedBubbleBarDisplayBounds();
-            mLastSentBubbleBarBounds.set(bounds);
-            mSystemUiProxy.showBubble(getSelectedBubbleKey(), bounds);
+            mLastSentBubbleBarTop = mBarView.getRestingTopPositionOnScreen();
+            mSystemUiProxy.showBubble(getSelectedBubbleKey(), mLastSentBubbleBarTop);
         } else {
             Log.w(TAG, "Trying to show the selected bubble but it's null");
         }
@@ -636,42 +631,14 @@
         return mIconFactory.createBadgedIconBitmap(drawable).icon;
     }
 
-    private void onBubbleBarBoundsChanged(Rect newBounds) {
-        Rect displayBounds = convertToDisplayBounds(newBounds);
-        // Only send bounds over if they changed
-        if (!displayBounds.equals(mLastSentBubbleBarBounds)) {
-            mLastSentBubbleBarBounds.set(displayBounds);
-            mSystemUiProxy.setBubbleBarBounds(displayBounds);
+    private void onBubbleBarBoundsChanged() {
+        int newTop = mBarView.getRestingTopPositionOnScreen();
+        if (newTop != mLastSentBubbleBarTop) {
+            mLastSentBubbleBarTop = newTop;
+            mSystemUiProxy.updateBubbleBarTopOnScreen(newTop);
         }
     }
 
-    /**
-     * Get bounds of the bubble bar as if it would be expanded.
-     * Calculates the bounds instead of retrieving current view location as the view may be
-     * animating.
-     */
-    private Rect getExpandedBubbleBarDisplayBounds() {
-        return convertToDisplayBounds(mBarView.getBubbleBarBounds());
-    }
-
-    private Rect convertToDisplayBounds(Rect currentBarBounds) {
-        Point displaySize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
-        Rect displayBounds = new Rect();
-        // currentBarBounds is only useful for distance from left or right edge.
-        // It contains the current bounds, calculate the expanded bounds.
-        if (mBarView.getBubbleBarLocation().isOnLeft(mBarView.isLayoutRtl())) {
-            displayBounds.left = currentBarBounds.left;
-            displayBounds.right = (int) (currentBarBounds.left + mBarView.expandedWidth());
-        } else {
-            displayBounds.left = (int) (currentBarBounds.right - mBarView.expandedWidth());
-            displayBounds.right = currentBarBounds.right;
-        }
-        final int translation = (int) abs(mBubbleStashController.getBubbleBarTranslationY());
-        displayBounds.top = displaySize.y - currentBarBounds.height() - translation;
-        displayBounds.bottom = displaySize.y - translation;
-        return displayBounds;
-    }
-
     /** Interface for checking whether the IME is visible. */
     public interface ImeVisibilityChecker {
         /** Whether the IME is visible. */
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
index 43fe251..23e52e6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
@@ -43,6 +43,7 @@
 
 import com.android.launcher3.R;
 import com.android.launcher3.anim.SpringAnimationBuilder;
+import com.android.launcher3.util.DisplayController;
 import com.android.wm.shell.common.bubbles.BubbleBarLocation;
 
 import java.util.List;
@@ -554,6 +555,15 @@
     }
 
     /**
+     * Get bubble bar top coordinate on screen when bar is resting
+     */
+    public int getRestingTopPositionOnScreen() {
+        int displayHeight = DisplayController.INSTANCE.get(getContext()).getInfo().currentSize.y;
+        int bubbleBarHeight = getBubbleBarBounds().height();
+        return displayHeight - bubbleBarHeight + (int) mController.getBubbleBarTranslationY();
+    }
+
+    /**
      * Updates the bounds with translation that may have been applied and returns the result.
      */
     public Rect getBubbleBarBounds() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index 5f75b3b..f614dc6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -93,8 +93,6 @@
     @Nullable
     private BubbleBarBoundsChangeListener mBoundsChangeListener;
 
-    private final Rect mPreviousBubbleBarBounds = new Rect();
-
     public BubbleBarViewController(TaskbarActivityContext activity, BubbleBarView barView) {
         mActivity = activity;
         mBarView = barView;
@@ -122,12 +120,8 @@
         mBarView.addOnLayoutChangeListener(
                 (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
                     mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
-                    Rect bubbleBarBounds = mBarView.getBubbleBarBounds();
-                    if (!bubbleBarBounds.equals(mPreviousBubbleBarBounds)) {
-                        mPreviousBubbleBarBounds.set(bubbleBarBounds);
-                        if (mBoundsChangeListener != null) {
-                            mBoundsChangeListener.onBoundsChanged(bubbleBarBounds);
-                        }
+                    if (mBoundsChangeListener != null) {
+                        mBoundsChangeListener.onBoundsChanged();
                     }
                 });
 
@@ -497,7 +491,7 @@
      * that a bubble is being dragged to dismiss.
      * @param bubbleView dragged bubble view
      */
-    public void onDragStart(@NonNull BubbleView bubbleView) {
+    public void onBubbleDragStart(@NonNull BubbleView bubbleView) {
         if (bubbleView.getBubble() == null) return;
 
         mSystemUiProxy.startBubbleDrag(bubbleView.getBubble().getKey());
@@ -507,20 +501,19 @@
     /**
      * Notifies SystemUI to expand the selected bubble when the bubble is released.
      */
-    public void onDragRelease(BubbleBarLocation location) {
-        // TODO(b/330585402): send new bubble bar bounds to shell for the animation
-        mSystemUiProxy.stopBubbleDrag(location);
+    public void onBubbleDragRelease(BubbleBarLocation location) {
+        mSystemUiProxy.stopBubbleDrag(location, mBarView.getRestingTopPositionOnScreen());
     }
 
     /**
      * Notifies {@link BubbleBarView} that drag and all animations are finished.
      */
-    public void onDragBubbleEnded() {
+    public void onBubbleDragEnd() {
         mBarView.setDraggedBubble(null);
     }
 
     /** Notifies that dragging the bubble bar ended. */
-    public void onDragBubbleBarEnded() {
+    public void onBubbleBarDragEnd() {
         // we may have changed the bubble bar translation Y value from the value it had at the
         // beginning of the drag, so update the translation Y animator state
         mBubbleBarTranslationY.updateValue(mBarView.getTranslationY());
@@ -576,6 +569,6 @@
      */
     public interface BubbleBarBoundsChangeListener {
         /** Called when bounds have changed */
-        void onBoundsChanged(Rect newBounds);
+        void onBoundsChanged();
     }
 }
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java
index 604ae89..2ebc3e8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java
@@ -97,7 +97,7 @@
             @Override
             void onDragStart() {
                 mBubblePinController.setListener(mLocationChangeListener);
-                mBubbleBarViewController.onDragStart(bubbleView);
+                mBubbleBarViewController.onBubbleDragStart(bubbleView);
                 mBubblePinController.onDragStart(
                         mBubbleBarViewController.getBubbleBarLocation().isOnLeft(
                                 bubbleView.isLayoutRtl()));
@@ -113,7 +113,7 @@
             @Override
             protected void onDragRelease() {
                 mBubblePinController.onDragEnd();
-                mBubbleBarViewController.onDragRelease(mReleasedLocation);
+                mBubbleBarViewController.onBubbleDragRelease(mReleasedLocation);
             }
 
             @Override
@@ -124,7 +124,7 @@
             @Override
             void onDragEnd() {
                 mBubbleBarController.updateBubbleBarLocation(mReleasedLocation);
-                mBubbleBarViewController.onDragBubbleEnded();
+                mBubbleBarViewController.onBubbleDragEnd();
                 mBubblePinController.setListener(null);
             }
 
@@ -192,7 +192,7 @@
                 bubbleBarView.setIsDragging(false);
                 // Restoring the initial pivot for the bubble bar view
                 bubbleBarView.setRelativePivot(initialRelativePivot.x, initialRelativePivot.y);
-                mBubbleBarViewController.onDragBubbleBarEnded();
+                mBubbleBarViewController.onBubbleBarDragEnd();
                 mBubbleBarPinController.setListener(null);
             }
 
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index da1d322..0ac3ec7 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -761,12 +761,12 @@
     /**
      * Tells SysUI to show the bubble with the provided key.
      * @param key the key of the bubble to show.
-     * @param bubbleBarBounds bounds of the bubble bar in display coordinates
+     * @param top top coordinate of bubble bar on screen
      */
-    public void showBubble(String key, Rect bubbleBarBounds) {
+    public void showBubble(String key, int top) {
         if (mBubbles != null) {
             try {
-                mBubbles.showBubble(key, bubbleBarBounds);
+                mBubbles.showBubble(key, top);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed call showBubble");
             }
@@ -815,12 +815,14 @@
     /**
      * Tells SysUI when the bubble stops being dragged.
      * Should be called only when the bubble bar is expanded.
+     *
      * @param location location of the bubble bar
+     * @param top      new top coordinate for bubble bar on screen
      */
-    public void stopBubbleDrag(BubbleBarLocation location) {
+    public void stopBubbleDrag(BubbleBarLocation location, int top) {
         if (mBubbles == null) return;
         try {
-            mBubbles.stopBubbleDrag(location);
+            mBubbles.stopBubbleDrag(location, top);
         } catch (RemoteException e) {
             Log.w(TAG, "Failed call stopBubbleDrag");
         }
@@ -864,16 +866,17 @@
     }
 
     /**
-     * Tells SysUI the bounds for the bubble bar
-     * @param bubbleBarBounds bounds of the bubble bar in display coordinates
+     * Tells SysUI the top coordinate of bubble bar on screen
+     *
+     * @param topOnScreen top coordinate for bubble bar on screen
      */
-    public void setBubbleBarBounds(Rect bubbleBarBounds) {
+    public void updateBubbleBarTopOnScreen(int topOnScreen) {
         try {
             if (mBubbles != null) {
-                mBubbles.setBubbleBarBounds(bubbleBarBounds);
+                mBubbles.updateBubbleBarTopOnScreen(topOnScreen);
             }
         } catch (RemoteException e) {
-            Log.w(TAG, "Failed call setBubbleBarBounds");
+            Log.w(TAG, "Failed call updateBubbleBarTopOnScreen");
         }
     }
 
diff --git a/res/layout/work_apps_edu.xml b/res/layout/work_apps_edu.xml
index f557fb6..99db8c6 100644
--- a/res/layout/work_apps_edu.xml
+++ b/res/layout/work_apps_edu.xml
@@ -50,9 +50,9 @@
                 android:id="@+id/action_btn"
                 android:layout_width="@dimen/x_icon_size"
                 android:layout_height="@dimen/x_icon_size"
+                android:scaleType="centerInside"
                 android:layout_gravity="center"
                 android:contentDescription="@string/accessibility_close"
-                android:padding="@dimen/x_icon_padding"
                 android:background="@android:color/transparent"
                 android:src="@drawable/ic_remove_no_shadow" />
         </FrameLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 74fadda..b4f8a47 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -167,7 +167,6 @@
     <!-- (x) icon button inside work edu card -->
     <dimen name="rounded_button_width">24dp</dimen>
     <dimen name="x_icon_size">16dp</dimen>
-    <dimen name="x_icon_padding">4dp</dimen>
 
     <!-- rounded button shown inside card views, and snack bars  -->
     <dimen name="padded_rounded_button_height">48dp</dimen>
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index e3da389..47a7115 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -19,6 +19,7 @@
 import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED;
 
 import static com.android.launcher3.LauncherAppState.ACTION_FORCE_ROLOAD;
+import static com.android.launcher3.LauncherPrefs.WORK_EDU_STEP;
 import static com.android.launcher3.config.FeatureFlags.IS_STUDIO_BUILD;
 import static com.android.launcher3.icons.cache.BaseIconCache.EMPTY_CLASS_NAME;
 import static com.android.launcher3.model.PackageUpdatedTask.OP_UPDATE;
@@ -276,6 +277,9 @@
             enqueueModelUpdateTask(new PackageUpdatedTask(
                     PackageUpdatedTask.OP_USER_AVAILABILITY_CHANGE, user));
         }
+        if (Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) {
+            LauncherPrefs.get(mApp.getContext()).put(WORK_EDU_STEP, 0);
+        }
     }
 
     /**
diff --git a/src/com/android/launcher3/pm/UserCache.java b/src/com/android/launcher3/pm/UserCache.java
index b7b557d..ed25186 100644
--- a/src/com/android/launcher3/pm/UserCache.java
+++ b/src/com/android/launcher3/pm/UserCache.java
@@ -101,6 +101,7 @@
         mUserChangeReceiver.register(mContext,
                 Intent.ACTION_MANAGED_PROFILE_AVAILABLE,
                 Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE,
+                Intent.ACTION_MANAGED_PROFILE_REMOVED,
                 ACTION_PROFILE_ADDED,
                 ACTION_PROFILE_REMOVED,
                 ACTION_PROFILE_UNLOCKED,