diff options
2 files changed, 41 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfo.java index 18c755da53ff..6045524f30b6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfo.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfo.java @@ -29,6 +29,7 @@ import static com.android.systemui.statusbar.notification.row.NotificationConver import static com.android.systemui.statusbar.notification.row.NotificationConversationInfo.UpdateChannelRunnable.ACTION_HOME; import static com.android.systemui.statusbar.notification.row.NotificationConversationInfo.UpdateChannelRunnable.ACTION_MUTE; import static com.android.systemui.statusbar.notification.row.NotificationConversationInfo.UpdateChannelRunnable.ACTION_SNOOZE; +import static com.android.systemui.statusbar.notification.row.NotificationConversationInfo.UpdateChannelRunnable.ACTION_UNBUBBLE; import static java.lang.annotation.RetentionPolicy.SOURCE; @@ -121,7 +122,7 @@ public class NotificationConversationInfo extends LinearLayout implements boolean mSkipPost = false; private OnClickListener mOnBubbleClick = v -> { - mSelectedAction = ACTION_BUBBLE; + mSelectedAction = mStartedAsBubble ? ACTION_UNBUBBLE : ACTION_BUBBLE; if (mStartedAsBubble) { mBubbleController.onUserDemotedBubbleFromNotification(mEntry); } else { @@ -586,6 +587,7 @@ public class NotificationConversationInfo extends LinearLayout implements static final int ACTION_SNOOZE = 3; static final int ACTION_MUTE = 4; static final int ACTION_DEMOTE = 5; + static final int ACTION_UNBUBBLE = 6; private final INotificationManager mINotificationManager; private final String mAppPkg; @@ -606,9 +608,17 @@ public class NotificationConversationInfo extends LinearLayout implements @Override public void run() { try { + boolean channelSettingChanged = mAction != ACTION_HOME && mAction != ACTION_SNOOZE; switch (mAction) { case ACTION_BUBBLE: - mChannelToUpdate.setAllowBubbles(!mChannelToUpdate.canBubble()); + case ACTION_UNBUBBLE: + boolean canBubble = mAction == ACTION_BUBBLE; + if (mChannelToUpdate.canBubble() != canBubble) { + channelSettingChanged = true; + mChannelToUpdate.setAllowBubbles(canBubble); + } else { + channelSettingChanged = false; + } break; case ACTION_FAVORITE: // TODO: extend beyond DND @@ -629,7 +639,7 @@ public class NotificationConversationInfo extends LinearLayout implements } - if (mAction != ACTION_HOME && mAction != ACTION_SNOOZE) { + if (channelSettingChanged) { mINotificationManager.updateNotificationChannelForPackage( mAppPkg, mAppUid, mChannelToUpdate); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java index 5fc40ccb6c8a..20a089f97f51 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationConversationInfoTest.java @@ -58,7 +58,6 @@ import android.service.notification.StatusBarNotification; import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; -import android.util.Slog; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; @@ -601,6 +600,34 @@ public class NotificationConversationInfoTest extends SysuiTestCase { } @Test + public void testBubble_noChannelChange() throws Exception { + mNotificationInfo.bindNotification( + mShortcutManager, + mLauncherApps, + mMockPackageManager, + mMockINotificationManager, + mVisualStabilityManager, + TEST_PACKAGE_NAME, + mNotificationChannel, + mBubbleEntry, + null, + null, + null, + true); + + assertFalse(mBubbleEntry.isBubble()); + assertTrue(mNotificationChannel.canBubble()); + + // Promote it + mNotificationInfo.findViewById(R.id.bubble).performClick(); + mTestableLooper.processAllMessages(); + + verify(mBubbleController, times(1)).onUserCreatedBubbleFromNotification(mBubbleEntry); + verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( + anyString(), anyInt(), any()); + } + + @Test public void testFavorite_favorite() throws Exception { mNotificationInfo.bindNotification( mShortcutManager, |