Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt +16 −7 Original line number Diff line number Diff line Loading @@ -268,7 +268,8 @@ class BubblePositionerTest { ) positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) assertThat(positioner.getExpandedViewHeight(bubble)).isEqualTo(MAX_HEIGHT) } Loading @@ -294,6 +295,7 @@ class BubblePositionerTest { 0 /* taskId */, null /* locus */, true /* isDismissable */, directExecutor(), directExecutor() ) {} Loading Loading @@ -322,6 +324,7 @@ class BubblePositionerTest { 0 /* taskId */, null /* locus */, true /* isDismissable */, directExecutor(), directExecutor() ) {} Loading Loading @@ -416,7 +419,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // This bubble will have max height so it'll always be top aligned assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -433,7 +437,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // Always top aligned in phone portrait assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -452,7 +457,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // This bubble will have max height which is always top aligned on small tablets assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -470,7 +476,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // This bubble will have max height which is always top aligned on small tablets assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -489,7 +496,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // This bubble will have max height which is always top aligned on landscape, large tablet assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -507,7 +515,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) val manageButtonHeight = context.resources.getDimensionPixelSize(R.dimen.bubble_manage_button_height) Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleStackViewTest.kt +4 −1 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ class BubbleStackViewTest { BubbleLogger(UiEventLoggerFake()), positioner, BubbleEducationController(context), shellExecutor, shellExecutor ) bubbleStackViewManager = FakeBubbleStackViewManager() Loading Loading @@ -364,6 +365,7 @@ class BubbleStackViewTest { /* taskId= */ 0, "locus", /* isDismissable= */ true, directExecutor(), directExecutor() ) {} inflateBubble(bubble) Loading @@ -373,7 +375,8 @@ class BubbleStackViewTest { private fun createAndInflateBubble(): Bubble { val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val icon = Icon.createWithResource(context.resources, R.drawable.bubble_ic_overflow_button) val bubble = Bubble.createAppBubble(intent, UserHandle(1), icon, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), icon, directExecutor(), directExecutor()) inflateBubble(bubble) return bubble } Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java +113 −36 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ import com.android.wm.shell.Flags; import com.android.wm.shell.bubbles.bar.BubbleBarExpandedView; import com.android.wm.shell.bubbles.bar.BubbleBarLayerView; import com.android.wm.shell.common.bubbles.BubbleInfo; import com.android.wm.shell.shared.annotations.ShellBackgroundThread; import com.android.wm.shell.shared.annotations.ShellMainThread; import java.io.PrintWriter; import java.util.List; Loading @@ -79,6 +81,7 @@ public class Bubble implements BubbleViewProvider { private final LocusId mLocusId; private final Executor mMainExecutor; private final Executor mBgExecutor; private long mLastUpdated; private long mLastAccessed; Loading Loading @@ -111,7 +114,10 @@ public class Bubble implements BubbleViewProvider { @Nullable private BubbleTaskView mBubbleTaskView; @Nullable private BubbleViewInfoTask mInflationTask; @Nullable private BubbleViewInfoTaskLegacy mInflationTaskLegacy; private boolean mInflateSynchronously; private boolean mPendingIntentCanceled; private boolean mIsImportantConversation; Loading Loading @@ -203,7 +209,9 @@ public class Bubble implements BubbleViewProvider { @VisibleForTesting(visibility = PRIVATE) public Bubble(@NonNull final String key, @NonNull final ShortcutInfo shortcutInfo, final int desiredHeight, final int desiredHeightResId, @Nullable final String title, int taskId, @Nullable final String locus, boolean isDismissable, Executor mainExecutor, int taskId, @Nullable final String locus, boolean isDismissable, @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor, final Bubbles.BubbleMetadataFlagListener listener) { Objects.requireNonNull(key); Objects.requireNonNull(shortcutInfo); Loading @@ -222,6 +230,7 @@ public class Bubble implements BubbleViewProvider { mTitle = title; mShowBubbleUpdateDot = false; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = taskId; mBubbleMetadataFlagListener = listener; mIsAppBubble = false; Loading @@ -233,7 +242,8 @@ public class Bubble implements BubbleViewProvider { @Nullable Icon icon, boolean isAppBubble, String key, Executor mainExecutor) { @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { mGroupKey = null; mLocusId = null; mFlags = 0; Loading @@ -243,13 +253,15 @@ public class Bubble implements BubbleViewProvider { mKey = key; mShowBubbleUpdateDot = false; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; mAppIntent = intent; mDesiredHeight = Integer.MAX_VALUE; mPackageName = intent.getPackage(); } private Bubble(ShortcutInfo info, Executor mainExecutor) { private Bubble(ShortcutInfo info, @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { mGroupKey = null; mLocusId = null; mFlags = 0; Loading @@ -259,6 +271,7 @@ public class Bubble implements BubbleViewProvider { mKey = getBubbleKeyForShortcut(info); mShowBubbleUpdateDot = false; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; mAppIntent = null; mDesiredHeight = Integer.MAX_VALUE; Loading @@ -267,24 +280,21 @@ public class Bubble implements BubbleViewProvider { } /** Creates an app bubble. */ public static Bubble createAppBubble( Intent intent, UserHandle user, @Nullable Icon icon, Executor mainExecutor) { public static Bubble createAppBubble(Intent intent, UserHandle user, @Nullable Icon icon, @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { return new Bubble(intent, user, icon, /* isAppBubble= */ true, /* key= */ getAppBubbleKeyForApp(intent.getPackage(), user), mainExecutor); mainExecutor, bgExecutor); } /** Creates a shortcut bubble. */ public static Bubble createShortcutBubble( ShortcutInfo info, Executor mainExecutor) { return new Bubble(info, mainExecutor); @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { return new Bubble(info, mainExecutor, bgExecutor); } /** Loading @@ -309,7 +319,7 @@ public class Bubble implements BubbleViewProvider { public Bubble(@NonNull final BubbleEntry entry, final Bubbles.BubbleMetadataFlagListener listener, final Bubbles.PendingIntentCanceledListener intentCancelListener, Executor mainExecutor) { @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { mIsAppBubble = false; mKey = entry.getKey(); mGroupKey = entry.getGroupKey(); Loading @@ -324,6 +334,7 @@ public class Bubble implements BubbleViewProvider { }); }; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; setEntry(entry); } Loading Loading @@ -557,9 +568,11 @@ public class Bubble implements BubbleViewProvider { @Nullable BubbleBarLayerView layerView, BubbleIconFactory iconFactory, boolean skipInflation) { if (isBubbleLoading()) { if (Flags.bubbleViewInfoExecutors()) { if (mInflationTask != null && mInflationTask.getStatus() != FINISHED) { mInflationTask.cancel(true /* mayInterruptIfRunning */); } // TODO(b/353894869): switch to executors mInflationTask = new BubbleViewInfoTask(this, context, expandedViewManager, Loading @@ -576,10 +589,31 @@ public class Bubble implements BubbleViewProvider { } else { mInflationTask.execute(); } } else { if (mInflationTaskLegacy != null && mInflationTaskLegacy.getStatus() != FINISHED) { mInflationTaskLegacy.cancel(true /* mayInterruptIfRunning */); } mInflationTaskLegacy = new BubbleViewInfoTaskLegacy(this, context, expandedViewManager, taskViewFactory, positioner, stackView, layerView, iconFactory, skipInflation, bubble -> { if (callback != null) { callback.onBubbleViewsReady(bubble); } }, mMainExecutor); if (mInflateSynchronously) { mInflationTaskLegacy.onPostExecute(mInflationTaskLegacy.doInBackground()); } else { mInflationTaskLegacy.execute(); } } private boolean isBubbleLoading() { return mInflationTask != null && mInflationTask.getStatus() != FINISHED; } boolean isInflated() { Loading @@ -587,10 +621,17 @@ public class Bubble implements BubbleViewProvider { } void stopInflation() { if (Flags.bubbleViewInfoExecutors()) { if (mInflationTask == null) { return; } mInflationTask.cancel(true /* mayInterruptIfRunning */); } else { if (mInflationTaskLegacy == null) { return; } mInflationTaskLegacy.cancel(true /* mayInterruptIfRunning */); } } void setViewInfo(BubbleViewInfoTask.BubbleViewInfo info) { Loading Loading @@ -625,6 +666,42 @@ public class Bubble implements BubbleViewProvider { } } /** * @deprecated {@link BubbleViewInfoTaskLegacy} is deprecated. */ @Deprecated void setViewInfoLegacy(BubbleViewInfoTaskLegacy.BubbleViewInfo info) { if (!isInflated()) { mIconView = info.imageView; mExpandedView = info.expandedView; mBubbleBarExpandedView = info.bubbleBarExpandedView; } mShortcutInfo = info.shortcutInfo; mAppName = info.appName; if (mTitle == null) { mTitle = mAppName; } mFlyoutMessage = info.flyoutMessage; mBadgeBitmap = info.badgeBitmap; mRawBadgeBitmap = info.rawBadgeBitmap; mBubbleBitmap = info.bubbleBitmap; mDotColor = info.dotColor; mDotPath = info.dotPath; if (mExpandedView != null) { mExpandedView.update(this /* bubble */); } if (mBubbleBarExpandedView != null) { mBubbleBarExpandedView.update(this /* bubble */); } if (mIconView != null) { mIconView.setRenderedBubble(this /* bubble */); } } /** * Set visibility of bubble in the expanded state. * Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +1 −1 Original line number Diff line number Diff line Loading @@ -1495,7 +1495,7 @@ public class BubbleController implements ConfigurationChangeListener, b.setAppBubbleIntent(intent); } else { // App bubble does not exist, lets add and expand it b = Bubble.createAppBubble(intent, user, icon, mMainExecutor); b = Bubble.createAppBubble(intent, user, icon, mMainExecutor, mBackgroundExecutor); } ProtoLog.d(WM_SHELL_BUBBLES, "inflateAndAdd %s", appBubbleKey); b.setShouldAutoExpand(true); Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java +10 −4 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import com.android.wm.shell.R; import com.android.wm.shell.bubbles.Bubbles.DismissReason; import com.android.wm.shell.common.bubbles.BubbleBarUpdate; import com.android.wm.shell.common.bubbles.RemovedBubble; import com.android.wm.shell.shared.annotations.ShellBackgroundThread; import com.android.wm.shell.shared.annotations.ShellMainThread; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -201,6 +203,7 @@ public class BubbleData { private final BubblePositioner mPositioner; private final BubbleEducationController mEducationController; private final Executor mMainExecutor; private final Executor mBgExecutor; /** Bubbles that are actively in the stack. */ private final List<Bubble> mBubbles; /** Bubbles that aged out to overflow. */ Loading Loading @@ -246,12 +249,14 @@ public class BubbleData { private HashMap<String, String> mSuppressedGroupKeys = new HashMap<>(); public BubbleData(Context context, BubbleLogger bubbleLogger, BubblePositioner positioner, BubbleEducationController educationController, Executor mainExecutor) { BubbleEducationController educationController, @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { mContext = context; mLogger = bubbleLogger; mPositioner = positioner; mEducationController = educationController; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mOverflow = new BubbleOverflow(context, positioner); mBubbles = new ArrayList<>(); mOverflowBubbles = new ArrayList<>(); Loading Loading @@ -431,7 +436,8 @@ public class BubbleData { bubbleToReturn = new Bubble(entry, mBubbleMetadataFlagListener, mCancelledListener, mMainExecutor); mMainExecutor, mBgExecutor); } else { // If there's no entry it must be a persisted bubble bubbleToReturn = persistedBubble; Loading @@ -450,7 +456,7 @@ public class BubbleData { String bubbleKey = Bubble.getBubbleKeyForShortcut(info); Bubble bubbleToReturn = findAndRemoveBubbleFromOverflow(bubbleKey); if (bubbleToReturn == null) { bubbleToReturn = Bubble.createShortcutBubble(info, mMainExecutor); bubbleToReturn = Bubble.createShortcutBubble(info, mMainExecutor, mBgExecutor); } return bubbleToReturn; } Loading @@ -461,7 +467,7 @@ public class BubbleData { user); Bubble bubbleToReturn = findAndRemoveBubbleFromOverflow(bubbleKey); if (bubbleToReturn == null) { bubbleToReturn = Bubble.createAppBubble(intent, user, null, mMainExecutor); bubbleToReturn = Bubble.createAppBubble(intent, user, null, mMainExecutor, mBgExecutor); } return bubbleToReturn; } Loading Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt +16 −7 Original line number Diff line number Diff line Loading @@ -268,7 +268,8 @@ class BubblePositionerTest { ) positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) assertThat(positioner.getExpandedViewHeight(bubble)).isEqualTo(MAX_HEIGHT) } Loading @@ -294,6 +295,7 @@ class BubblePositionerTest { 0 /* taskId */, null /* locus */, true /* isDismissable */, directExecutor(), directExecutor() ) {} Loading Loading @@ -322,6 +324,7 @@ class BubblePositionerTest { 0 /* taskId */, null /* locus */, true /* isDismissable */, directExecutor(), directExecutor() ) {} Loading Loading @@ -416,7 +419,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // This bubble will have max height so it'll always be top aligned assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -433,7 +437,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // Always top aligned in phone portrait assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -452,7 +457,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // This bubble will have max height which is always top aligned on small tablets assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -470,7 +476,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // This bubble will have max height which is always top aligned on small tablets assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -489,7 +496,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) // This bubble will have max height which is always top aligned on landscape, large tablet assertThat(positioner.getExpandedViewY(bubble, 0f /* bubblePosition */)) Loading @@ -507,7 +515,8 @@ class BubblePositionerTest { positioner.update(deviceConfig) val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), null, directExecutor(), directExecutor()) val manageButtonHeight = context.resources.getDimensionPixelSize(R.dimen.bubble_manage_button_height) Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleStackViewTest.kt +4 −1 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ class BubbleStackViewTest { BubbleLogger(UiEventLoggerFake()), positioner, BubbleEducationController(context), shellExecutor, shellExecutor ) bubbleStackViewManager = FakeBubbleStackViewManager() Loading Loading @@ -364,6 +365,7 @@ class BubbleStackViewTest { /* taskId= */ 0, "locus", /* isDismissable= */ true, directExecutor(), directExecutor() ) {} inflateBubble(bubble) Loading @@ -373,7 +375,8 @@ class BubbleStackViewTest { private fun createAndInflateBubble(): Bubble { val intent = Intent(Intent.ACTION_VIEW).setPackage(context.packageName) val icon = Icon.createWithResource(context.resources, R.drawable.bubble_ic_overflow_button) val bubble = Bubble.createAppBubble(intent, UserHandle(1), icon, directExecutor()) val bubble = Bubble.createAppBubble(intent, UserHandle(1), icon, directExecutor(), directExecutor()) inflateBubble(bubble) return bubble } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java +113 −36 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ import com.android.wm.shell.Flags; import com.android.wm.shell.bubbles.bar.BubbleBarExpandedView; import com.android.wm.shell.bubbles.bar.BubbleBarLayerView; import com.android.wm.shell.common.bubbles.BubbleInfo; import com.android.wm.shell.shared.annotations.ShellBackgroundThread; import com.android.wm.shell.shared.annotations.ShellMainThread; import java.io.PrintWriter; import java.util.List; Loading @@ -79,6 +81,7 @@ public class Bubble implements BubbleViewProvider { private final LocusId mLocusId; private final Executor mMainExecutor; private final Executor mBgExecutor; private long mLastUpdated; private long mLastAccessed; Loading Loading @@ -111,7 +114,10 @@ public class Bubble implements BubbleViewProvider { @Nullable private BubbleTaskView mBubbleTaskView; @Nullable private BubbleViewInfoTask mInflationTask; @Nullable private BubbleViewInfoTaskLegacy mInflationTaskLegacy; private boolean mInflateSynchronously; private boolean mPendingIntentCanceled; private boolean mIsImportantConversation; Loading Loading @@ -203,7 +209,9 @@ public class Bubble implements BubbleViewProvider { @VisibleForTesting(visibility = PRIVATE) public Bubble(@NonNull final String key, @NonNull final ShortcutInfo shortcutInfo, final int desiredHeight, final int desiredHeightResId, @Nullable final String title, int taskId, @Nullable final String locus, boolean isDismissable, Executor mainExecutor, int taskId, @Nullable final String locus, boolean isDismissable, @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor, final Bubbles.BubbleMetadataFlagListener listener) { Objects.requireNonNull(key); Objects.requireNonNull(shortcutInfo); Loading @@ -222,6 +230,7 @@ public class Bubble implements BubbleViewProvider { mTitle = title; mShowBubbleUpdateDot = false; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = taskId; mBubbleMetadataFlagListener = listener; mIsAppBubble = false; Loading @@ -233,7 +242,8 @@ public class Bubble implements BubbleViewProvider { @Nullable Icon icon, boolean isAppBubble, String key, Executor mainExecutor) { @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { mGroupKey = null; mLocusId = null; mFlags = 0; Loading @@ -243,13 +253,15 @@ public class Bubble implements BubbleViewProvider { mKey = key; mShowBubbleUpdateDot = false; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; mAppIntent = intent; mDesiredHeight = Integer.MAX_VALUE; mPackageName = intent.getPackage(); } private Bubble(ShortcutInfo info, Executor mainExecutor) { private Bubble(ShortcutInfo info, @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { mGroupKey = null; mLocusId = null; mFlags = 0; Loading @@ -259,6 +271,7 @@ public class Bubble implements BubbleViewProvider { mKey = getBubbleKeyForShortcut(info); mShowBubbleUpdateDot = false; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; mAppIntent = null; mDesiredHeight = Integer.MAX_VALUE; Loading @@ -267,24 +280,21 @@ public class Bubble implements BubbleViewProvider { } /** Creates an app bubble. */ public static Bubble createAppBubble( Intent intent, UserHandle user, @Nullable Icon icon, Executor mainExecutor) { public static Bubble createAppBubble(Intent intent, UserHandle user, @Nullable Icon icon, @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { return new Bubble(intent, user, icon, /* isAppBubble= */ true, /* key= */ getAppBubbleKeyForApp(intent.getPackage(), user), mainExecutor); mainExecutor, bgExecutor); } /** Creates a shortcut bubble. */ public static Bubble createShortcutBubble( ShortcutInfo info, Executor mainExecutor) { return new Bubble(info, mainExecutor); @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { return new Bubble(info, mainExecutor, bgExecutor); } /** Loading @@ -309,7 +319,7 @@ public class Bubble implements BubbleViewProvider { public Bubble(@NonNull final BubbleEntry entry, final Bubbles.BubbleMetadataFlagListener listener, final Bubbles.PendingIntentCanceledListener intentCancelListener, Executor mainExecutor) { @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { mIsAppBubble = false; mKey = entry.getKey(); mGroupKey = entry.getGroupKey(); Loading @@ -324,6 +334,7 @@ public class Bubble implements BubbleViewProvider { }); }; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; setEntry(entry); } Loading Loading @@ -557,9 +568,11 @@ public class Bubble implements BubbleViewProvider { @Nullable BubbleBarLayerView layerView, BubbleIconFactory iconFactory, boolean skipInflation) { if (isBubbleLoading()) { if (Flags.bubbleViewInfoExecutors()) { if (mInflationTask != null && mInflationTask.getStatus() != FINISHED) { mInflationTask.cancel(true /* mayInterruptIfRunning */); } // TODO(b/353894869): switch to executors mInflationTask = new BubbleViewInfoTask(this, context, expandedViewManager, Loading @@ -576,10 +589,31 @@ public class Bubble implements BubbleViewProvider { } else { mInflationTask.execute(); } } else { if (mInflationTaskLegacy != null && mInflationTaskLegacy.getStatus() != FINISHED) { mInflationTaskLegacy.cancel(true /* mayInterruptIfRunning */); } mInflationTaskLegacy = new BubbleViewInfoTaskLegacy(this, context, expandedViewManager, taskViewFactory, positioner, stackView, layerView, iconFactory, skipInflation, bubble -> { if (callback != null) { callback.onBubbleViewsReady(bubble); } }, mMainExecutor); if (mInflateSynchronously) { mInflationTaskLegacy.onPostExecute(mInflationTaskLegacy.doInBackground()); } else { mInflationTaskLegacy.execute(); } } private boolean isBubbleLoading() { return mInflationTask != null && mInflationTask.getStatus() != FINISHED; } boolean isInflated() { Loading @@ -587,10 +621,17 @@ public class Bubble implements BubbleViewProvider { } void stopInflation() { if (Flags.bubbleViewInfoExecutors()) { if (mInflationTask == null) { return; } mInflationTask.cancel(true /* mayInterruptIfRunning */); } else { if (mInflationTaskLegacy == null) { return; } mInflationTaskLegacy.cancel(true /* mayInterruptIfRunning */); } } void setViewInfo(BubbleViewInfoTask.BubbleViewInfo info) { Loading Loading @@ -625,6 +666,42 @@ public class Bubble implements BubbleViewProvider { } } /** * @deprecated {@link BubbleViewInfoTaskLegacy} is deprecated. */ @Deprecated void setViewInfoLegacy(BubbleViewInfoTaskLegacy.BubbleViewInfo info) { if (!isInflated()) { mIconView = info.imageView; mExpandedView = info.expandedView; mBubbleBarExpandedView = info.bubbleBarExpandedView; } mShortcutInfo = info.shortcutInfo; mAppName = info.appName; if (mTitle == null) { mTitle = mAppName; } mFlyoutMessage = info.flyoutMessage; mBadgeBitmap = info.badgeBitmap; mRawBadgeBitmap = info.rawBadgeBitmap; mBubbleBitmap = info.bubbleBitmap; mDotColor = info.dotColor; mDotPath = info.dotPath; if (mExpandedView != null) { mExpandedView.update(this /* bubble */); } if (mBubbleBarExpandedView != null) { mBubbleBarExpandedView.update(this /* bubble */); } if (mIconView != null) { mIconView.setRenderedBubble(this /* bubble */); } } /** * Set visibility of bubble in the expanded state. * Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +1 −1 Original line number Diff line number Diff line Loading @@ -1495,7 +1495,7 @@ public class BubbleController implements ConfigurationChangeListener, b.setAppBubbleIntent(intent); } else { // App bubble does not exist, lets add and expand it b = Bubble.createAppBubble(intent, user, icon, mMainExecutor); b = Bubble.createAppBubble(intent, user, icon, mMainExecutor, mBackgroundExecutor); } ProtoLog.d(WM_SHELL_BUBBLES, "inflateAndAdd %s", appBubbleKey); b.setShouldAutoExpand(true); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java +10 −4 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import com.android.wm.shell.R; import com.android.wm.shell.bubbles.Bubbles.DismissReason; import com.android.wm.shell.common.bubbles.BubbleBarUpdate; import com.android.wm.shell.common.bubbles.RemovedBubble; import com.android.wm.shell.shared.annotations.ShellBackgroundThread; import com.android.wm.shell.shared.annotations.ShellMainThread; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -201,6 +203,7 @@ public class BubbleData { private final BubblePositioner mPositioner; private final BubbleEducationController mEducationController; private final Executor mMainExecutor; private final Executor mBgExecutor; /** Bubbles that are actively in the stack. */ private final List<Bubble> mBubbles; /** Bubbles that aged out to overflow. */ Loading Loading @@ -246,12 +249,14 @@ public class BubbleData { private HashMap<String, String> mSuppressedGroupKeys = new HashMap<>(); public BubbleData(Context context, BubbleLogger bubbleLogger, BubblePositioner positioner, BubbleEducationController educationController, Executor mainExecutor) { BubbleEducationController educationController, @ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) { mContext = context; mLogger = bubbleLogger; mPositioner = positioner; mEducationController = educationController; mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mOverflow = new BubbleOverflow(context, positioner); mBubbles = new ArrayList<>(); mOverflowBubbles = new ArrayList<>(); Loading Loading @@ -431,7 +436,8 @@ public class BubbleData { bubbleToReturn = new Bubble(entry, mBubbleMetadataFlagListener, mCancelledListener, mMainExecutor); mMainExecutor, mBgExecutor); } else { // If there's no entry it must be a persisted bubble bubbleToReturn = persistedBubble; Loading @@ -450,7 +456,7 @@ public class BubbleData { String bubbleKey = Bubble.getBubbleKeyForShortcut(info); Bubble bubbleToReturn = findAndRemoveBubbleFromOverflow(bubbleKey); if (bubbleToReturn == null) { bubbleToReturn = Bubble.createShortcutBubble(info, mMainExecutor); bubbleToReturn = Bubble.createShortcutBubble(info, mMainExecutor, mBgExecutor); } return bubbleToReturn; } Loading @@ -461,7 +467,7 @@ public class BubbleData { user); Bubble bubbleToReturn = findAndRemoveBubbleFromOverflow(bubbleKey); if (bubbleToReturn == null) { bubbleToReturn = Bubble.createAppBubble(intent, user, null, mMainExecutor); bubbleToReturn = Bubble.createAppBubble(intent, user, null, mMainExecutor, mBgExecutor); } return bubbleToReturn; } Loading