diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/StatusEvent.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/StatusEvent.kt index 398f5e35e5491..539020d52db5d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/StatusEvent.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/StatusEvent.kt @@ -31,6 +31,8 @@ interface StatusEvent { val priority: Int // Whether or not to force the status bar open and show a dot val forceVisible: Boolean + // Whether or not to show an animation for this event + val showAnimation: Boolean val viewCreator: (context: Context) -> View // Update this event with values from another event. @@ -47,6 +49,7 @@ interface StatusEvent { class BatteryEvent : StatusEvent { override val priority = 50 override val forceVisible = false + override val showAnimation = true override val viewCreator: (context: Context) -> View = { context -> val iv = ImageView(context) @@ -59,7 +62,7 @@ class BatteryEvent : StatusEvent { return javaClass.simpleName } } -class PrivacyEvent : StatusEvent { +class PrivacyEvent(override val showAnimation: Boolean = true) : StatusEvent { override val priority = 100 override val forceVisible = true var privacyItems: List = listOf() diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventCoordinator.kt index 20135447c3654..ba50659f55675 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventCoordinator.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventCoordinator.kt @@ -16,11 +16,13 @@ package com.android.systemui.statusbar.events -import android.os.SystemClock +import android.provider.DeviceConfig +import android.provider.DeviceConfig.NAMESPACE_PRIVACY import com.android.systemui.dagger.SysUISingleton import com.android.systemui.privacy.PrivacyItem import com.android.systemui.privacy.PrivacyItemController import com.android.systemui.statusbar.policy.BatteryController +import com.android.systemui.util.time.SystemClock import javax.inject.Inject /** @@ -29,6 +31,7 @@ import javax.inject.Inject */ @SysUISingleton class SystemEventCoordinator @Inject constructor( + private val systemClock: SystemClock, private val batteryController: BatteryController, private val privacyController: PrivacyItemController ) { @@ -61,9 +64,9 @@ class SystemEventCoordinator @Inject constructor( } fun notifyPrivacyItemsChanged(showAnimation: Boolean = true) { - val event = PrivacyEvent() + val event = PrivacyEvent(showAnimation) event.privacyItems = privacyStateListener.currentPrivacyItems - scheduler.onStatusEvent(event, showAnimation) + scheduler.onStatusEvent(event) } private val batteryStateListener = object : BatteryController.BatteryStateChangeCallback { @@ -92,14 +95,14 @@ class SystemEventCoordinator @Inject constructor( private val privacyStateListener = object : PrivacyItemController.Callback { var currentPrivacyItems = listOf() var previousPrivacyItems = listOf() - var timeLastEmpty = SystemClock.elapsedRealtime() + var timeLastEmpty = systemClock.elapsedRealtime() override fun onPrivacyItemsChanged(privacyItems: List) { if (uniqueItemsMatch(privacyItems, currentPrivacyItems)) { return } else if (privacyItems.isEmpty()) { previousPrivacyItems = currentPrivacyItems - timeLastEmpty = SystemClock.elapsedRealtime() + timeLastEmpty = systemClock.elapsedRealtime() } currentPrivacyItems = privacyItems @@ -110,8 +113,9 @@ class SystemEventCoordinator @Inject constructor( if (currentPrivacyItems.isEmpty()) { notifyPrivacyItemsEmpty() } else { - val showAnimation = !uniqueItemsMatch(currentPrivacyItems, previousPrivacyItems) || - SystemClock.elapsedRealtime() - timeLastEmpty >= DEBOUNCE_TIME + val showAnimation = isChipAnimationEnabled() && + (!uniqueItemsMatch(currentPrivacyItems, previousPrivacyItems) || + systemClock.elapsedRealtime() - timeLastEmpty >= DEBOUNCE_TIME) notifyPrivacyItemsChanged(showAnimation) } } @@ -121,8 +125,13 @@ class SystemEventCoordinator @Inject constructor( return one.map { it.application.uid to it.privacyType.permGroupName }.toSet() == two.map { it.application.uid to it.privacyType.permGroupName }.toSet() } + + private fun isChipAnimationEnabled(): Boolean { + return DeviceConfig.getBoolean(NAMESPACE_PRIVACY, CHIP_ANIMATION_ENABLED, true) + } } } private const val DEBOUNCE_TIME = 3000L +private const val CHIP_ANIMATION_ENABLED = "privacy_chip_animation_enabled" private const val TAG = "SystemEventCoordinator" \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt index 2f565037a359c..b6f041685dd14 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt @@ -90,7 +90,7 @@ class SystemStatusAnimationScheduler @Inject constructor( coordinator.attachScheduler(this) } - fun onStatusEvent(event: StatusEvent, showAnimation: Boolean = true) { + fun onStatusEvent(event: StatusEvent) { // Ignore any updates until the system is up and running if (isTooEarly() || !isImmersiveIndicatorEnabled()) { return @@ -103,7 +103,7 @@ class SystemStatusAnimationScheduler @Inject constructor( if (DEBUG) { Log.d(TAG, "scheduling event $event") } - if (showAnimation) { + if (event.showAnimation) { scheduleEvent(event) } else if (event.forceVisible) { hasPersistentDot = true