From 26d226301c56fb53f6eddb60dc89212a747c06a2 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Wed, 31 Mar 2021 12:18:32 -0700 Subject: [PATCH] Fix bubbles for workprofile - use getPackageManagerForUser when looking up app info - add test for it Bug: 184041127 Test: atest BubblesTest Test: - have a managed work profile - install the bubbles app *only* for the work profile - make some bubbles => Notice bubbles appear - dismiss all the bubbles - restart the device, add a bubble - open the bubble, navigate to the bubble overflow => notice the previously dismissed workprofile bubbles are in the overflow Change-Id: I479bb717b3c365346682331b0def7170ed1a791b --- .../com/android/wm/shell/bubbles/Bubble.java | 8 +- .../wm/shell/bubbles/BubbleIconFactory.java | 5 +- .../wm/shell/bubbles/BubbleViewInfoTask.java | 10 +- .../android/systemui/wmshell/BubblesTest.java | 92 ++++++++++++++++++- 4 files changed, 107 insertions(+), 8 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java index 0a15d8468983b..f6e92ef0e8eae 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java @@ -165,7 +165,8 @@ public class Bubble implements BubbleViewProvider { * Create a bubble with limited information based on given {@link ShortcutInfo}. * Note: Currently this is only being used when the bubble is persisted to disk. */ - Bubble(@NonNull final String key, @NonNull final ShortcutInfo shortcutInfo, + @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, Executor mainExecutor) { Objects.requireNonNull(key); @@ -188,7 +189,7 @@ public class Bubble implements BubbleViewProvider { } @VisibleForTesting(visibility = PRIVATE) - Bubble(@NonNull final BubbleEntry entry, + public Bubble(@NonNull final BubbleEntry entry, @Nullable final Bubbles.SuppressionChangedListener listener, final Bubbles.PendingIntentCanceledListener intentCancelListener, Executor mainExecutor) { @@ -718,7 +719,8 @@ public class Bubble implements BubbleViewProvider { private int getUid(final Context context) { if (mAppUid != -1) return mAppUid; - final PackageManager pm = context.getPackageManager(); + final PackageManager pm = BubbleController.getPackageManagerForUser(context, + mUser.getIdentifier()); if (pm == null) return -1; try { final ApplicationInfo info = pm.getApplicationInfo(mShortcutInfo.getPackage(), 0); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleIconFactory.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleIconFactory.java index fe3f9ef6aa5f2..e64ed6a0836c1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleIconFactory.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleIconFactory.java @@ -29,6 +29,8 @@ import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; +import androidx.annotation.VisibleForTesting; + import com.android.launcher3.icons.BaseIconFactory; import com.android.launcher3.icons.BitmapInfo; import com.android.launcher3.icons.ShadowGenerator; @@ -39,11 +41,12 @@ import com.android.wm.shell.R; * We are not using Launcher's IconFactory because bubbles only runs on the UI thread, * so there is no need to manage a pool across multiple threads. */ +@VisibleForTesting public class BubbleIconFactory extends BaseIconFactory { private int mBadgeSize; - protected BubbleIconFactory(Context context) { + public BubbleIconFactory(Context context) { super(context, context.getResources().getConfiguration().densityDpi, context.getResources().getDimensionPixelSize(R.dimen.individual_bubble_size)); mBadgeSize = mContext.getResources().getDimensionPixelSize( diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTask.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTask.java index 5cdce886a9e8b..fc53ef26dbd95 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTask.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTask.java @@ -39,6 +39,7 @@ import android.util.PathParser; import android.view.LayoutInflater; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import com.android.internal.graphics.ColorUtils; import com.android.launcher3.icons.BitmapInfo; @@ -118,7 +119,8 @@ public class BubbleViewInfoTask extends AsyncTask