diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index 2cb6c08771e15..a1160de4e042b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -827,10 +827,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public void onDensityOrFontScaleChanged() { super.onDensityOrFontScaleChanged(); initDimens(); - if (mIsSummaryWithChildren) { - if (mChildrenContainer != null) { - mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.notification); - } + // Let's update our childrencontainer. This is intentionally not guarded with + // mIsSummaryWithChildren since we might have had children but not anymore. + if (mChildrenContainer != null) { + mChildrenContainer.reInflateViews(mExpandClickListener, mEntry.notification); } if (mGuts != null) { View oldGuts = mGuts; @@ -1496,9 +1496,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public void setUserLocked(boolean userLocked) { mUserLocked = userLocked; mPrivateLayout.setUserExpanding(userLocked); - if (mIsSummaryWithChildren) { + // This is intentionally not guarded with mIsSummaryWithChildren since we might have had + // children but not anymore. + if (mChildrenContainer != null) { mChildrenContainer.setUserLocked(userLocked); - if (userLocked || !isGroupExpanded()) { + if (mIsSummaryWithChildren && (userLocked || !isGroupExpanded())) { updateBackgroundForGroupState(); } } @@ -2228,4 +2230,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } } } + + @VisibleForTesting + protected void setChildrenContainer(NotificationChildrenContainer childrenContainer) { + mChildrenContainer = childrenContainer; + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java index 5069b913950d9..208156160b862 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java @@ -29,6 +29,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.RemoteViews; import android.widget.TextView; + +import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.R; import com.android.systemui.statusbar.CrossFadeHelper; import com.android.systemui.statusbar.ExpandableNotificationRow; @@ -1243,4 +1245,9 @@ public class NotificationChildrenContainer extends ViewGroup { } return getGroupExpandFraction(); } + + @VisibleForTesting + public boolean isUserLocked() { + return mUserLocked; + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java index 183d8d9963c75..628630182ad16 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java @@ -16,7 +16,9 @@ package com.android.systemui.statusbar; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import android.content.Context; import android.support.test.InstrumentationRegistry; @@ -26,6 +28,7 @@ import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.view.View; +import com.android.systemui.statusbar.stack.NotificationChildrenContainer; import com.android.systemui.SysuiTestCase; import org.junit.Assert; @@ -65,4 +68,25 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { == View.VISIBLE); } + @Test + public void testUserLockedResetEvenWhenNoChildren() { + mGroup.setUserLocked(true); + mGroup.removeAllChildren(); + mGroup.setUserLocked(false); + Assert.assertFalse("The childrencontainer should not be userlocked but is, the state " + + "seems out of sync.", mGroup.getChildrenContainer().isUserLocked()); + } + + @Test + public void testReinflatedOnDensityChange() { + mGroup.setUserLocked(true); + mGroup.removeAllChildren(); + mGroup.setUserLocked(false); + NotificationChildrenContainer mockContainer = mock(NotificationChildrenContainer.class); + mGroup.setChildrenContainer(mockContainer); + mGroup.onDensityOrFontScaleChanged(); + verify(mockContainer).reInflateViews(any(), any()); + } + + }