Allow system info to be set visible even if we don't animate
CollapsedStatusBarFragment uses disable flags to show and hide the system info in two cases: when showing the keyguard and when showing quick settings. This animation causes the alpha to animate to zero AND the visibility to be View.INVISIBLE. This means that the system event animation only has the context to set the alpha of the system status area -- _not_ the visibility. In the case where the disable flags change while a system status event animation is in progress, CollapsedStatusBarFragment would bail on the _entire_ animation, including the change from View.INVISIBLE to View.VISIBLE, which is crucial for unhiding the view eventually. This change simply allows CollapsedStatusBarFragment to set the system info area back to View.VISIBLE even if it doens't control the overall animation. Test: atest CollapsedStatusBarFragmentTest Fixes: 238968127 Change-Id: I7ad8c4a4df8ff335ea9b3de428521b24e59002ee
This commit is contained in:
@@ -509,6 +509,10 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
|
|||||||
int state = mAnimationScheduler.getAnimationState();
|
int state = mAnimationScheduler.getAnimationState();
|
||||||
if (state == IDLE || state == SHOWING_PERSISTENT_DOT) {
|
if (state == IDLE || state == SHOWING_PERSISTENT_DOT) {
|
||||||
animateShow(mEndSideContent, animate);
|
animateShow(mEndSideContent, animate);
|
||||||
|
} else {
|
||||||
|
// We are in the middle of a system status event animation, which will animate the
|
||||||
|
// alpha (but not the visibility). Allow the view to become visible again
|
||||||
|
mEndSideContent.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ package com.android.systemui.statusbar.phone.fragment;
|
|||||||
|
|
||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
|
|
||||||
|
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.ANIMATING_IN;
|
||||||
|
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.ANIMATING_OUT;
|
||||||
|
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.IDLE;
|
||||||
|
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.RUNNING_CHIP_ANIM;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -25,6 +30,7 @@ import static org.mockito.Mockito.atLeast;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.StatusBarManager;
|
import android.app.StatusBarManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -132,7 +138,8 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDisableSystemInfo() {
|
public void testDisableSystemInfo_systemAnimationIdle_doesHide() {
|
||||||
|
when(mAnimationScheduler.getAnimationState()).thenReturn(IDLE);
|
||||||
CollapsedStatusBarFragment fragment = resumeAndGetFragment();
|
CollapsedStatusBarFragment fragment = resumeAndGetFragment();
|
||||||
|
|
||||||
fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_SYSTEM_INFO, 0, false);
|
fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_SYSTEM_INFO, 0, false);
|
||||||
@@ -144,6 +151,98 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
|
|||||||
assertEquals(View.VISIBLE, getEndSideContentView().getVisibility());
|
assertEquals(View.VISIBLE, getEndSideContentView().getVisibility());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSystemStatusAnimation_startedDisabled_finishedWithAnimator_showsSystemInfo() {
|
||||||
|
// GIVEN the status bar hides the system info via disable flags, while there is no event
|
||||||
|
CollapsedStatusBarFragment fragment = resumeAndGetFragment();
|
||||||
|
when(mAnimationScheduler.getAnimationState()).thenReturn(IDLE);
|
||||||
|
fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_SYSTEM_INFO, 0, false);
|
||||||
|
assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility());
|
||||||
|
|
||||||
|
// WHEN the disable flags are cleared during a system event animation
|
||||||
|
when(mAnimationScheduler.getAnimationState()).thenReturn(RUNNING_CHIP_ANIM);
|
||||||
|
fragment.disable(DEFAULT_DISPLAY, 0, 0, false);
|
||||||
|
|
||||||
|
// THEN the view is made visible again, but still low alpha
|
||||||
|
assertEquals(View.VISIBLE, getEndSideContentView().getVisibility());
|
||||||
|
assertEquals(0, getEndSideContentView().getAlpha(), 0.01);
|
||||||
|
|
||||||
|
// WHEN the system event animation finishes
|
||||||
|
when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_OUT);
|
||||||
|
Animator anim = fragment.onSystemEventAnimationFinish(false);
|
||||||
|
anim.start();
|
||||||
|
processAllMessages();
|
||||||
|
anim.end();
|
||||||
|
|
||||||
|
// THEN the system info is full alpha
|
||||||
|
assertEquals(1, getEndSideContentView().getAlpha(), 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSystemStatusAnimation_systemInfoDisabled_staysInvisible() {
|
||||||
|
// GIVEN the status bar hides the system info via disable flags, while there is no event
|
||||||
|
CollapsedStatusBarFragment fragment = resumeAndGetFragment();
|
||||||
|
when(mAnimationScheduler.getAnimationState()).thenReturn(IDLE);
|
||||||
|
fragment.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_SYSTEM_INFO, 0, false);
|
||||||
|
assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility());
|
||||||
|
|
||||||
|
// WHEN the system event animation finishes
|
||||||
|
when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_OUT);
|
||||||
|
Animator anim = fragment.onSystemEventAnimationFinish(false);
|
||||||
|
anim.start();
|
||||||
|
processAllMessages();
|
||||||
|
anim.end();
|
||||||
|
|
||||||
|
// THEN the system info is at full alpha, but still INVISIBLE (since the disable flag is
|
||||||
|
// still set)
|
||||||
|
assertEquals(1, getEndSideContentView().getAlpha(), 0.01);
|
||||||
|
assertEquals(View.INVISIBLE, getEndSideContentView().getVisibility());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSystemStatusAnimation_notDisabled_animatesAlphaZero() {
|
||||||
|
// GIVEN the status bar is not disabled
|
||||||
|
CollapsedStatusBarFragment fragment = resumeAndGetFragment();
|
||||||
|
when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_IN);
|
||||||
|
// WHEN the system event animation begins
|
||||||
|
Animator anim = fragment.onSystemEventAnimationBegin();
|
||||||
|
anim.start();
|
||||||
|
processAllMessages();
|
||||||
|
anim.end();
|
||||||
|
|
||||||
|
// THEN the system info is visible but alpha 0
|
||||||
|
assertEquals(View.VISIBLE, getEndSideContentView().getVisibility());
|
||||||
|
assertEquals(0, getEndSideContentView().getAlpha(), 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSystemStatusAnimation_notDisabled_animatesBackToAlphaOne() {
|
||||||
|
// GIVEN the status bar is not disabled
|
||||||
|
CollapsedStatusBarFragment fragment = resumeAndGetFragment();
|
||||||
|
when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_IN);
|
||||||
|
// WHEN the system event animation begins
|
||||||
|
Animator anim = fragment.onSystemEventAnimationBegin();
|
||||||
|
anim.start();
|
||||||
|
processAllMessages();
|
||||||
|
anim.end();
|
||||||
|
|
||||||
|
// THEN the system info is visible but alpha 0
|
||||||
|
assertEquals(View.VISIBLE, getEndSideContentView().getVisibility());
|
||||||
|
assertEquals(0, getEndSideContentView().getAlpha(), 0.01);
|
||||||
|
|
||||||
|
// WHEN the system event animation finishes
|
||||||
|
when(mAnimationScheduler.getAnimationState()).thenReturn(ANIMATING_OUT);
|
||||||
|
anim = fragment.onSystemEventAnimationFinish(false);
|
||||||
|
anim.start();
|
||||||
|
processAllMessages();
|
||||||
|
anim.end();
|
||||||
|
|
||||||
|
// THEN the syste info is full alpha and VISIBLE
|
||||||
|
assertEquals(View.VISIBLE, getEndSideContentView().getVisibility());
|
||||||
|
assertEquals(1, getEndSideContentView().getAlpha(), 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDisableNotifications() {
|
public void testDisableNotifications() {
|
||||||
CollapsedStatusBarFragment fragment = resumeAndGetFragment();
|
CollapsedStatusBarFragment fragment = resumeAndGetFragment();
|
||||||
|
|||||||
Reference in New Issue
Block a user