From: Selim Cinek Date: Wed, 24 May 2017 18:08:55 +0000 (-0700) Subject: Fixed an issue where groups could stay userlocked X-Git-Tag: android-x86-9.0-r1~1044^2~508^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=91f41cea2e34f1a363e460627c82918da4826d5e;p=android-x86%2Fframeworks-base.git Fixed an issue where groups could stay userlocked It also fixes an issue where the reinflation wasn't working properly. Test: runtest -x packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java Merged-In: If359256a3ac0c574260b5ff5af3fc2042e1dce9a Change-Id: If359256a3ac0c574260b5ff5af3fc2042e1dce9a Fixes: 36469584 --- diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index 3a39e9111be4..35425004c27b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -813,10 +813,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public void 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; @@ -1458,9 +1458,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(); } } @@ -2189,4 +2191,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 cb1f44ededa7..d3bb529312fc 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,7 @@ 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; @@ -1223,4 +1224,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 5cd092bc8b53..fd0cbd15a38f 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; @@ -25,6 +27,8 @@ import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.view.View; +import com.android.systemui.statusbar.stack.NotificationChildrenContainer; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -62,4 +66,25 @@ public class ExpandableNotificationRowTest { == 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()); + } + + }