Introduce DreamLog using LogBuffer.

This change introduces a DreamLogger which uses a LogBuffer. It also
logs the overlay animations state to this buffer.

Bug: 274804854
Test: atest DreamOverlayAnimationsControllerTest
Test: adb shell dumpsys activity service
com.android.systemui/.SystemUIService DreamLog -> verify overlay
animation states are dumpped

Change-Id: I0609cd20c47054de417367e054471ed66af57c41
This commit is contained in:
Darrell Shi
2023-04-24 20:59:35 +00:00
parent 1d8d37bb35
commit cecff2619c
5 changed files with 78 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.dreams
import com.android.systemui.log.dagger.DreamLog
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel
import javax.inject.Inject
/** Logs dream-related stuff to a {@link LogBuffer}. */
class DreamLogger @Inject constructor(@DreamLog private val buffer: LogBuffer) {
/** Logs a debug message to the buffer. */
fun d(tag: String, message: String) {
buffer.log(tag, LogLevel.DEBUG, { str1 = message }, { message })
}
}

View File

@@ -21,6 +21,7 @@ import android.animation.AnimatorSet
import android.animation.ValueAnimator
import android.view.View
import android.view.animation.Interpolator
import androidx.core.animation.doOnCancel
import androidx.core.animation.doOnEnd
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
@@ -65,7 +66,11 @@ constructor(
private val mDreamInTranslationYDistance: Int,
@Named(DreamOverlayModule.DREAM_IN_TRANSLATION_Y_DURATION)
private val mDreamInTranslationYDurationMs: Long,
private val mLogger: DreamLogger,
) {
companion object {
private const val TAG = "DreamOverlayAnimationsController"
}
private var mAnimator: Animator? = null
private lateinit var view: View
@@ -169,8 +174,11 @@ constructor(
doOnEnd {
mAnimator = null
mOverlayStateController.setEntryAnimationsFinished(true)
mLogger.d(TAG, "Dream overlay entry animations finished.")
}
doOnCancel { mLogger.d(TAG, "Dream overlay entry animations canceled.") }
start()
mLogger.d(TAG, "Dream overlay entry animations started.")
}
}
@@ -232,8 +240,11 @@ constructor(
doOnEnd {
mAnimator = null
mOverlayStateController.setExitAnimationsRunning(false)
mLogger.d(TAG, "Dream overlay exit animations finished.")
}
doOnCancel { mLogger.d(TAG, "Dream overlay exit animations canceled.") }
start()
mLogger.d(TAG, "Dream overlay exit animations started.")
}
mOverlayStateController.setExitAnimationsRunning(true)
return mAnimator as AnimatorSet

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.log.dagger
import javax.inject.Qualifier
/** A [com.android.systemui.log.LogBuffer] for dream-related logging. */
@Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class DreamLog

View File

@@ -440,4 +440,14 @@ public class LogModule {
public static LogBuffer provideKeyguardLogBuffer(LogBufferFactory factory) {
return factory.create("KeyguardLog", 250);
}
/**
* Provides a {@link LogBuffer} for dream-related logs.
*/
@Provides
@SysUISingleton
@DreamLog
public static LogBuffer provideDreamLogBuffer(LogBufferFactory factory) {
return factory.create("DreamLog", 250);
}
}

View File

@@ -24,6 +24,7 @@ import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Mock
import org.mockito.Mockito.anyLong
import org.mockito.Mockito.atLeastOnce
import org.mockito.Mockito.eq
import org.mockito.Mockito.never
import org.mockito.Mockito.times
@@ -49,6 +50,7 @@ class DreamOverlayAnimationsControllerTest : SysuiTestCase() {
@Mock private lateinit var stateController: DreamOverlayStateController
@Mock private lateinit var configController: ConfigurationController
@Mock private lateinit var transitionViewModel: DreamingToLockscreenTransitionViewModel
@Mock private lateinit var logger: DreamLogger
private lateinit var controller: DreamOverlayAnimationsController
@Before
@@ -67,6 +69,7 @@ class DreamOverlayAnimationsControllerTest : SysuiTestCase() {
DREAM_IN_COMPLICATIONS_ANIMATION_DURATION,
DREAM_IN_TRANSLATION_Y_DISTANCE,
DREAM_IN_TRANSLATION_Y_DURATION,
logger
)
val mockView: View = mock()
@@ -82,9 +85,9 @@ class DreamOverlayAnimationsControllerTest : SysuiTestCase() {
verify(stateController).setExitAnimationsRunning(true)
val captor = argumentCaptor<Animator.AnimatorListener>()
verify(mockAnimator).addListener(captor.capture())
verify(mockAnimator, atLeastOnce()).addListener(captor.capture())
captor.value.onAnimationEnd(mockAnimator)
captor.allValues.forEach { it.onAnimationEnd(mockAnimator) }
verify(stateController).setExitAnimationsRunning(false)
}