summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Göllner <chrisgollner@google.com> 2024-06-04 16:27:09 +0100
committer Chris Göllner <chrisgollner@google.com> 2024-06-04 16:27:45 +0100
commit352ab97e76faa0e3bbcedf60129ab342e7bd9623 (patch)
tree172600505b48fcc4c3cc9080f6458e168d4f576d
parentf008fd09f1f7ffdb09087f0de4689f1e325f929f (diff)
Status Bar - Fix privacy dot being in the wrong corner after fold/unfold
When unfolding and folding, the PrivacyDotViewController will be reused and #initialize will be called with new views. For the views to be in the correct position, their gravity has to be set. The fix is to make sure the gravity is updated when we have new views. Fixes: 339335643 Test: Unit tests in this CL Test: Manually Flag: com.android.systemui.privacy_dot_unfold_wrong_corner_fix Change-Id: Id37da91b04cf5fa956f3d6d7f254e9c2634a2563
-rw-r--r--packages/SystemUI/aconfig/systemui.aconfig10
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/PrivacyDotViewControllerTest.kt56
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt7
3 files changed, 69 insertions, 4 deletions
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 2cb297ad1359..723959ac3f6e 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -984,6 +984,16 @@ flag {
}
flag {
+ namespace: "systemui"
+ name: "privacy_dot_unfold_wrong_corner_fix"
+ description: "Fixes an issue where the privacy dot is at the wrong corner after unfolding/folding."
+ bug: "339335643"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "validate_keyboard_shortcut_helper_icon_uri"
namespace: "systemui"
description: "Adds a check that the caller can access the content URI of an icon in the shortcut helper."
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/PrivacyDotViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/PrivacyDotViewControllerTest.kt
index 43409718c849..f12643280c26 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/PrivacyDotViewControllerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/PrivacyDotViewControllerTest.kt
@@ -18,14 +18,19 @@ package com.android.systemui.statusbar.events
import android.graphics.Point
import android.graphics.Rect
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper.RunWithLooper
import android.view.Display
import android.view.DisplayAdjustments
import android.view.View
import android.widget.FrameLayout
+import android.widget.FrameLayout.LayoutParams.UNSPECIFIED_GRAVITY
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
+import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
+import com.android.systemui.res.R
import com.android.systemui.statusbar.FakeStatusBarStateController
import com.android.systemui.statusbar.phone.StatusBarContentInsetsProvider
import com.android.systemui.statusbar.policy.FakeConfigurationController
@@ -291,14 +296,61 @@ class PrivacyDotViewControllerTest : SysuiTestCase() {
assertThat(controller.currentViewState.designatedCorner).isEqualTo(bottomRightView)
}
+ @Test
+ @EnableFlags(Flags.FLAG_PRIVACY_DOT_UNFOLD_WRONG_CORNER_FIX)
+ fun initialize_newViews_fixFlagEnabled_gravityIsUpdated() {
+ val newTopLeftView = initDotView()
+ val newTopRightView = initDotView()
+ val newBottomLeftView = initDotView()
+ val newBottomRightView = initDotView()
+ setRotation(ROTATION_LANDSCAPE) // Bottom right used in landscape
+
+ val controller = createAndInitializeController()
+ // Re-init with different views, but same rotation
+ controller.initialize(
+ newTopLeftView,
+ newTopRightView,
+ newBottomLeftView,
+ newBottomRightView
+ )
+
+ assertThat((newBottomRightView.layoutParams as FrameLayout.LayoutParams).gravity)
+ .isNotEqualTo(UNSPECIFIED_GRAVITY)
+ }
+
+ @Test
+ @DisableFlags(Flags.FLAG_PRIVACY_DOT_UNFOLD_WRONG_CORNER_FIX)
+ fun initialize_newViews_fixFlagDisabled_gravityIsNotUpdated() {
+ val newTopLeftView = initDotView()
+ val newTopRightView = initDotView()
+ val newBottomLeftView = initDotView()
+ val newBottomRightView = initDotView()
+ setRotation(ROTATION_LANDSCAPE) // Bottom right used in landscape
+
+ val controller = createAndInitializeController()
+ // Re-init with different views, but same rotation
+ controller.initialize(
+ newTopLeftView,
+ newTopRightView,
+ newBottomLeftView,
+ newBottomRightView
+ )
+
+ assertThat((newBottomRightView.layoutParams as FrameLayout.LayoutParams).gravity)
+ .isEqualTo(UNSPECIFIED_GRAVITY)
+ }
+
private fun setRotation(rotation: Int) {
whenever(mockDisplay.rotation).thenReturn(rotation)
}
- private fun initDotView(): View =
- View(context).also {
+ private fun initDotView(): View {
+ val privacyDot = View(context).also { it.id = R.id.privacy_dot }
+ return FrameLayout(context).also {
it.layoutParams = FrameLayout.LayoutParams(/* width = */ 0, /* height = */ 0)
+ it.addView(privacyDot)
}
+ }
private fun enableRtl() {
configurationController.notifyLayoutDirectionChanged(isRtl = true)
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 658625996575..9eb9ed5f2063 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt
@@ -26,6 +26,7 @@ import android.widget.FrameLayout
import androidx.core.animation.Animator
import com.android.app.animation.Interpolators
import com.android.internal.annotations.GuardedBy
+import com.android.systemui.Flags.privacyDotUnfoldWrongCornerFix
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
@@ -505,7 +506,9 @@ open class PrivacyDotViewController @Inject constructor(
return
}
- if (state.rotation != currentViewState.rotation) {
+ val designatedCornerChanged = state.designatedCorner != currentViewState.designatedCorner
+ val rotationChanged = state.rotation != currentViewState.rotation
+ if (rotationChanged || (designatedCornerChanged && privacyDotUnfoldWrongCornerFix())) {
// A rotation has started, hide the views to avoid flicker
updateRotations(state.rotation, state.paddingTop)
}
@@ -515,7 +518,7 @@ open class PrivacyDotViewController @Inject constructor(
views.forEach { it.requestLayout() }
}
- if (state.designatedCorner != currentViewState.designatedCorner) {
+ if (designatedCornerChanged) {
currentViewState.designatedCorner?.contentDescription = null
state.designatedCorner?.contentDescription = state.contentDescription