Merge "Prevent NPE when dragging last bubble from expanded state" into rvc-dev am: d4952538cc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11832765

Change-Id: I55c4bc750a36cffba236e23d2a53e221a259878a
This commit is contained in:
Mady Mellor
2020-06-11 18:42:51 +00:00
committed by Automerger Merge Worker
4 changed files with 17 additions and 12 deletions

View File

@@ -714,6 +714,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
* the new params if the stack has been added. * the new params if the stack has been added.
*/ */
private void updateWmFlags() { private void updateWmFlags() {
if (mStackView == null) {
return;
}
if (isStackExpanded() && !mImeVisible) { if (isStackExpanded() && !mImeVisible) {
// If we're expanded, and the IME isn't visible, we want to be focusable. This ensures // If we're expanded, and the IME isn't visible, we want to be focusable. This ensures
// that any taps within Bubbles (including on the ActivityView) results in Bubbles // that any taps within Bubbles (including on the ActivityView) results in Bubbles
@@ -725,7 +728,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
mWmLayoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; mWmLayoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
} }
if (mStackView != null && mAddedToWindowManager) { if (mAddedToWindowManager) {
try { try {
mWindowManager.updateViewLayout(mStackView, mWmLayoutParams); mWindowManager.updateViewLayout(mStackView, mWmLayoutParams);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@@ -1245,24 +1248,23 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
} }
mDataRepository.removeBubbles(mCurrentUserId, bubblesToBeRemovedFromRepository); mDataRepository.removeBubbles(mCurrentUserId, bubblesToBeRemovedFromRepository);
if (update.addedBubble != null) { if (update.addedBubble != null && mStackView != null) {
mDataRepository.addBubble(mCurrentUserId, update.addedBubble); mDataRepository.addBubble(mCurrentUserId, update.addedBubble);
mStackView.addBubble(update.addedBubble); mStackView.addBubble(update.addedBubble);
} }
if (update.updatedBubble != null) { if (update.updatedBubble != null && mStackView != null) {
mStackView.updateBubble(update.updatedBubble); mStackView.updateBubble(update.updatedBubble);
} }
// At this point, the correct bubbles are inflated in the stack. // At this point, the correct bubbles are inflated in the stack.
// Make sure the order in bubble data is reflected in bubble row. // Make sure the order in bubble data is reflected in bubble row.
if (update.orderChanged) { if (update.orderChanged && mStackView != null) {
mDataRepository.addBubbles(mCurrentUserId, update.bubbles); mDataRepository.addBubbles(mCurrentUserId, update.bubbles);
mStackView.updateBubbleOrder(update.bubbles); mStackView.updateBubbleOrder(update.bubbles);
} }
if (update.selectionChanged) { if (update.selectionChanged && mStackView != null) {
mStackView.setSelectedBubble(update.selectedBubble); mStackView.setSelectedBubble(update.selectedBubble);
if (update.selectedBubble != null && update.selectedBubble.getEntry() != null) { if (update.selectedBubble != null && update.selectedBubble.getEntry() != null) {
mNotificationGroupManager.updateSuppression( mNotificationGroupManager.updateSuppression(
@@ -1272,8 +1274,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
// Expanding? Apply this last. // Expanding? Apply this last.
if (update.expandedChanged && update.expanded) { if (update.expandedChanged && update.expanded) {
if (mStackView != null) {
mStackView.setExpanded(true); mStackView.setExpanded(true);
} }
}
for (NotifCallback cb : mCallbacks) { for (NotifCallback cb : mCallbacks) {
cb.invalidateNotifications("BubbleData.Listener.applyUpdate"); cb.invalidateNotifications("BubbleData.Listener.applyUpdate");
@@ -1378,7 +1382,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
} }
/** /**
* Lets any listeners know if bubble state has changed.
* Updates the visibility of the bubbles based on current state. * Updates the visibility of the bubbles based on current state.
* Does not un-bubble, just hides or un-hides. * Does not un-bubble, just hides or un-hides.
* Updates stack description for TalkBack focus. * Updates stack description for TalkBack focus.

View File

@@ -417,7 +417,8 @@ public class BubbleData {
if (mBubbles.size() == 1) { if (mBubbles.size() == 1) {
// Going to become empty, handle specially. // Going to become empty, handle specially.
setExpandedInternal(false); setExpandedInternal(false);
setSelectedBubbleInternal(null); // Don't use setSelectedBubbleInternal because we don't want to trigger an applyUpdate
mSelectedBubble = null;
} }
if (indexToRemove < mBubbles.size() - 1) { if (indexToRemove < mBubbles.size() - 1) {
// Removing anything but the last bubble means positions will change. // Removing anything but the last bubble means positions will change.

View File

@@ -93,7 +93,6 @@ import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.SysUiStatsLog; import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment; import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment;
import com.android.systemui.statusbar.phone.NotificationShadeWindowController;
import com.android.systemui.util.DismissCircleView; import com.android.systemui.util.DismissCircleView;
import com.android.systemui.util.FloatingContentCoordinator; import com.android.systemui.util.FloatingContentCoordinator;
import com.android.systemui.util.RelativeTouchListener; import com.android.systemui.util.RelativeTouchListener;
@@ -1515,7 +1514,9 @@ public class BubbleStackView extends FrameLayout
// expanded view becomes visible on the screen. See b/126856255 // expanded view becomes visible on the screen. See b/126856255
mExpandedViewContainer.setAlpha(0.0f); mExpandedViewContainer.setAlpha(0.0f);
mSurfaceSynchronizer.syncSurfaceAndRun(() -> { mSurfaceSynchronizer.syncSurfaceAndRun(() -> {
if (previouslySelected != null) {
previouslySelected.setContentVisibility(false); previouslySelected.setContentVisibility(false);
}
updateExpandedBubble(); updateExpandedBubble();
requestUpdate(); requestUpdate();

View File

@@ -537,7 +537,7 @@ public class BubbleDataTest extends SysuiTestCase {
// Verify the selection was cleared. // Verify the selection was cleared.
verifyUpdateReceived(); verifyUpdateReceived();
assertThat(mBubbleData.isExpanded()).isFalse(); assertThat(mBubbleData.isExpanded()).isFalse();
assertSelectionCleared(); assertThat(mBubbleData.getSelectedBubble()).isNull();
} }
// EXPANDED / ADD / UPDATE // EXPANDED / ADD / UPDATE