From 66b5926148d910dc7be78e0c05f3ab5a33a58941 Mon Sep 17 00:00:00 2001 From: "Cassie(Yitong) Wang" Date: Sun, 11 Sep 2022 23:09:23 -0700 Subject: [PATCH] Make classes open for inherit For the implementation of Car/SystemUI immersive mic indicator. Bug: 241931460 Test: Unit tests Change-Id: I6c8338e3c3d4fceb5ea471114fd6a655eb8f3fd9 --- .../decor/PrivacyDotDecorProviderFactory.kt | 2 +- .../events/PrivacyDotViewController.kt | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/decor/PrivacyDotDecorProviderFactory.kt b/packages/SystemUI/src/com/android/systemui/decor/PrivacyDotDecorProviderFactory.kt index e18c0e15b57a7..8cfd39148f1cc 100644 --- a/packages/SystemUI/src/com/android/systemui/decor/PrivacyDotDecorProviderFactory.kt +++ b/packages/SystemUI/src/com/android/systemui/decor/PrivacyDotDecorProviderFactory.kt @@ -33,7 +33,7 @@ import javax.inject.Inject * of the privacy dot views are controlled by the PrivacyDotViewController. */ @SysUISingleton -class PrivacyDotDecorProviderFactory @Inject constructor( +open class PrivacyDotDecorProviderFactory @Inject constructor( @Main private val res: Resources ) : DecorProviderFactory() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt index 737b4812d4fb6..143c6979c5903 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt @@ -62,7 +62,7 @@ import javax.inject.Inject */ @SysUISingleton -class PrivacyDotViewController @Inject constructor( +open class PrivacyDotViewController @Inject constructor( @Main private val mainExecutor: Executor, private val stateController: StatusBarStateController, private val configurationController: ConfigurationController, @@ -76,7 +76,8 @@ class PrivacyDotViewController @Inject constructor( private lateinit var br: View // Only can be modified on @UiThread - private var currentViewState: ViewState = ViewState() + var currentViewState: ViewState = ViewState() + get() = field @GuardedBy("lock") private var nextViewState: ViewState = currentViewState.copy() @@ -142,6 +143,10 @@ class PrivacyDotViewController @Inject constructor( uiExecutor = e } + fun getUiExecutor(): DelayableExecutor? { + return uiExecutor + } + fun setShowingListener(l: ShowingListener?) { showingListener = l } @@ -176,7 +181,7 @@ class PrivacyDotViewController @Inject constructor( } @UiThread - private fun hideDotView(dot: View, animate: Boolean) { + fun hideDotView(dot: View, animate: Boolean) { dot.clearAnimation() if (animate) { dot.animate() @@ -195,7 +200,7 @@ class PrivacyDotViewController @Inject constructor( } @UiThread - private fun showDotView(dot: View, animate: Boolean) { + fun showDotView(dot: View, animate: Boolean) { dot.clearAnimation() if (animate) { dot.visibility = View.VISIBLE @@ -508,6 +513,13 @@ class PrivacyDotViewController @Inject constructor( state.designatedCorner?.contentDescription = state.contentDescription } + updateDotView(state) + + currentViewState = state + } + + @UiThread + open fun updateDotView(state: ViewState) { val shouldShow = state.shouldShowDot() if (shouldShow != currentViewState.shouldShowDot()) { if (shouldShow && state.designatedCorner != null) { @@ -516,8 +528,6 @@ class PrivacyDotViewController @Inject constructor( hideDotView(state.designatedCorner, true) } } - - currentViewState = state } private val systemStatusAnimationCallback: SystemStatusAnimationCallback = @@ -621,7 +631,7 @@ private fun Int.innerGravity(): Int { } } -private data class ViewState( +data class ViewState( val viewInitialized: Boolean = false, val systemPrivacyEventIsActive: Boolean = false,