Merge "Add LogBuffer to SystemStatusAnimationScheduler" into udc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b1aa946049
@@ -22,6 +22,8 @@ import com.android.systemui.dagger.qualifiers.Main
|
|||||||
import com.android.systemui.dump.DumpManager
|
import com.android.systemui.dump.DumpManager
|
||||||
import com.android.systemui.flags.FeatureFlags
|
import com.android.systemui.flags.FeatureFlags
|
||||||
import com.android.systemui.flags.Flags
|
import com.android.systemui.flags.Flags
|
||||||
|
import com.android.systemui.log.LogBuffer
|
||||||
|
import com.android.systemui.log.LogBufferFactory
|
||||||
import com.android.systemui.statusbar.window.StatusBarWindowController
|
import com.android.systemui.statusbar.window.StatusBarWindowController
|
||||||
import com.android.systemui.util.concurrency.DelayableExecutor
|
import com.android.systemui.util.concurrency.DelayableExecutor
|
||||||
import com.android.systemui.util.time.SystemClock
|
import com.android.systemui.util.time.SystemClock
|
||||||
@@ -34,6 +36,13 @@ interface StatusBarEventsModule {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@SysUISingleton
|
||||||
|
@SystemStatusAnimationSchedulerLog
|
||||||
|
fun provideSystemStatusAnimationSchedulerLogBuffer(factory: LogBufferFactory): LogBuffer {
|
||||||
|
return factory.create("SystemStatusAnimationSchedulerLog", 60)
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
fun provideSystemStatusAnimationScheduler(
|
fun provideSystemStatusAnimationScheduler(
|
||||||
@@ -44,7 +53,8 @@ interface StatusBarEventsModule {
|
|||||||
dumpManager: DumpManager,
|
dumpManager: DumpManager,
|
||||||
systemClock: SystemClock,
|
systemClock: SystemClock,
|
||||||
@Application coroutineScope: CoroutineScope,
|
@Application coroutineScope: CoroutineScope,
|
||||||
@Main executor: DelayableExecutor
|
@Main executor: DelayableExecutor,
|
||||||
|
logger: SystemStatusAnimationSchedulerLogger
|
||||||
): SystemStatusAnimationScheduler {
|
): SystemStatusAnimationScheduler {
|
||||||
return if (featureFlags.isEnabled(Flags.PLUG_IN_STATUS_BAR_CHIP)) {
|
return if (featureFlags.isEnabled(Flags.PLUG_IN_STATUS_BAR_CHIP)) {
|
||||||
SystemStatusAnimationSchedulerImpl(
|
SystemStatusAnimationSchedulerImpl(
|
||||||
@@ -53,7 +63,8 @@ interface StatusBarEventsModule {
|
|||||||
statusBarWindowController,
|
statusBarWindowController,
|
||||||
dumpManager,
|
dumpManager,
|
||||||
systemClock,
|
systemClock,
|
||||||
coroutineScope
|
coroutineScope,
|
||||||
|
logger
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
SystemStatusAnimationSchedulerLegacyImpl(
|
SystemStatusAnimationSchedulerLegacyImpl(
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.android.systemui.statusbar.events
|
|||||||
|
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.provider.DeviceConfig
|
import android.provider.DeviceConfig
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.animation.Animator
|
import androidx.core.animation.Animator
|
||||||
import androidx.core.animation.AnimatorListenerAdapter
|
import androidx.core.animation.AnimatorListenerAdapter
|
||||||
import androidx.core.animation.AnimatorSet
|
import androidx.core.animation.AnimatorSet
|
||||||
@@ -69,7 +68,8 @@ constructor(
|
|||||||
private val statusBarWindowController: StatusBarWindowController,
|
private val statusBarWindowController: StatusBarWindowController,
|
||||||
dumpManager: DumpManager,
|
dumpManager: DumpManager,
|
||||||
private val systemClock: SystemClock,
|
private val systemClock: SystemClock,
|
||||||
@Application private val coroutineScope: CoroutineScope
|
@Application private val coroutineScope: CoroutineScope,
|
||||||
|
private val logger: SystemStatusAnimationSchedulerLogger?
|
||||||
) : SystemStatusAnimationScheduler {
|
) : SystemStatusAnimationScheduler {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -121,6 +121,10 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coroutineScope.launch {
|
||||||
|
animationState.collect { logger?.logAnimationStateUpdate(it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SystemAnimationState override fun getAnimationState(): Int = animationState.value
|
@SystemAnimationState override fun getAnimationState(): Int = animationState.value
|
||||||
@@ -140,32 +144,17 @@ constructor(
|
|||||||
) {
|
) {
|
||||||
// a event can only be scheduled if no other event is in progress or it has a higher
|
// a event can only be scheduled if no other event is in progress or it has a higher
|
||||||
// priority. If a persistent dot is currently displayed, don't schedule the event.
|
// priority. If a persistent dot is currently displayed, don't schedule the event.
|
||||||
if (DEBUG) {
|
logger?.logScheduleEvent(event)
|
||||||
Log.d(TAG, "scheduling event $event")
|
|
||||||
}
|
|
||||||
|
|
||||||
scheduleEvent(event)
|
scheduleEvent(event)
|
||||||
} else if (currentlyDisplayedEvent?.shouldUpdateFromEvent(event) == true) {
|
} else if (currentlyDisplayedEvent?.shouldUpdateFromEvent(event) == true) {
|
||||||
if (DEBUG) {
|
logger?.logUpdateEvent(event, animationState.value)
|
||||||
Log.d(
|
|
||||||
TAG,
|
|
||||||
"updating current event from: $event. animationState=${animationState.value}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
currentlyDisplayedEvent?.updateFromEvent(event)
|
currentlyDisplayedEvent?.updateFromEvent(event)
|
||||||
if (event.forceVisible) hasPersistentDot = true
|
if (event.forceVisible) hasPersistentDot = true
|
||||||
} else if (scheduledEvent.value?.shouldUpdateFromEvent(event) == true) {
|
} else if (scheduledEvent.value?.shouldUpdateFromEvent(event) == true) {
|
||||||
if (DEBUG) {
|
logger?.logUpdateEvent(event, animationState.value)
|
||||||
Log.d(
|
|
||||||
TAG,
|
|
||||||
"updating scheduled event from: $event. animationState=${animationState.value}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
scheduledEvent.value?.updateFromEvent(event)
|
scheduledEvent.value?.updateFromEvent(event)
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) {
|
logger?.logIgnoreEvent(event)
|
||||||
Log.d(TAG, "ignoring event $event")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,6 +345,7 @@ constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun notifyTransitionToPersistentDot(): Animator? {
|
private fun notifyTransitionToPersistentDot(): Animator? {
|
||||||
|
logger?.logTransitionToPersistentDotCallbackInvoked()
|
||||||
val anims: List<Animator> =
|
val anims: List<Animator> =
|
||||||
listeners.mapNotNull {
|
listeners.mapNotNull {
|
||||||
it.onSystemStatusAnimationTransitionToPersistentDot(
|
it.onSystemStatusAnimationTransitionToPersistentDot(
|
||||||
@@ -373,6 +363,7 @@ constructor(
|
|||||||
|
|
||||||
private fun notifyHidePersistentDot(): Animator? {
|
private fun notifyHidePersistentDot(): Animator? {
|
||||||
Assert.isMainThread()
|
Assert.isMainThread()
|
||||||
|
logger?.logHidePersistentDotCallbackInvoked()
|
||||||
val anims: List<Animator> = listeners.mapNotNull { it.onHidePersistentDot() }
|
val anims: List<Animator> = listeners.mapNotNull { it.onHidePersistentDot() }
|
||||||
|
|
||||||
if (animationState.value == SHOWING_PERSISTENT_DOT) {
|
if (animationState.value == SHOWING_PERSISTENT_DOT) {
|
||||||
@@ -424,5 +415,4 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val DEBUG = false
|
|
||||||
private const val TAG = "SystemStatusAnimationSchedulerImpl"
|
private const val TAG = "SystemStatusAnimationSchedulerImpl"
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.statusbar.events
|
||||||
|
|
||||||
|
import javax.inject.Qualifier
|
||||||
|
|
||||||
|
/** Logs for the SystemStatusAnimationScheduler. */
|
||||||
|
@Qualifier
|
||||||
|
@MustBeDocumented
|
||||||
|
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
|
||||||
|
annotation class SystemStatusAnimationSchedulerLog
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package com.android.systemui.statusbar.events
|
||||||
|
|
||||||
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
|
import com.android.systemui.log.LogBuffer
|
||||||
|
import com.android.systemui.log.LogLevel
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
/** Logs for the SystemStatusAnimationScheduler. */
|
||||||
|
@SysUISingleton
|
||||||
|
class SystemStatusAnimationSchedulerLogger
|
||||||
|
@Inject
|
||||||
|
constructor(
|
||||||
|
@SystemStatusAnimationSchedulerLog private val logBuffer: LogBuffer,
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun logScheduleEvent(event: StatusEvent) {
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{
|
||||||
|
str1 = event.javaClass.simpleName
|
||||||
|
int1 = event.priority
|
||||||
|
bool1 = event.forceVisible
|
||||||
|
bool2 = event.showAnimation
|
||||||
|
},
|
||||||
|
{ "Scheduling event: $str1(forceVisible=$bool1, priority=$int1, showAnimation=$bool2)" }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logUpdateEvent(event: StatusEvent, @SystemAnimationState animationState: Int) {
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{
|
||||||
|
str1 = event.javaClass.simpleName
|
||||||
|
int1 = event.priority
|
||||||
|
bool1 = event.forceVisible
|
||||||
|
bool2 = event.showAnimation
|
||||||
|
int2 = animationState
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Updating current event from: $str1(forceVisible=$bool1, priority=$int1, " +
|
||||||
|
"showAnimation=$bool2), animationState=${animationState.name()}"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logIgnoreEvent(event: StatusEvent) {
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{
|
||||||
|
str1 = event.javaClass.simpleName
|
||||||
|
int1 = event.priority
|
||||||
|
bool1 = event.forceVisible
|
||||||
|
bool2 = event.showAnimation
|
||||||
|
},
|
||||||
|
{ "Ignore event: $str1(forceVisible=$bool1, priority=$int1, showAnimation=$bool2)" }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logHidePersistentDotCallbackInvoked() {
|
||||||
|
logBuffer.log(TAG, LogLevel.DEBUG, "Hide persistent dot callback invoked")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logTransitionToPersistentDotCallbackInvoked() {
|
||||||
|
logBuffer.log(TAG, LogLevel.DEBUG, "Transition to persistent dot callback invoked")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logAnimationStateUpdate(@SystemAnimationState animationState: Int) {
|
||||||
|
logBuffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{ int1 = animationState },
|
||||||
|
{ "AnimationState update: ${int1.name()}" }
|
||||||
|
)
|
||||||
|
animationState.name()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun @receiver:SystemAnimationState Int.name() =
|
||||||
|
when (this) {
|
||||||
|
IDLE -> "IDLE"
|
||||||
|
ANIMATION_QUEUED -> "ANIMATION_QUEUED"
|
||||||
|
ANIMATING_IN -> "ANIMATING_IN"
|
||||||
|
RUNNING_CHIP_ANIM -> "RUNNING_CHIP_ANIM"
|
||||||
|
ANIMATING_OUT -> "ANIMATING_OUT"
|
||||||
|
SHOWING_PERSISTENT_DOT -> "SHOWING_PERSISTENT_DOT"
|
||||||
|
else -> "UNKNOWN_ANIMATION_STATE"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val TAG = "SystemStatusAnimationSchedulerLog"
|
||||||
@@ -69,6 +69,8 @@ class SystemStatusAnimationSchedulerImplTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Mock private lateinit var listener: SystemStatusAnimationCallback
|
@Mock private lateinit var listener: SystemStatusAnimationCallback
|
||||||
|
|
||||||
|
@Mock private lateinit var logger: SystemStatusAnimationSchedulerLogger
|
||||||
|
|
||||||
private lateinit var systemClock: FakeSystemClock
|
private lateinit var systemClock: FakeSystemClock
|
||||||
private lateinit var chipAnimationController: SystemEventChipAnimationController
|
private lateinit var chipAnimationController: SystemEventChipAnimationController
|
||||||
private lateinit var systemStatusAnimationScheduler: SystemStatusAnimationScheduler
|
private lateinit var systemStatusAnimationScheduler: SystemStatusAnimationScheduler
|
||||||
@@ -538,7 +540,8 @@ class SystemStatusAnimationSchedulerImplTest : SysuiTestCase() {
|
|||||||
statusBarWindowController,
|
statusBarWindowController,
|
||||||
dumpManager,
|
dumpManager,
|
||||||
systemClock,
|
systemClock,
|
||||||
CoroutineScope(StandardTestDispatcher(testScope.testScheduler))
|
CoroutineScope(StandardTestDispatcher(testScope.testScheduler)),
|
||||||
|
logger
|
||||||
)
|
)
|
||||||
// add a mock listener
|
// add a mock listener
|
||||||
systemStatusAnimationScheduler.addCallback(listener)
|
systemStatusAnimationScheduler.addCallback(listener)
|
||||||
|
|||||||
Reference in New Issue
Block a user