Remove setalpha(0f) from reset.

Reset has too many callers for different reasons. It is extremely frail
and is causing the user switcher to disappear for various reasons.
Largely the user switcher disappears when switching users in the bouncer
and persisting the bouncer.

Fixes: 290355544
Test: Get multiple users and switch users with bouncer user switcher on.
Test: close and open bouncer scrimmed to see that the userswitcher does
not flicker.

Change-Id: I313240f1c594d5df6071b0dc6a7099496990e274
This commit is contained in:
Aaron Liu
2023-08-07 09:36:40 -07:00
parent e8610d7369
commit 05445443cf
3 changed files with 22 additions and 0 deletions

View File

@@ -676,6 +676,14 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
mSecurityViewFlipperController.reset();
}
/** Prepares views in the bouncer before starting appear animation. */
public void prepareToShow() {
View bouncerUserSwitcher = mView.findViewById(R.id.keyguard_bouncer_user_switcher);
if (bouncerUserSwitcher != null) {
bouncerUserSwitcher.setAlpha(0f);
}
}
@Override
public void onResume(int reason) {
if (DEBUG) Log.d(TAG, "screen on, instance " + Integer.toHexString(hashCode()));

View File

@@ -120,6 +120,8 @@ object KeyguardBouncerViewBinder {
viewModel.isShowing.collect { isShowing ->
view.visibility = if (isShowing) View.VISIBLE else View.INVISIBLE
if (isShowing) {
// Reset security container because these views are not reinflated.
securityContainerController.prepareToShow()
securityContainerController.reinflateViewFlipper {
// Reset Security Container entirely.
securityContainerController.onBouncerVisibilityChanged(

View File

@@ -27,6 +27,7 @@ import android.testing.TestableResources
import android.view.Gravity
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.WindowInsetsController
import android.widget.FrameLayout
import androidx.test.filters.SmallTest
@@ -80,6 +81,7 @@ import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mockito.atLeastOnce
import org.mockito.Mockito.clearInvocations
import org.mockito.Mockito.mock
import org.mockito.Mockito.never
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
@@ -772,6 +774,16 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
verify(viewMediatorCallback).keyguardDone(anyBoolean(), anyInt())
}
@Test
fun testResetUserSwitcher() {
val userSwitcher = mock(View::class.java)
whenever(view.findViewById<View>(R.id.keyguard_bouncer_user_switcher))
.thenReturn(userSwitcher)
underTest.prepareToShow()
verify(userSwitcher).setAlpha(0f)
}
private val registeredSwipeListener: KeyguardSecurityContainer.SwipeListener
get() {
underTest.onViewAttached()