Loading packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +73 −10 Original line number Diff line number Diff line Loading @@ -25,12 +25,16 @@ import static com.android.systemui.DejankUtils.whitelistIpcs; import static java.lang.Integer.max; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.app.Activity; import android.app.AlertDialog; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Insets; import android.graphics.Rect; import android.metrics.LogMaker; import android.os.Handler; Loading @@ -48,9 +52,13 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.WindowInsets; import android.view.WindowInsetsAnimation; import android.view.WindowInsetsAnimationControlListener; import android.view.WindowInsetsAnimationController; import android.view.WindowManager; import android.widget.FrameLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.dynamicanimation.animation.DynamicAnimation; import androidx.dynamicanimation.animation.SpringAnimation; Loading @@ -64,6 +72,7 @@ import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardSecurityModel.SecurityMode; import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.SystemUIFactory; import com.android.systemui.shared.system.SysUiStatsLog; Loading Loading @@ -100,6 +109,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe private static final UiEventLogger sUiEventLogger = new UiEventLoggerImpl(); private static final long IME_DISAPPEAR_DURATION_MS = 125; private KeyguardSecurityModel mSecurityModel; private LockPatternUtils mLockPatternUtils; Loading @@ -125,6 +136,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe private int mActivePointerId = -1; private boolean mIsDragging; private float mStartTouchY = -1; private boolean mDisappearAnimRunning; private final WindowInsetsAnimation.Callback mWindowInsetsAnimationCallback = new WindowInsetsAnimation.Callback(DISPATCH_MODE_STOP) { Loading @@ -148,6 +160,10 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe public WindowInsets onProgress(WindowInsets windowInsets, List<WindowInsetsAnimation> list) { int translationY = 0; if (mDisappearAnimRunning) { mSecurityViewFlipper.setTranslationY( mInitialBounds.bottom - mFinalBounds.bottom); } else { for (WindowInsetsAnimation animation : list) { if ((animation.getTypeMask() & WindowInsets.Type.ime()) == 0) { continue; Loading @@ -158,13 +174,16 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe translationY += paddingBottom; } mSecurityViewFlipper.setTranslationY(translationY); } return windowInsets; } @Override public void onEnd(WindowInsetsAnimation animation) { if (!mDisappearAnimRunning) { mSecurityViewFlipper.setTranslationY(0); } } }; // Used to notify the container when something interesting happens. Loading Loading @@ -376,8 +395,51 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe } public boolean startDisappearAnimation(Runnable onFinishRunnable) { mDisappearAnimRunning = true; if (mCurrentSecuritySelection == SecurityMode.Password) { mSecurityViewFlipper.getWindowInsetsController().hide(WindowInsets.Type.ime()); mSecurityViewFlipper.getWindowInsetsController().controlWindowInsetsAnimation(ime(), IME_DISAPPEAR_DURATION_MS, Interpolators.LINEAR, null, new WindowInsetsAnimationControlListener() { @Override public void onReady(@NonNull WindowInsetsAnimationController controller, int types) { ValueAnimator anim = ValueAnimator.ofFloat(1f, 0f); anim.addUpdateListener(animation -> { if (controller.isCancelled()) { return; } Insets shownInsets = controller.getShownStateInsets(); Insets insets = Insets.add(shownInsets, Insets.of(0, 0, 0, (int) (-shownInsets.bottom / 4 * anim.getAnimatedFraction()))); controller.setInsetsAndAlpha(insets, (float) animation.getAnimatedValue(), anim.getAnimatedFraction()); }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { controller.finish(false); } }); anim.setDuration(IME_DISAPPEAR_DURATION_MS); anim.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN); anim.start(); } @Override public void onFinished( @NonNull WindowInsetsAnimationController controller) { mDisappearAnimRunning = false; } @Override public void onCancelled( @Nullable WindowInsetsAnimationController controller) { } }); } if (mCurrentSecuritySelection != SecurityMode.None) { return getSecurityView(mCurrentSecuritySelection).startDisappearAnimation( Loading Loading @@ -887,6 +949,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe @Override public void reset() { mSecurityViewFlipper.reset(); mDisappearAnimRunning = false; } @Override Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ package com.android.keyguard; import static android.view.WindowInsets.Type.ime; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -110,6 +112,7 @@ public class KeyguardSecurityContainerTest extends SysuiTestCase { mKeyguardSecurityContainer.startDisappearAnimation(null); verify(mSecurityView).startDisappearAnimation(eq(null)); verify(mWindowInsetsController).hide(eq(ime())); verify(mWindowInsetsController).controlWindowInsetsAnimation(eq(ime()), anyLong(), any(), any(), any()); } } No newline at end of file Loading
packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +73 −10 Original line number Diff line number Diff line Loading @@ -25,12 +25,16 @@ import static com.android.systemui.DejankUtils.whitelistIpcs; import static java.lang.Integer.max; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.app.Activity; import android.app.AlertDialog; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Insets; import android.graphics.Rect; import android.metrics.LogMaker; import android.os.Handler; Loading @@ -48,9 +52,13 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.WindowInsets; import android.view.WindowInsetsAnimation; import android.view.WindowInsetsAnimationControlListener; import android.view.WindowInsetsAnimationController; import android.view.WindowManager; import android.widget.FrameLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.dynamicanimation.animation.DynamicAnimation; import androidx.dynamicanimation.animation.SpringAnimation; Loading @@ -64,6 +72,7 @@ import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardSecurityModel.SecurityMode; import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.SystemUIFactory; import com.android.systemui.shared.system.SysUiStatsLog; Loading Loading @@ -100,6 +109,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe private static final UiEventLogger sUiEventLogger = new UiEventLoggerImpl(); private static final long IME_DISAPPEAR_DURATION_MS = 125; private KeyguardSecurityModel mSecurityModel; private LockPatternUtils mLockPatternUtils; Loading @@ -125,6 +136,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe private int mActivePointerId = -1; private boolean mIsDragging; private float mStartTouchY = -1; private boolean mDisappearAnimRunning; private final WindowInsetsAnimation.Callback mWindowInsetsAnimationCallback = new WindowInsetsAnimation.Callback(DISPATCH_MODE_STOP) { Loading @@ -148,6 +160,10 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe public WindowInsets onProgress(WindowInsets windowInsets, List<WindowInsetsAnimation> list) { int translationY = 0; if (mDisappearAnimRunning) { mSecurityViewFlipper.setTranslationY( mInitialBounds.bottom - mFinalBounds.bottom); } else { for (WindowInsetsAnimation animation : list) { if ((animation.getTypeMask() & WindowInsets.Type.ime()) == 0) { continue; Loading @@ -158,13 +174,16 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe translationY += paddingBottom; } mSecurityViewFlipper.setTranslationY(translationY); } return windowInsets; } @Override public void onEnd(WindowInsetsAnimation animation) { if (!mDisappearAnimRunning) { mSecurityViewFlipper.setTranslationY(0); } } }; // Used to notify the container when something interesting happens. Loading Loading @@ -376,8 +395,51 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe } public boolean startDisappearAnimation(Runnable onFinishRunnable) { mDisappearAnimRunning = true; if (mCurrentSecuritySelection == SecurityMode.Password) { mSecurityViewFlipper.getWindowInsetsController().hide(WindowInsets.Type.ime()); mSecurityViewFlipper.getWindowInsetsController().controlWindowInsetsAnimation(ime(), IME_DISAPPEAR_DURATION_MS, Interpolators.LINEAR, null, new WindowInsetsAnimationControlListener() { @Override public void onReady(@NonNull WindowInsetsAnimationController controller, int types) { ValueAnimator anim = ValueAnimator.ofFloat(1f, 0f); anim.addUpdateListener(animation -> { if (controller.isCancelled()) { return; } Insets shownInsets = controller.getShownStateInsets(); Insets insets = Insets.add(shownInsets, Insets.of(0, 0, 0, (int) (-shownInsets.bottom / 4 * anim.getAnimatedFraction()))); controller.setInsetsAndAlpha(insets, (float) animation.getAnimatedValue(), anim.getAnimatedFraction()); }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { controller.finish(false); } }); anim.setDuration(IME_DISAPPEAR_DURATION_MS); anim.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN); anim.start(); } @Override public void onFinished( @NonNull WindowInsetsAnimationController controller) { mDisappearAnimRunning = false; } @Override public void onCancelled( @Nullable WindowInsetsAnimationController controller) { } }); } if (mCurrentSecuritySelection != SecurityMode.None) { return getSecurityView(mCurrentSecuritySelection).startDisappearAnimation( Loading Loading @@ -887,6 +949,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe @Override public void reset() { mSecurityViewFlipper.reset(); mDisappearAnimRunning = false; } @Override Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ package com.android.keyguard; import static android.view.WindowInsets.Type.ime; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -110,6 +112,7 @@ public class KeyguardSecurityContainerTest extends SysuiTestCase { mKeyguardSecurityContainer.startDisappearAnimation(null); verify(mSecurityView).startDisappearAnimation(eq(null)); verify(mWindowInsetsController).hide(eq(ime())); verify(mWindowInsetsController).controlWindowInsetsAnimation(eq(ime()), anyLong(), any(), any(), any()); } } No newline at end of file