1 /* 2 * Copyright (C) 2025 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.keyguard.shared.transition 18 19 import com.android.systemui.keyguard.shared.model.KeyguardState 20 21 class FakeKeyguardTransitionAnimationCallback : KeyguardTransitionAnimationCallback { 22 23 private val _activeAnimations = mutableListOf<TransitionAnimation>() 24 /** The animations that have been started but not yet ended nor canceled. */ 25 val activeAnimations: List<TransitionAnimation> 26 get() = _activeAnimations.toList() 27 28 private val _finishedAnimations = mutableListOf<TransitionAnimation>() 29 /** The animations that have ended. */ 30 val finishedAnimations: List<TransitionAnimation> 31 get() = _finishedAnimations.toList() 32 33 private val _canceledAnimations = mutableListOf<TransitionAnimation>() 34 /** The animations that have been canceled. */ 35 val canceledAnimations: List<TransitionAnimation> 36 get() = _canceledAnimations.toList() 37 onAnimationStartednull38 override fun onAnimationStarted(from: KeyguardState, to: KeyguardState) { 39 _activeAnimations.add(TransitionAnimation(from = from, to = to)) 40 } 41 onAnimationEndednull42 override fun onAnimationEnded(from: KeyguardState, to: KeyguardState) { 43 val animation = TransitionAnimation(from = from, to = to) 44 check(_activeAnimations.remove(animation)) { "Ending an animation that wasn't started!" } 45 _finishedAnimations.add(animation) 46 } 47 onAnimationCancelednull48 override fun onAnimationCanceled(from: KeyguardState, to: KeyguardState) { 49 val animation = TransitionAnimation(from = from, to = to) 50 check(_activeAnimations.remove(animation)) { "Canceling an animation that wasn't started!" } 51 _canceledAnimations.add(animation) 52 } 53 54 data class TransitionAnimation(val from: KeyguardState, val to: KeyguardState) 55 } 56