Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java +49 −43 Original line number Diff line number Diff line Loading @@ -192,10 +192,10 @@ public class Bubble implements BubbleViewProvider { * that bubble being added back to the stack anyways. */ @Nullable private PendingIntent mIntent; private boolean mIntentActive; private PendingIntent mPendingIntent; private boolean mPendingIntentActive; @Nullable private PendingIntent.CancelListener mIntentCancelListener; private PendingIntent.CancelListener mPendingIntentCancelListener; /** * Sent when the bubble & notification are no longer visible to the user (i.e. no Loading @@ -205,12 +205,10 @@ public class Bubble implements BubbleViewProvider { private PendingIntent mDeleteIntent; /** * Used only for a special bubble in the stack that has {@link #mIsAppBubble} set to true. * There can only be one of these bubbles in the stack and this intent will be populated for * that bubble. * Used for app & note bubbles. */ @Nullable private Intent mAppIntent; private Intent mIntent; /** * Set while preparing a transition for animation. Several steps are needed before animation Loading Loading @@ -275,7 +273,7 @@ public class Bubble implements BubbleViewProvider { mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; mAppIntent = intent; mIntent = intent; mDesiredHeight = Integer.MAX_VALUE; mPackageName = intent.getPackage(); } Loading @@ -294,7 +292,7 @@ public class Bubble implements BubbleViewProvider { mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; mAppIntent = null; mIntent = null; mDesiredHeight = Integer.MAX_VALUE; mPackageName = info.getPackage(); mShortcutInfo = info; Loading @@ -319,7 +317,7 @@ public class Bubble implements BubbleViewProvider { mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = task.taskId; mAppIntent = null; mIntent = null; mDesiredHeight = Integer.MAX_VALUE; mPackageName = task.baseActivity.getPackageName(); } Loading Loading @@ -413,9 +411,9 @@ public class Bubble implements BubbleViewProvider { mGroupKey = entry.getGroupKey(); mLocusId = entry.getLocusId(); mBubbleMetadataFlagListener = listener; mIntentCancelListener = intent -> { if (mIntent != null) { mIntent.unregisterCancelListener(mIntentCancelListener); mPendingIntentCancelListener = intent -> { if (mPendingIntent != null) { mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener); } mainExecutor.execute(() -> { intentCancelListener.onPendingIntentCanceled(this); Loading Loading @@ -601,10 +599,10 @@ public class Bubble implements BubbleViewProvider { if (cleanupTaskView) { cleanupTaskView(); } if (mIntent != null) { mIntent.unregisterCancelListener(mIntentCancelListener); if (mPendingIntent != null) { mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener); } mIntentActive = false; mPendingIntentActive = false; } /** Cleans-up the taskview associated with this bubble (possibly removing the task from wm) */ Loading Loading @@ -874,19 +872,19 @@ public class Bubble implements BubbleViewProvider { mDesiredHeightResId = entry.getBubbleMetadata().getDesiredHeightResId(); mIcon = entry.getBubbleMetadata().getIcon(); if (!mIntentActive || mIntent == null) { if (mIntent != null) { mIntent.unregisterCancelListener(mIntentCancelListener); if (!mPendingIntentActive || mPendingIntent == null) { if (mPendingIntent != null) { mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener); } mIntent = entry.getBubbleMetadata().getIntent(); if (mIntent != null) { mIntent.registerCancelListener(mIntentCancelListener); mPendingIntent = entry.getBubbleMetadata().getIntent(); if (mPendingIntent != null) { mPendingIntent.registerCancelListener(mPendingIntentCancelListener); } } else if (mIntent != null && entry.getBubbleMetadata().getIntent() == null) { } else if (mPendingIntent != null && entry.getBubbleMetadata().getIntent() == null) { // Was an intent bubble now it's a shortcut bubble... still unregister the listener mIntent.unregisterCancelListener(mIntentCancelListener); mIntentActive = false; mIntent = null; mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener); mPendingIntentActive = false; mPendingIntent = null; } mDeleteIntent = entry.getBubbleMetadata().getDeleteIntent(); } Loading Loading @@ -926,12 +924,15 @@ public class Bubble implements BubbleViewProvider { * Sets if the intent used for this bubble is currently active (i.e. populating an * expanded view, expanded or not). */ void setIntentActive() { mIntentActive = true; void setPendingIntentActive() { mPendingIntentActive = true; } boolean isIntentActive() { return mIntentActive; /** * Whether the pending intent of this bubble is active (i.e. has been sent). */ boolean isPendingIntentActive() { return mPendingIntentActive; } public InstanceId getInstanceId() { Loading Loading @@ -1118,9 +1119,12 @@ public class Bubble implements BubbleViewProvider { } } /** * Returns the pending intent used to populate the bubble. */ @Nullable PendingIntent getBubbleIntent() { return mIntent; PendingIntent getPendingIntent() { return mPendingIntent; } /** Loading @@ -1128,31 +1132,33 @@ public class Bubble implements BubbleViewProvider { * intent for an app. In this case we don't show a badge on the icon. */ public boolean isAppLaunchIntent() { if (BubbleAnythingFlagHelper.enableCreateAnyBubble() && mAppIntent != null) { return mAppIntent.hasCategory("android.intent.category.LAUNCHER"); if (BubbleAnythingFlagHelper.enableCreateAnyBubble() && mIntent != null) { return mIntent.hasCategory("android.intent.category.LAUNCHER"); } return false; } /** * Returns the pending intent to send when a bubble is dismissed (set via the notification API). */ @Nullable PendingIntent getDeleteIntent() { return mDeleteIntent; } /** * Returns the intent used to populate the bubble. */ @Nullable @VisibleForTesting public Intent getAppBubbleIntent() { return mAppIntent; public Intent getIntent() { return mIntent; } /** * Sets the intent for a bubble that is an app bubble (one for which {@link #mIsAppBubble} is * true). * * @param appIntent The intent to set for the app bubble. * Sets the intent used to populate the bubble. */ void setAppBubbleIntent(Intent appIntent) { mAppIntent = appIntent; void setIntent(Intent intent) { mIntent = intent; } /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +4 −3 Original line number Diff line number Diff line Loading @@ -419,10 +419,11 @@ public class BubbleController implements ConfigurationChangeListener, mBubbleData.setSuppressionChangedListener(this::onBubbleMetadataFlagChanged); mDataRepository.setSuppressionChangedListener(this::onBubbleMetadataFlagChanged); mBubbleData.setPendingIntentCancelledListener(bubble -> { if (bubble.getBubbleIntent() == null) { if (bubble.getPendingIntent() == null) { return; } if (bubble.isIntentActive() || mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) { if (bubble.isPendingIntentActive() || mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) { bubble.setPendingIntentCanceled(); return; } Loading Loading @@ -1663,7 +1664,7 @@ public class BubbleController implements ConfigurationChangeListener, // It's in the overflow, so remove it & reinflate mBubbleData.dismissBubbleWithKey(noteBubbleKey, Bubbles.DISMISS_NOTIF_CANCEL); // Update the bubble entry in the overflow with the latest intent. b.setAppBubbleIntent(intent); b.setIntent(intent); } else { // Notes bubble does not exist, lets add and expand it b = Bubble.createNotesBubble(intent, user, icon, mMainExecutor, Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +4 −5 Original line number Diff line number Diff line Loading @@ -237,8 +237,7 @@ public class BubbleExpandedView extends LinearLayout { PendingIntent pi = PendingIntent.getActivity( context, /* requestCode= */ 0, mBubble.getAppBubbleIntent() .addFlags(FLAG_ACTIVITY_MULTIPLE_TASK), mBubble.getIntent().addFlags(FLAG_ACTIVITY_MULTIPLE_TASK), PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT, /* options= */ null); mTaskView.startActivity(pi, /* fillInIntent= */ null, options, Loading @@ -252,7 +251,7 @@ public class BubbleExpandedView extends LinearLayout { } else { options.setLaunchedFromBubble(true); if (mBubble != null) { mBubble.setIntentActive(); mBubble.setPendingIntentActive(); } final Intent fillInIntent = new Intent(); // Apply flags to make behaviour match documentLaunchMode=always. Loading Loading @@ -920,7 +919,7 @@ public class BubbleExpandedView extends LinearLayout { }); if (isNew) { mPendingIntent = mBubble.getBubbleIntent(); mPendingIntent = mBubble.getPendingIntent(); if ((mPendingIntent != null || mBubble.hasMetadataShortcutId()) && mTaskView != null) { setContentVisibility(false); Loading @@ -947,7 +946,7 @@ public class BubbleExpandedView extends LinearLayout { */ private boolean didBackingContentChange(Bubble newBubble) { boolean prevWasIntentBased = mBubble != null && mPendingIntent != null; boolean newIsIntentBased = newBubble.getBubbleIntent() != null; boolean newIsIntentBased = newBubble.getPendingIntent() != null; return prevWasIntentBased != newIsIntentBased; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -119,7 +119,7 @@ public class BubbleTaskViewHelper { PendingIntent pi = PendingIntent.getActivity( context, /* requestCode= */ 0, mBubble.getAppBubbleIntent() mBubble.getIntent() .addFlags(FLAG_ACTIVITY_MULTIPLE_TASK), PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT, /* options= */ null); Loading @@ -133,7 +133,7 @@ public class BubbleTaskViewHelper { } else { options.setLaunchedFromBubble(true); if (mBubble != null) { mBubble.setIntentActive(); mBubble.setPendingIntentActive(); } final Intent fillInIntent = new Intent(); // Apply flags to make behaviour match documentLaunchMode=always. Loading Loading @@ -231,7 +231,7 @@ public class BubbleTaskViewHelper { boolean isNew = mBubble == null || didBackingContentChange(bubble); mBubble = bubble; if (isNew) { mPendingIntent = mBubble.getBubbleIntent(); mPendingIntent = mBubble.getPendingIntent(); return true; } return false; Loading Loading @@ -276,7 +276,7 @@ public class BubbleTaskViewHelper { */ private boolean didBackingContentChange(Bubble newBubble) { boolean prevWasIntentBased = mBubble != null && mPendingIntent != null; boolean newIsIntentBased = newBubble.getBubbleIntent() != null; boolean newIsIntentBased = newBubble.getPendingIntent() != null; return prevWasIntentBased != newIsIntentBased; } } packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -2110,7 +2110,7 @@ public class BubblesTest extends SysuiTestCase { assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(noteBubbleKey); assertThat(mBubbleController.isStackExpanded()).isTrue(); assertThat(mBubbleData.getBubbles().size()).isEqualTo(1); assertThat(mBubbleData.getBubbles().get(0).getAppBubbleIntent() assertThat(mBubbleData.getBubbles().get(0).getIntent() .getStringExtra("hello")).isEqualTo("world"); assertThat(mBubbleData.getOverflowBubbleWithKey(noteBubbleKey)).isNull(); } Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java +49 −43 Original line number Diff line number Diff line Loading @@ -192,10 +192,10 @@ public class Bubble implements BubbleViewProvider { * that bubble being added back to the stack anyways. */ @Nullable private PendingIntent mIntent; private boolean mIntentActive; private PendingIntent mPendingIntent; private boolean mPendingIntentActive; @Nullable private PendingIntent.CancelListener mIntentCancelListener; private PendingIntent.CancelListener mPendingIntentCancelListener; /** * Sent when the bubble & notification are no longer visible to the user (i.e. no Loading @@ -205,12 +205,10 @@ public class Bubble implements BubbleViewProvider { private PendingIntent mDeleteIntent; /** * Used only for a special bubble in the stack that has {@link #mIsAppBubble} set to true. * There can only be one of these bubbles in the stack and this intent will be populated for * that bubble. * Used for app & note bubbles. */ @Nullable private Intent mAppIntent; private Intent mIntent; /** * Set while preparing a transition for animation. Several steps are needed before animation Loading Loading @@ -275,7 +273,7 @@ public class Bubble implements BubbleViewProvider { mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; mAppIntent = intent; mIntent = intent; mDesiredHeight = Integer.MAX_VALUE; mPackageName = intent.getPackage(); } Loading @@ -294,7 +292,7 @@ public class Bubble implements BubbleViewProvider { mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = INVALID_TASK_ID; mAppIntent = null; mIntent = null; mDesiredHeight = Integer.MAX_VALUE; mPackageName = info.getPackage(); mShortcutInfo = info; Loading @@ -319,7 +317,7 @@ public class Bubble implements BubbleViewProvider { mMainExecutor = mainExecutor; mBgExecutor = bgExecutor; mTaskId = task.taskId; mAppIntent = null; mIntent = null; mDesiredHeight = Integer.MAX_VALUE; mPackageName = task.baseActivity.getPackageName(); } Loading Loading @@ -413,9 +411,9 @@ public class Bubble implements BubbleViewProvider { mGroupKey = entry.getGroupKey(); mLocusId = entry.getLocusId(); mBubbleMetadataFlagListener = listener; mIntentCancelListener = intent -> { if (mIntent != null) { mIntent.unregisterCancelListener(mIntentCancelListener); mPendingIntentCancelListener = intent -> { if (mPendingIntent != null) { mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener); } mainExecutor.execute(() -> { intentCancelListener.onPendingIntentCanceled(this); Loading Loading @@ -601,10 +599,10 @@ public class Bubble implements BubbleViewProvider { if (cleanupTaskView) { cleanupTaskView(); } if (mIntent != null) { mIntent.unregisterCancelListener(mIntentCancelListener); if (mPendingIntent != null) { mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener); } mIntentActive = false; mPendingIntentActive = false; } /** Cleans-up the taskview associated with this bubble (possibly removing the task from wm) */ Loading Loading @@ -874,19 +872,19 @@ public class Bubble implements BubbleViewProvider { mDesiredHeightResId = entry.getBubbleMetadata().getDesiredHeightResId(); mIcon = entry.getBubbleMetadata().getIcon(); if (!mIntentActive || mIntent == null) { if (mIntent != null) { mIntent.unregisterCancelListener(mIntentCancelListener); if (!mPendingIntentActive || mPendingIntent == null) { if (mPendingIntent != null) { mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener); } mIntent = entry.getBubbleMetadata().getIntent(); if (mIntent != null) { mIntent.registerCancelListener(mIntentCancelListener); mPendingIntent = entry.getBubbleMetadata().getIntent(); if (mPendingIntent != null) { mPendingIntent.registerCancelListener(mPendingIntentCancelListener); } } else if (mIntent != null && entry.getBubbleMetadata().getIntent() == null) { } else if (mPendingIntent != null && entry.getBubbleMetadata().getIntent() == null) { // Was an intent bubble now it's a shortcut bubble... still unregister the listener mIntent.unregisterCancelListener(mIntentCancelListener); mIntentActive = false; mIntent = null; mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener); mPendingIntentActive = false; mPendingIntent = null; } mDeleteIntent = entry.getBubbleMetadata().getDeleteIntent(); } Loading Loading @@ -926,12 +924,15 @@ public class Bubble implements BubbleViewProvider { * Sets if the intent used for this bubble is currently active (i.e. populating an * expanded view, expanded or not). */ void setIntentActive() { mIntentActive = true; void setPendingIntentActive() { mPendingIntentActive = true; } boolean isIntentActive() { return mIntentActive; /** * Whether the pending intent of this bubble is active (i.e. has been sent). */ boolean isPendingIntentActive() { return mPendingIntentActive; } public InstanceId getInstanceId() { Loading Loading @@ -1118,9 +1119,12 @@ public class Bubble implements BubbleViewProvider { } } /** * Returns the pending intent used to populate the bubble. */ @Nullable PendingIntent getBubbleIntent() { return mIntent; PendingIntent getPendingIntent() { return mPendingIntent; } /** Loading @@ -1128,31 +1132,33 @@ public class Bubble implements BubbleViewProvider { * intent for an app. In this case we don't show a badge on the icon. */ public boolean isAppLaunchIntent() { if (BubbleAnythingFlagHelper.enableCreateAnyBubble() && mAppIntent != null) { return mAppIntent.hasCategory("android.intent.category.LAUNCHER"); if (BubbleAnythingFlagHelper.enableCreateAnyBubble() && mIntent != null) { return mIntent.hasCategory("android.intent.category.LAUNCHER"); } return false; } /** * Returns the pending intent to send when a bubble is dismissed (set via the notification API). */ @Nullable PendingIntent getDeleteIntent() { return mDeleteIntent; } /** * Returns the intent used to populate the bubble. */ @Nullable @VisibleForTesting public Intent getAppBubbleIntent() { return mAppIntent; public Intent getIntent() { return mIntent; } /** * Sets the intent for a bubble that is an app bubble (one for which {@link #mIsAppBubble} is * true). * * @param appIntent The intent to set for the app bubble. * Sets the intent used to populate the bubble. */ void setAppBubbleIntent(Intent appIntent) { mAppIntent = appIntent; void setIntent(Intent intent) { mIntent = intent; } /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +4 −3 Original line number Diff line number Diff line Loading @@ -419,10 +419,11 @@ public class BubbleController implements ConfigurationChangeListener, mBubbleData.setSuppressionChangedListener(this::onBubbleMetadataFlagChanged); mDataRepository.setSuppressionChangedListener(this::onBubbleMetadataFlagChanged); mBubbleData.setPendingIntentCancelledListener(bubble -> { if (bubble.getBubbleIntent() == null) { if (bubble.getPendingIntent() == null) { return; } if (bubble.isIntentActive() || mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) { if (bubble.isPendingIntentActive() || mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) { bubble.setPendingIntentCanceled(); return; } Loading Loading @@ -1663,7 +1664,7 @@ public class BubbleController implements ConfigurationChangeListener, // It's in the overflow, so remove it & reinflate mBubbleData.dismissBubbleWithKey(noteBubbleKey, Bubbles.DISMISS_NOTIF_CANCEL); // Update the bubble entry in the overflow with the latest intent. b.setAppBubbleIntent(intent); b.setIntent(intent); } else { // Notes bubble does not exist, lets add and expand it b = Bubble.createNotesBubble(intent, user, icon, mMainExecutor, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +4 −5 Original line number Diff line number Diff line Loading @@ -237,8 +237,7 @@ public class BubbleExpandedView extends LinearLayout { PendingIntent pi = PendingIntent.getActivity( context, /* requestCode= */ 0, mBubble.getAppBubbleIntent() .addFlags(FLAG_ACTIVITY_MULTIPLE_TASK), mBubble.getIntent().addFlags(FLAG_ACTIVITY_MULTIPLE_TASK), PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT, /* options= */ null); mTaskView.startActivity(pi, /* fillInIntent= */ null, options, Loading @@ -252,7 +251,7 @@ public class BubbleExpandedView extends LinearLayout { } else { options.setLaunchedFromBubble(true); if (mBubble != null) { mBubble.setIntentActive(); mBubble.setPendingIntentActive(); } final Intent fillInIntent = new Intent(); // Apply flags to make behaviour match documentLaunchMode=always. Loading Loading @@ -920,7 +919,7 @@ public class BubbleExpandedView extends LinearLayout { }); if (isNew) { mPendingIntent = mBubble.getBubbleIntent(); mPendingIntent = mBubble.getPendingIntent(); if ((mPendingIntent != null || mBubble.hasMetadataShortcutId()) && mTaskView != null) { setContentVisibility(false); Loading @@ -947,7 +946,7 @@ public class BubbleExpandedView extends LinearLayout { */ private boolean didBackingContentChange(Bubble newBubble) { boolean prevWasIntentBased = mBubble != null && mPendingIntent != null; boolean newIsIntentBased = newBubble.getBubbleIntent() != null; boolean newIsIntentBased = newBubble.getPendingIntent() != null; return prevWasIntentBased != newIsIntentBased; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -119,7 +119,7 @@ public class BubbleTaskViewHelper { PendingIntent pi = PendingIntent.getActivity( context, /* requestCode= */ 0, mBubble.getAppBubbleIntent() mBubble.getIntent() .addFlags(FLAG_ACTIVITY_MULTIPLE_TASK), PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT, /* options= */ null); Loading @@ -133,7 +133,7 @@ public class BubbleTaskViewHelper { } else { options.setLaunchedFromBubble(true); if (mBubble != null) { mBubble.setIntentActive(); mBubble.setPendingIntentActive(); } final Intent fillInIntent = new Intent(); // Apply flags to make behaviour match documentLaunchMode=always. Loading Loading @@ -231,7 +231,7 @@ public class BubbleTaskViewHelper { boolean isNew = mBubble == null || didBackingContentChange(bubble); mBubble = bubble; if (isNew) { mPendingIntent = mBubble.getBubbleIntent(); mPendingIntent = mBubble.getPendingIntent(); return true; } return false; Loading Loading @@ -276,7 +276,7 @@ public class BubbleTaskViewHelper { */ private boolean didBackingContentChange(Bubble newBubble) { boolean prevWasIntentBased = mBubble != null && mPendingIntent != null; boolean newIsIntentBased = newBubble.getBubbleIntent() != null; boolean newIsIntentBased = newBubble.getPendingIntent() != null; return prevWasIntentBased != newIsIntentBased; } }
packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -2110,7 +2110,7 @@ public class BubblesTest extends SysuiTestCase { assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(noteBubbleKey); assertThat(mBubbleController.isStackExpanded()).isTrue(); assertThat(mBubbleData.getBubbles().size()).isEqualTo(1); assertThat(mBubbleData.getBubbles().get(0).getAppBubbleIntent() assertThat(mBubbleData.getBubbles().get(0).getIntent() .getStringExtra("hello")).isEqualTo("world"); assertThat(mBubbleData.getOverflowBubbleWithKey(noteBubbleKey)).isNull(); } Loading