Merge "Check for emergency installer attribute and permission to trigger an emergency uninstall" into main
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 44444b5..67752f2 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -62,6 +62,7 @@
import static android.app.admin.flags.Flags.FLAG_HEADLESS_DEVICE_OWNER_SINGLE_USER_ENABLED;
import static android.app.admin.flags.Flags.FLAG_SECURITY_LOG_V2_ENABLED;
import static android.app.admin.flags.Flags.onboardingBugreportV2Enabled;
+import static android.app.admin.flags.Flags.onboardingConsentlessBugreports;
import static android.app.admin.flags.Flags.FLAG_IS_MTE_POLICY_ENFORCED;
import static android.content.Intent.LOCAL_FLAG_FROM_SYSTEM;
import static android.net.NetworkCapabilities.NET_ENTERPRISE_ID_1;
@@ -17626,6 +17627,17 @@
return onboardingBugreportV2Enabled();
}
+ // TODO(b/308755220): Remove once the build is finalised.
+ /**
+ * Returns true if the flag for consentless bugreports is enabled.
+ *
+ * @hide
+ */
+ @UnsupportedAppUsage
+ public boolean isOnboardingConsentlessBugreportFlagEnabled() {
+ return onboardingConsentlessBugreports();
+ }
+
/**
* Returns the subscription ids of all subscriptions which were downloaded by the calling
* admin.
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index 6db40bf..79a9f2d 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -682,7 +682,8 @@
* <li>For a touch screen or touch pad, reports the approximate size of the contact area in
* relation to the maximum detectable size for the device. The value is normalized
* to a range from 0 (smallest detectable size) to 1 (largest detectable size),
- * although it is not a linear scale. This value is of limited use.
+ * although it is not a linear scale. The value of size can be used to
+ * determine fat touch events.
* To obtain calibrated size information, use
* {@link #AXIS_TOUCH_MAJOR} or {@link #AXIS_TOOL_MAJOR}.
* </ul>
@@ -2795,13 +2796,8 @@
}
/**
- * Returns the current pressure of this event for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * The pressure generally
- * ranges from 0 (no pressure at all) to 1 (normal pressure), however
- * values higher than 1 may be generated depending on the calibration of
- * the input device.
+ * Returns the value of {@link #AXIS_PRESSURE} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2812,14 +2808,8 @@
}
/**
- * Returns a scaled value of the approximate size for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * This represents some approximation of the area of the screen being
- * pressed; the actual value in pixels corresponding to the
- * touch is normalized with the device specific range of values
- * and scaled to a value between 0 and 1. The value of size can be used to
- * determine fat touch events.
+ * Returns the value of {@link #AXIS_SIZE} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2830,10 +2820,8 @@
}
/**
- * Returns the length of the major axis of an ellipse that describes the touch
- * area at the point of contact for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
+ * Returns the value of {@link #AXIS_TOUCH_MAJOR} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2844,10 +2832,8 @@
}
/**
- * Returns the length of the minor axis of an ellipse that describes the touch
- * area at the point of contact for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
+ * Returns the value of {@link #AXIS_TOUCH_MINOR} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2858,12 +2844,8 @@
}
/**
- * Returns the length of the major axis of an ellipse that describes the size of
- * the approaching tool for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * The tool area represents the estimated size of the finger or pen that is
- * touching the device independent of its actual touch area at the point of contact.
+ * Returns the value of {@link #AXIS_TOOL_MAJOR} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2874,12 +2856,8 @@
}
/**
- * Returns the length of the minor axis of an ellipse that describes the size of
- * the approaching tool for the given pointer
- * <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * The tool area represents the estimated size of the finger or pen that is
- * touching the device independent of its actual touch area at the point of contact.
+ * Returns the value of {@link #AXIS_TOOL_MINOR} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
@@ -2890,15 +2868,8 @@
}
/**
- * Returns the orientation of the touch area and tool area in radians clockwise from vertical
- * for the given pointer <em>index</em> (use {@link #getPointerId(int)} to find the pointer
- * identifier for this index).
- * An angle of 0 radians indicates that the major axis of contact is oriented
- * upwards, is perfectly circular or is of unknown orientation. A positive angle
- * indicates that the major axis of contact is oriented to the right. A negative angle
- * indicates that the major axis of contact is oriented to the left.
- * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
- * (finger pointing fully right).
+ * Returns the value of {@link #AXIS_ORIENTATION} for the given pointer <em>index</em>.
+ *
* @param pointerIndex Raw index of pointer to retrieve. Value may be from 0
* (the first pointer that is down) to {@link #getPointerCount()}-1.
*
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 075ee1b..5e3f09a 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1984,9 +1984,25 @@
public @interface ContentSensitivity {}
/**
- * Automatically determine whether a view displays sensitive content. For example, available
- * autofill hints (or some other signal) can be used to determine if this view
- * displays sensitive content.
+ * Content sensitivity is determined by the framework. The framework uses a heuristic to
+ * determine if this view displays sensitive content.
+ * Autofill hints i.e. {@link #getAutofillHints()} are used in the heuristic
+ * to determine if this view should be considered as a sensitive view.
+ * <p>
+ * {@link #AUTOFILL_HINT_USERNAME},
+ * {@link #AUTOFILL_HINT_PASSWORD},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_NUMBER},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH},
+ * {@link #AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR}
+ * are considered sensitive hints by the framework, and the list may include more hints
+ * in the future.
+ *
+ * <p> The window hosting a sensitive view will be marked as secure during an active media
+ * projection session. This would be equivalent to applying
+ * {@link android.view.WindowManager.LayoutParams#FLAG_SECURE} to the window.
*
* @see #getContentSensitivity()
*/
@@ -1996,6 +2012,10 @@
/**
* The view displays sensitive content.
*
+ * <p> The window hosting a sensitive view will be marked as secure during an active media
+ * projection session. This would be equivalent to applying
+ * {@link android.view.WindowManager.LayoutParams#FLAG_SECURE} to the window.
+ *
* @see #getContentSensitivity()
*/
@FlaggedApi(FLAG_SENSITIVE_CONTENT_APP_PROTECTION_API)
@@ -10548,9 +10568,13 @@
/**
* Sets content sensitivity mode to determine whether this view displays sensitive content
- * (e.g. username, password etc.). The system may improve user privacy i.e. hide content
+ * (e.g. username, password etc.). The system will improve user privacy i.e. hide content
* drawn by a sensitive view from screen sharing and recording.
*
+ * <p> The window hosting a sensitive view will be marked as secure during an active media
+ * projection session. This would be equivalent to applying
+ * {@link android.view.WindowManager.LayoutParams#FLAG_SECURE} to the window.
+ *
* @param mode {@link #CONTENT_SENSITIVITY_AUTO}, {@link #CONTENT_SENSITIVITY_NOT_SENSITIVE}
* or {@link #CONTENT_SENSITIVITY_SENSITIVE}
*/
@@ -10574,8 +10598,7 @@
* {@link #setContentSensitivity(int)}.
*/
@FlaggedApi(FLAG_SENSITIVE_CONTENT_APP_PROTECTION_API)
- public @ContentSensitivity
- final int getContentSensitivity() {
+ public @ContentSensitivity final int getContentSensitivity() {
return (mPrivateFlags4 & PFLAG4_CONTENT_SENSITIVITY_MASK)
>> PFLAG4_CONTENT_SENSITIVITY_SHIFT;
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 0f54940b..42bf420 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -2801,6 +2801,10 @@
* it from appearing in screenshots or from being viewed on non-secure
* displays.
*
+ * <p>See {@link android.view.View#setContentSensitivity(int)}, a window hosting
+ * a sensitive view will be marked as secure during media projection, preventing
+ * it from being viewed on non-secure displays and during screen share.
+ *
* <p>See {@link android.view.Display#FLAG_SECURE} for more details about
* secure surfaces and secure displays.
*/
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 3310cfa..4a4c3a5 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -33,6 +33,13 @@
}
flag {
+ name: "notification_row_content_binder_refactor"
+ namespace: "systemui"
+ description: "Convert the NotificationContentInflater to Kotlin and restructure it to support modern views"
+ bug: "343942780"
+}
+
+flag {
name: "notification_minimalism_prototype"
namespace: "systemui"
description: "Prototype of notification minimalism; the new 'Intermediate' lockscreen customization proposal."
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
index a90f82e..c329384 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
@@ -1,9 +1,16 @@
package com.android.systemui.communal.ui.compose
+import androidx.compose.animation.core.LinearEasing
+import androidx.compose.animation.core.RepeatMode
+import androidx.compose.animation.core.animateFloat
+import androidx.compose.animation.core.infiniteRepeatable
+import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
+import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
@@ -13,12 +20,20 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.composed
+import androidx.compose.ui.draw.alpha
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.res.dimensionResource
+import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.animation.scene.CommunalSwipeDetector
@@ -36,8 +51,10 @@
import com.android.compose.animation.scene.SwipeDirection
import com.android.compose.animation.scene.observableTransitionState
import com.android.compose.animation.scene.transitions
+import com.android.compose.theme.LocalAndroidColorScheme
import com.android.systemui.Flags
import com.android.systemui.Flags.glanceableHubFullscreenSwipe
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.shared.model.CommunalTransitionKeys
import com.android.systemui.communal.ui.compose.extensions.allowGestures
@@ -102,6 +119,10 @@
val touchesAllowed by viewModel.touchesAllowed.collectAsStateWithLifecycle(initialValue = false)
val showGestureIndicator by
viewModel.showGestureIndicator.collectAsStateWithLifecycle(initialValue = false)
+ val backgroundType by
+ viewModel.communalBackground.collectAsStateWithLifecycle(
+ initialValue = CommunalBackgroundType.DEFAULT
+ )
val state: MutableSceneTransitionLayoutState = remember {
MutableSceneTransitionLayoutState(
initialScene = currentSceneKey,
@@ -174,7 +195,7 @@
userActions =
mapOf(Swipe(SwipeDirection.Right, fromSource = Edge.Left) to CommunalScenes.Blank)
) {
- CommunalScene(colors, content)
+ CommunalScene(backgroundType, colors, content)
}
}
@@ -186,17 +207,87 @@
/** Scene containing the glanceable hub UI. */
@Composable
private fun SceneScope.CommunalScene(
+ backgroundType: CommunalBackgroundType,
colors: CommunalColors,
content: CommunalContent,
modifier: Modifier = Modifier,
) {
- val backgroundColor by colors.backgroundColor.collectAsStateWithLifecycle()
-
- Box(
- modifier =
- Modifier.element(Communal.Elements.Scrim)
- .fillMaxSize()
- .background(Color(backgroundColor.toArgb())),
- )
+ Box(modifier = Modifier.element(Communal.Elements.Scrim).fillMaxSize()) {
+ when (backgroundType) {
+ CommunalBackgroundType.DEFAULT -> DefaultBackground(colors = colors)
+ CommunalBackgroundType.STATIC_GRADIENT -> StaticLinearGradient()
+ CommunalBackgroundType.ANIMATED -> AnimatedLinearGradient()
+ }
+ }
with(content) { Content(modifier = modifier) }
}
+
+/** Default background of the hub, a single color */
+@Composable
+private fun BoxScope.DefaultBackground(
+ colors: CommunalColors,
+) {
+ val backgroundColor by colors.backgroundColor.collectAsStateWithLifecycle()
+ Box(
+ modifier = Modifier.matchParentSize().background(Color(backgroundColor.toArgb())),
+ )
+}
+
+/** Experimental hub background, static linear gradient */
+@Composable
+private fun BoxScope.StaticLinearGradient() {
+ val colors = LocalAndroidColorScheme.current
+ Box(
+ Modifier.matchParentSize()
+ .background(
+ Brush.linearGradient(colors = listOf(colors.primary, colors.primaryContainer)),
+ )
+ )
+ BackgroundTopScrim()
+}
+
+/** Experimental hub background, animated linear gradient */
+@Composable
+private fun BoxScope.AnimatedLinearGradient() {
+ val colors = LocalAndroidColorScheme.current
+ Box(
+ Modifier.matchParentSize()
+ .animatedGradientBackground(colors = listOf(colors.primary, colors.primaryContainer))
+ )
+ BackgroundTopScrim()
+}
+
+/** Scrim placed on top of the background in order to dim/bright colors */
+@Composable
+private fun BoxScope.BackgroundTopScrim() {
+ val darkTheme = isSystemInDarkTheme()
+ val scrimOnTopColor = if (darkTheme) Color.Black else Color.White
+ Box(Modifier.matchParentSize().alpha(0.34f).background(scrimOnTopColor))
+}
+
+/** Modifier which sets the background of a composable to an animated gradient */
+@Composable
+private fun Modifier.animatedGradientBackground(colors: List<Color>): Modifier = composed {
+ var size by remember { mutableStateOf(IntSize.Zero) }
+ val transition = rememberInfiniteTransition(label = "scrim background")
+ val startOffsetX by
+ transition.animateFloat(
+ initialValue = -size.width.toFloat(),
+ targetValue = size.width.toFloat(),
+ animationSpec =
+ infiniteRepeatable(
+ animation = tween(durationMillis = 5_000, easing = LinearEasing),
+ repeatMode = RepeatMode.Reverse,
+ ),
+ label = "scrim start offset"
+ )
+ background(
+ brush =
+ Brush.linearGradient(
+ colors = colors,
+ start = Offset(startOffsetX, 0f),
+ end = Offset(startOffsetX + size.width.toFloat(), size.height.toFloat()),
+ )
+ )
+ .onGloballyPositioned { size = it.size }
+}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
index 1f81245..e9633c2 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
@@ -148,9 +148,9 @@
val swipes = computeSwipes(fromScene, startedPosition, pointersDown)
val result =
swipes.findUserActionResult(fromScene, overSlop, true)
- // As we were unable to locate a valid target scene, the initial SwipeTransition
- // cannot be defined. Consequently, a simple NoOp Controller will be returned.
- ?: return NoOpDragController
+ // As we were unable to locate a valid target scene, the initial SwipeTransition
+ // cannot be defined. Consequently, a simple NoOp Controller will be returned.
+ ?: return NoOpDragController
return updateDragController(
swipes = swipes,
@@ -521,6 +521,7 @@
}
return SwipeTransition(
+ layoutImpl = layoutImpl,
layoutState = layoutState,
coroutineScope = coroutineScope,
key = result.transitionKey,
@@ -534,6 +535,7 @@
private fun SwipeTransition(old: SwipeTransition): SwipeTransition {
return SwipeTransition(
+ layoutImpl = old.layoutImpl,
layoutState = old.layoutState,
coroutineScope = old.coroutineScope,
key = old.key,
@@ -550,6 +552,7 @@
}
private class SwipeTransition(
+ val layoutImpl: SceneTransitionLayoutImpl,
val layoutState: BaseSceneTransitionLayoutState,
val coroutineScope: CoroutineScope,
val key: TransitionKey?,
@@ -607,6 +610,12 @@
override val overscrollScope: OverscrollScope =
object : OverscrollScope {
+ override val density: Float
+ get() = layoutImpl.density.density
+
+ override val fontScale: Float
+ get() = layoutImpl.density.fontScale
+
override val absoluteDistance: Float
get() = distance().absoluteValue
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
index a4682ff..465a410 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
@@ -20,6 +20,7 @@
import androidx.compose.animation.core.SpringSpec
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.TransitionState.HasOverscrollProperties.Companion.DistanceUnspecified
@@ -192,7 +193,7 @@
)
}
-interface OverscrollScope {
+interface OverscrollScope : Density {
/**
* Return the absolute distance between fromScene and toScene, if available, otherwise
* [DistanceUnspecified].
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
index 3a806a4..25ea2ee 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
@@ -30,6 +30,7 @@
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.testTag
+import androidx.compose.ui.test.assertPositionInRootIsEqualTo
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performTouchInput
@@ -594,4 +595,43 @@
assertThat(transition).hasToScene(SceneB)
assertThat(transition).hasProgress(0.5f, tolerance = 0.01f)
}
+
+ @Test
+ fun overscrollScopeExtendsDensity() {
+ val swipeDistance = 100.dp
+ val state =
+ rule.runOnUiThread {
+ MutableSceneTransitionLayoutState(
+ SceneA,
+ transitions {
+ from(SceneA, to = SceneB) { distance = FixedDistance(swipeDistance) }
+
+ overscroll(SceneB, Orientation.Vertical) {
+ translate(TestElements.Foo, x = { 20.dp.toPx() }, y = { 30.dp.toPx() })
+ }
+ }
+ )
+ }
+ val layoutSize = 200.dp
+ var touchSlop = 0f
+ rule.setContent {
+ touchSlop = LocalViewConfiguration.current.touchSlop
+ SceneTransitionLayout(state, Modifier.size(layoutSize)) {
+ scene(SceneA, userActions = mapOf(Swipe.Down to SceneB)) {
+ Box(Modifier.fillMaxSize())
+ }
+ scene(SceneB) { Box(Modifier.element(TestElements.Foo).fillMaxSize()) }
+ }
+ }
+
+ // Swipe down by twice the swipe distance so that we are at 100% overscrolling on scene B.
+ rule.onRoot().performTouchInput {
+ val middle = (layoutSize / 2).toPx()
+ down(Offset(middle, middle))
+ moveBy(Offset(0f, touchSlop + (swipeDistance * 2).toPx()), delayMillis = 1_000)
+ }
+
+ // Foo should be translated by (20dp, 30dp).
+ rule.onNode(isElement(TestElements.Foo)).assertPositionInRootIsEqualTo(20.dp, 30.dp)
+ }
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/Transition.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/Transition.kt
index a609be4..e6fa69d 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/Transition.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/Transition.kt
@@ -41,8 +41,10 @@
return object : TransitionState.Transition(from, to), TransitionState.HasOverscrollProperties {
override val currentScene: SceneKey
get() = current()
+
override val progress: Float
get() = progress()
+
override val progressVelocity: Float
get() = progressVelocity()
@@ -53,6 +55,8 @@
override val orientation: Orientation = orientation
override val overscrollScope: OverscrollScope =
object : OverscrollScope {
+ override val density: Float = 1f
+ override val fontScale: Float = 1f
override val absoluteDistance = 0f
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt
index 89c5495..fb2b33d 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt
@@ -34,6 +34,8 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.broadcastDispatcher
import com.android.systemui.communal.data.model.DisabledReason
+import com.android.systemui.communal.data.repository.CommunalSettingsRepositoryImpl.Companion.GLANCEABLE_HUB_BACKGROUND_SETTING
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.fakeFeatureFlagsClassic
@@ -43,6 +45,7 @@
import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.settings.fakeSettings
import com.google.common.truth.Truth.assertThat
+import com.google.common.truth.Truth.assertWithMessage
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
@@ -216,6 +219,32 @@
)
}
+ @Test
+ fun backgroundType_defaultValue() =
+ testScope.runTest {
+ val backgroundType by collectLastValue(underTest.getBackground(PRIMARY_USER))
+ assertThat(backgroundType).isEqualTo(CommunalBackgroundType.DEFAULT)
+ }
+
+ @Test
+ fun backgroundType_verifyAllValues() =
+ testScope.runTest {
+ val backgroundType by collectLastValue(underTest.getBackground(PRIMARY_USER))
+ for (type in CommunalBackgroundType.entries) {
+ kosmos.fakeSettings.putIntForUser(
+ GLANCEABLE_HUB_BACKGROUND_SETTING,
+ type.value,
+ PRIMARY_USER.id
+ )
+ assertWithMessage(
+ "Expected $type when $GLANCEABLE_HUB_BACKGROUND_SETTING is set to" +
+ " ${type.value} but was $backgroundType"
+ )
+ .that(backgroundType)
+ .isEqualTo(type)
+ }
+ }
+
private fun setKeyguardFeaturesDisabled(user: UserInfo, disabledFlags: Int) {
whenever(kosmos.devicePolicyManager.getKeyguardDisabledFeatures(nullable(), eq(user.id)))
.thenReturn(disabledFlags)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt
index a1bad39..9dcea82 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt
@@ -37,6 +37,7 @@
import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
+import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.domain.interactor.communalTutorialInteractor
import com.android.systemui.communal.domain.model.CommunalContentModel
import com.android.systemui.communal.shared.model.CommunalScenes
@@ -152,6 +153,7 @@
kosmos.keyguardInteractor,
kosmos.communalSceneInteractor,
kosmos.communalInteractor,
+ kosmos.communalSettingsInteractor,
kosmos.communalTutorialInteractor,
kosmos.shadeInteractor,
mediaHost,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt
index 5068f68..78a1167 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt
@@ -350,7 +350,7 @@
}
@Test
- fun quickAffordance_doNotSendUpdatesWhileShadeExpandingAndStillHidden() =
+ fun quickAffordance_updateOncePerShadeExpansion() =
testScope.runTest {
val shadeExpansion = MutableStateFlow(0f)
whenever(shadeInteractor.anyExpansion).thenReturn(shadeExpansion)
@@ -365,9 +365,7 @@
shadeExpansion.value = i / 10f
}
- assertThat(collectedValue[0])
- .isInstanceOf(KeyguardQuickAffordanceModel.Hidden::class.java)
- assertThat(collectedValue.size).isEqualTo(initialSize)
+ assertThat(collectedValue.size).isEqualTo(initialSize + 1)
}
@Test
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index 47e4b49..f688d4f 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -308,14 +308,14 @@
mStatusArea = mView.findViewById(R.id.keyguard_status_area);
mBgExecutor.execute(() -> {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK,
false, /* notifyForDescendants */
mDoubleLineClockObserver,
UserHandle.USER_ALL
);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED,
false, /* notifyForDescendants */
mShowWeatherObserver,
@@ -372,8 +372,8 @@
setClock(null);
mBgExecutor.execute(() -> {
- mSecureSettings.unregisterContentObserver(mDoubleLineClockObserver);
- mSecureSettings.unregisterContentObserver(mShowWeatherObserver);
+ mSecureSettings.unregisterContentObserverSync(mDoubleLineClockObserver);
+ mSecureSettings.unregisterContentObserverSync(mShowWeatherObserver);
});
mKeyguardUnlockAnimationController.removeKeyguardUnlockAnimationListener(
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java
index ca24ccb..f2a68a8 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java
@@ -319,7 +319,7 @@
}
// Unregister observer before removing view
- mSecureSettings.unregisterContentObserver(mMagnificationCapabilityObserver);
+ mSecureSettings.unregisterContentObserverSync(mMagnificationCapabilityObserver);
mWindowManager.removeView(mSettingView);
mIsVisible = false;
if (resetPosition) {
@@ -380,7 +380,7 @@
mWindowManager.addView(mSettingView, mParams);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY,
mMagnificationCapabilityObserver,
UserHandle.USER_CURRENT);
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java
index eb840f1..ffb5f3d 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java
@@ -240,26 +240,26 @@
}
void registerObserversAndCallbacks() {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS),
/* notifyForDescendants */ false, mMenuTargetFeaturesContentObserver,
UserHandle.USER_CURRENT);
if (!com.android.systemui.Flags.floatingMenuNarrowTargetContentObserver()) {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(ENABLED_ACCESSIBILITY_SERVICES),
/* notifyForDescendants */ false,
mMenuTargetFeaturesContentObserver,
UserHandle.USER_CURRENT);
}
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE),
/* notifyForDescendants */ false, mMenuSizeContentObserver,
UserHandle.USER_CURRENT);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(ACCESSIBILITY_FLOATING_MENU_FADE_ENABLED),
/* notifyForDescendants */ false, mMenuFadeOutContentObserver,
UserHandle.USER_CURRENT);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(ACCESSIBILITY_FLOATING_MENU_OPACITY),
/* notifyForDescendants */ false, mMenuFadeOutContentObserver,
UserHandle.USER_CURRENT);
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogDelegate.kt
index 91bc0c1..eaf541d 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialogDelegate.kt
@@ -29,12 +29,12 @@
import android.widget.TextView
import androidx.annotation.MainThread
import androidx.annotation.WorkerThread
-import com.android.systemui.res.R
import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView
import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView.OnSeekBarWithIconButtonsChangeListener
import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView.OnSeekBarWithIconButtonsChangeListener.ControlUnitType
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
+import com.android.systemui.res.R
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.util.concurrency.DelayableExecutor
@@ -46,7 +46,9 @@
import kotlin.math.roundToInt
/** The Dialog that contains a seekbar for changing the font size. */
-class FontScalingDialogDelegate @Inject constructor(
+class FontScalingDialogDelegate
+@Inject
+constructor(
private val context: Context,
private val systemUIDialogFactory: SystemUIDialog.Factory,
private val layoutInflater: LayoutInflater,
@@ -84,9 +86,9 @@
dialog.setTitle(R.string.font_scaling_dialog_title)
dialog.setView(layoutInflater.inflate(R.layout.font_scaling_dialog, null))
dialog.setPositiveButton(
- R.string.quick_settings_done,
- /* onClick = */ null,
- /* dismissOnClick = */ true
+ R.string.quick_settings_done,
+ /* onClick = */ null,
+ /* dismissOnClick = */ true
)
}
@@ -142,7 +144,7 @@
}
)
doneButton.setOnClickListener { dialog.dismiss() }
- systemSettings.registerContentObserver(Settings.System.FONT_SCALE, fontSizeObserver)
+ systemSettings.registerContentObserverSync(Settings.System.FONT_SCALE, fontSizeObserver)
}
/**
@@ -165,7 +167,7 @@
override fun onStop(dialog: SystemUIDialog) {
cancelUpdateFontScaleRunnable?.run()
cancelUpdateFontScaleRunnable = null
- systemSettings.unregisterContentObserver(fontSizeObserver)
+ systemSettings.unregisterContentObserverSync(fontSizeObserver)
}
@MainThread
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FaceUserSettingsRepository.kt b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FaceUserSettingsRepository.kt
index 68c4a10..2970890 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FaceUserSettingsRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FaceUserSettingsRepository.kt
@@ -75,7 +75,7 @@
) {
fun fetch(): Boolean = getIntForUser(key, if (defaultValue) 1 else 0, userId) > 0
- registerContentObserverForUser(
+ registerContentObserverForUserSync(
key,
false /* notifyForDescendants */,
object : ContentObserver(handler) {
diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt
index 88cb64c..1c47e50 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt
@@ -30,6 +30,7 @@
import com.android.systemui.communal.data.model.DisabledReason.DISABLED_REASON_FLAG
import com.android.systemui.communal.data.model.DisabledReason.DISABLED_REASON_INVALID_USER
import com.android.systemui.communal.data.model.DisabledReason.DISABLED_REASON_USER_SETTING
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.flags.FeatureFlagsClassic
@@ -59,6 +60,9 @@
/** Keyguard widgets enabled state by Device Policy Manager for the specified user. */
fun getAllowedByDevicePolicy(user: UserInfo): Flow<Boolean>
+
+ /** The type of background to use for the hub. Used to experiment with different backgrounds. */
+ fun getBackground(user: UserInfo): Flow<CommunalBackgroundType>
}
@SysUISingleton
@@ -126,6 +130,21 @@
.emitOnStart()
.map { devicePolicyManager.areKeyguardWidgetsAllowed(user.id) }
+ override fun getBackground(user: UserInfo): Flow<CommunalBackgroundType> =
+ secureSettings
+ .observerFlow(userId = user.id, names = arrayOf(GLANCEABLE_HUB_BACKGROUND_SETTING))
+ .emitOnStart()
+ .map {
+ val intType =
+ secureSettings.getIntForUser(
+ GLANCEABLE_HUB_BACKGROUND_SETTING,
+ CommunalBackgroundType.DEFAULT.value,
+ user.id
+ )
+ CommunalBackgroundType.entries.find { type -> type.value == intType }
+ ?: CommunalBackgroundType.DEFAULT
+ }
+
private fun getEnabledByUser(user: UserInfo): Flow<Boolean> =
secureSettings
.observerFlow(userId = user.id, names = arrayOf(Settings.Secure.GLANCEABLE_HUB_ENABLED))
@@ -141,6 +160,7 @@
companion object {
const val GLANCEABLE_HUB_CONTENT_SETTING = "glanceable_hub_content_setting"
+ const val GLANCEABLE_HUB_BACKGROUND_SETTING = "glanceable_hub_background"
private const val ENABLED_SETTING_DEFAULT = 1
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt
index 3e5126a..f043d58 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt
@@ -21,6 +21,7 @@
import com.android.systemui.communal.data.model.CommunalEnabledState
import com.android.systemui.communal.data.model.CommunalWidgetCategories
import com.android.systemui.communal.data.repository.CommunalSettingsRepository
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.log.dagger.CommunalTableLog
@@ -30,6 +31,7 @@
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import java.util.concurrent.Executor
import javax.inject.Inject
+import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
@@ -38,6 +40,7 @@
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
+import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
@@ -47,6 +50,7 @@
@Inject
constructor(
@Background private val bgScope: CoroutineScope,
+ @Background private val bgDispatcher: CoroutineDispatcher,
@Background private val bgExecutor: Executor,
private val repository: CommunalSettingsRepository,
userInteractor: SelectedUserInteractor,
@@ -78,6 +82,12 @@
initialValue = CommunalWidgetCategories.defaultCategories
)
+ /** The type of background to use for the hub. Used to experiment with different backgrounds */
+ val communalBackground: Flow<CommunalBackgroundType> =
+ userInteractor.selectedUserInfo
+ .flatMapLatest { user -> repository.getBackground(user) }
+ .flowOn(bgDispatcher)
+
private val workProfileUserInfoCallbackFlow: Flow<UserInfo?> = conflatedCallbackFlow {
fun send(profiles: List<UserInfo>) {
trySend(profiles.find { it.isManagedProfile })
diff --git a/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalBackgroundType.kt b/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalBackgroundType.kt
new file mode 100644
index 0000000..8b816db
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/communal/shared/model/CommunalBackgroundType.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2024 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.communal.shared.model
+
+/** Models the types of background that can be shown on the hub. */
+enum class CommunalBackgroundType(val value: Int) {
+ DEFAULT(0),
+ STATIC_GRADIENT(1),
+ ANIMATED(2),
+}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt
index ce69ee8..3e00b04 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt
@@ -21,8 +21,10 @@
import android.view.accessibility.AccessibilityNodeInfo
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
+import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor
import com.android.systemui.communal.domain.interactor.CommunalTutorialInteractor
import com.android.systemui.communal.domain.model.CommunalContentModel
+import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
@@ -70,6 +72,7 @@
keyguardInteractor: KeyguardInteractor,
communalSceneInteractor: CommunalSceneInteractor,
private val communalInteractor: CommunalInteractor,
+ private val communalSettingsInteractor: CommunalSettingsInteractor,
tutorialInteractor: CommunalTutorialInteractor,
private val shadeInteractor: ShadeInteractor,
@Named(MediaModule.COMMUNAL_HUB) mediaHost: MediaHost,
@@ -284,6 +287,10 @@
*/
val showGestureIndicator: Flow<Boolean> = not(keyguardInteractor.isDreaming)
+ /** The type of background to use for the hub. */
+ val communalBackground: Flow<CommunalBackgroundType> =
+ communalSettingsInteractor.communalBackground
+
companion object {
const val POPUP_AUTO_HIDE_TIMEOUT_MS = 12000L
}
@@ -291,5 +298,6 @@
sealed class PopupType {
object CtaTile : PopupType()
+
object CustomizeWidgetButton : PopupType()
}
diff --git a/packages/SystemUI/src/com/android/systemui/complication/ComplicationTypesUpdater.java b/packages/SystemUI/src/com/android/systemui/complication/ComplicationTypesUpdater.java
index 0bdc7f1..84807fb 100644
--- a/packages/SystemUI/src/com/android/systemui/complication/ComplicationTypesUpdater.java
+++ b/packages/SystemUI/src/com/android/systemui/complication/ComplicationTypesUpdater.java
@@ -69,15 +69,15 @@
}
};
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.SCREENSAVER_COMPLICATIONS_ENABLED,
settingsObserver,
UserHandle.myUserId());
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.SCREENSAVER_HOME_CONTROLS_ENABLED,
settingsObserver,
UserHandle.myUserId());
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.LOCKSCREEN_SHOW_CONTROLS,
settingsObserver,
UserHandle.myUserId());
diff --git a/packages/SystemUI/src/com/android/systemui/dock/DockManagerExtensions.kt b/packages/SystemUI/src/com/android/systemui/dock/DockManagerExtensions.kt
index 1bbdfcd..4dbb32d 100644
--- a/packages/SystemUI/src/com/android/systemui/dock/DockManagerExtensions.kt
+++ b/packages/SystemUI/src/com/android/systemui/dock/DockManagerExtensions.kt
@@ -19,18 +19,16 @@
import com.android.systemui.common.coroutine.ConflatedCallbackFlow
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.distinctUntilChanged
/**
- * Retrieves whether or not the device is docked according to DockManager. Emits a starting value of
- * isDocked.
+ * Retrieves whether or not the device is docked according to DockManager. Emits a starting value
+ * of isDocked.
*/
fun DockManager.retrieveIsDocked(): Flow<Boolean> =
ConflatedCallbackFlow.conflatedCallbackFlow {
- val callback = DockManager.DockEventListener { trySend(isDocked) }
- addListener(callback)
- trySend(isDocked)
+ val callback = DockManager.DockEventListener { trySend(isDocked) }
+ addListener(callback)
+ trySend(isDocked)
- awaitClose { removeListener(callback) }
- }
- .distinctUntilChanged()
+ awaitClose { removeListener(callback) }
+ }
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java b/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java
index 3194942..7ae8409 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java
@@ -426,7 +426,7 @@
}
if (!anyListening) {
- mSecureSettings.unregisterContentObserver(mSettingsObserver);
+ mSecureSettings.unregisterContentObserverSync(mSettingsObserver);
} else if (!mSettingRegistered) {
for (TriggerSensor s : mTriggerSensors) {
s.registerSettingsObserver(mSettingsObserver);
@@ -750,7 +750,7 @@
public void registerSettingsObserver(ContentObserver settingsObserver) {
if (mConfigured && !TextUtils.isEmpty(mSetting)) {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSetting, mSettingsObserver, UserHandle.USER_ALL);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
index 49be03c..1e4fb4f 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
@@ -428,7 +428,7 @@
// get notified of phone state changes
mTelephonyListenerManager.addServiceStateListener(mPhoneStateListener);
- mGlobalSettings.registerContentObserver(
+ mGlobalSettings.registerContentObserverSync(
Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON), true,
mAirplaneModeObserver);
mHasVibrator = vibrator.hasVibrator();
@@ -453,7 +453,7 @@
public void destroy() {
mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
mTelephonyListenerManager.removeServiceStateListener(mPhoneStateListener);
- mGlobalSettings.unregisterContentObserver(mAirplaneModeObserver);
+ mGlobalSettings.unregisterContentObserverSync(mAirplaneModeObserver);
mConfigurationController.removeCallback(this);
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt
index f488d3b..8ec460a 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt
@@ -265,7 +265,7 @@
state: TransitionState
) {
if (updateTransitionId != transitionId) {
- Log.w(TAG, "Attempting to update with old/invalid transitionId: $transitionId")
+ Log.wtf(TAG, "Attempting to update with old/invalid transitionId: $transitionId")
return
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt
index 8ffa4bb..ccce3bf 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt
@@ -105,35 +105,33 @@
}
return combine(
- quickAffordanceAlwaysVisible(position),
- keyguardInteractor.isDozing,
- if (SceneContainerFlag.isEnabled) {
- sceneInteractor
- .get()
- .transitionState
- .map {
- when (it) {
- is ObservableTransitionState.Idle ->
- it.currentScene == Scenes.Lockscreen
- is ObservableTransitionState.Transition ->
- it.fromScene == Scenes.Lockscreen ||
- it.toScene == Scenes.Lockscreen
- }
+ quickAffordanceAlwaysVisible(position),
+ keyguardInteractor.isDozing,
+ if (SceneContainerFlag.isEnabled) {
+ sceneInteractor
+ .get()
+ .transitionState
+ .map {
+ when (it) {
+ is ObservableTransitionState.Idle ->
+ it.currentScene == Scenes.Lockscreen
+ is ObservableTransitionState.Transition ->
+ it.fromScene == Scenes.Lockscreen || it.toScene == Scenes.Lockscreen
}
- .distinctUntilChanged()
- } else {
- keyguardInteractor.isKeyguardShowing
- },
- shadeInteractor.anyExpansion.map { it < 1.0f }.distinctUntilChanged(),
- biometricSettingsRepository.isCurrentUserInLockdown,
- ) { affordance, isDozing, isKeyguardShowing, isQuickSettingsVisible, isUserInLockdown ->
- if (!isDozing && isKeyguardShowing && isQuickSettingsVisible && !isUserInLockdown) {
- affordance
- } else {
- KeyguardQuickAffordanceModel.Hidden
- }
+ }
+ .distinctUntilChanged()
+ } else {
+ keyguardInteractor.isKeyguardShowing
+ },
+ shadeInteractor.anyExpansion.map { it < 1.0f }.distinctUntilChanged(),
+ biometricSettingsRepository.isCurrentUserInLockdown,
+ ) { affordance, isDozing, isKeyguardShowing, isQuickSettingsVisible, isUserInLockdown ->
+ if (!isDozing && isKeyguardShowing && isQuickSettingsVisible && !isUserInLockdown) {
+ affordance
+ } else {
+ KeyguardQuickAffordanceModel.Hidden
}
- .distinctUntilChanged()
+ }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt
index 807c322..23c2491 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt
@@ -65,7 +65,7 @@
val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
val disposableHandle =
view.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.CREATED) {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
launch("$TAG#viewModel.alpha") {
// Do not independently apply alpha, as [KeyguardRootViewModel] should work
// for this and all its children
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt
index 1cf009d..b9a79dc 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt
@@ -30,7 +30,6 @@
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
-import com.android.app.tracing.coroutines.launch
import com.android.settingslib.Utils
import com.android.systemui.animation.Expandable
import com.android.systemui.animation.view.LaunchableImageView
@@ -81,8 +80,8 @@
val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
val disposableHandle =
view.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.CREATED) {
- launch("$TAG#viewModel.collect") {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ launch {
viewModel.collect { buttonModel ->
updateButton(
view = button,
@@ -94,7 +93,7 @@
}
}
- launch("$TAG#updateButtonAlpha") {
+ launch {
updateButtonAlpha(
view = button,
viewModel = viewModel,
@@ -102,7 +101,7 @@
)
}
- launch("$TAG#configurationBasedDimensions") {
+ launch {
configurationBasedDimensions.collect { dimensions ->
button.updateLayoutParams<ViewGroup.LayoutParams> {
width = dimensions.buttonSizePx.width
@@ -324,6 +323,4 @@
private data class ConfigurationBasedDimensions(
val buttonSizePx: Size,
)
-
- private const val TAG = "KeyguardQuickAffordanceViewBinder"
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModel.kt
index 244d842..c4383fc 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModel.kt
@@ -18,7 +18,6 @@
package com.android.systemui.keyguard.ui.viewmodel
import androidx.annotation.VisibleForTesting
-import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
@@ -29,23 +28,19 @@
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots
import javax.inject.Inject
-import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
-import kotlinx.coroutines.flow.stateIn
@OptIn(ExperimentalCoroutinesApi::class)
class KeyguardQuickAffordancesCombinedViewModel
@Inject
constructor(
- @Application applicationScope: CoroutineScope,
private val quickAffordanceInteractor: KeyguardQuickAffordanceInteractor,
private val keyguardInteractor: KeyguardInteractor,
shadeInteractor: ShadeInteractor,
@@ -89,20 +84,15 @@
/** The only time the expansion is important is while lockscreen is actively displayed */
private val shadeExpansionAlpha =
combine(
- showingLockscreen,
- shadeInteractor.anyExpansion,
- ) { showingLockscreen, expansion ->
- if (showingLockscreen) {
- 1 - expansion
- } else {
- 0f
- }
+ showingLockscreen,
+ shadeInteractor.anyExpansion,
+ ) { showingLockscreen, expansion ->
+ if (showingLockscreen) {
+ 1 - expansion
+ } else {
+ 0f
}
- .stateIn(
- scope = applicationScope,
- started = SharingStarted.Lazily,
- initialValue = 0f,
- )
+ }
/**
* ID of the slot that's currently selected in the preview that renders exclusively in the
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt
index 7bacdeb..edead51 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt
@@ -397,7 +397,7 @@
listenForLockscreenSettingChanges(applicationScope)
// Notifies all active players about animation scale changes.
- globalSettings.registerContentObserver(
+ globalSettings.registerContentObserverSync(
Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE),
animationScaleObserver
)
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
index 6589038..601d563 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaHierarchyManager.kt
@@ -167,6 +167,7 @@
private var targetBounds: Rect = Rect()
private val mediaFrame
get() = mediaCarouselController.mediaFrame
+
private var statusbarState: Int = statusBarStateController.state
private var animator =
ValueAnimator.ofFloat(0.0f, 1.0f).apply {
@@ -600,7 +601,7 @@
}
}
}
- secureSettings.registerContentObserverForUser(
+ secureSettings.registerContentObserverForUserSync(
Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN,
settingsObserver,
UserHandle.USER_ALL
diff --git a/packages/SystemUI/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerController.java b/packages/SystemUI/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerController.java
index 2d460a0..765b45b 100644
--- a/packages/SystemUI/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerController.java
+++ b/packages/SystemUI/src/com/android/systemui/qrcodescanner/controller/QRCodeScannerController.java
@@ -341,7 +341,7 @@
}
mQRCodeScannerPreferenceObserver.forEach((key, value) -> {
- mSecureSettings.unregisterContentObserver(value);
+ mSecureSettings.unregisterContentObserverSync(value);
});
// Reset cached values to default as we are no longer listening
@@ -418,7 +418,7 @@
});
}
});
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(LOCK_SCREEN_SHOW_QR_CODE_SCANNER), false,
mQRCodeScannerPreferenceObserver.get(userId), userId);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt b/packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt
index 2fafba1..e4bafcd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/AutoAddTracker.kt
@@ -52,7 +52,9 @@
*
* It also handles restore gracefully.
*/
-class AutoAddTracker @VisibleForTesting constructor(
+class AutoAddTracker
+@VisibleForTesting
+constructor(
private val secureSettings: SecureSettings,
private val broadcastDispatcher: BroadcastDispatcher,
private val qsHost: QSHost,
@@ -66,39 +68,43 @@
private val FILTER = IntentFilter(Intent.ACTION_SETTING_RESTORED)
}
- @GuardedBy("autoAdded")
- private val autoAdded = ArraySet<String>()
+ @GuardedBy("autoAdded") private val autoAdded = ArraySet<String>()
private var restoredTiles: Map<String, AutoTile>? = null
override val currentUserId: Int
get() = userId
- private val contentObserver = object : ContentObserver(mainHandler) {
- override fun onChange(
- selfChange: Boolean,
- uris: Collection<Uri>,
- flags: Int,
- _userId: Int
- ) {
- if (_userId != userId) {
- // Ignore changes outside of our user. We'll load the correct value on user change
- return
+ private val contentObserver =
+ object : ContentObserver(mainHandler) {
+ override fun onChange(
+ selfChange: Boolean,
+ uris: Collection<Uri>,
+ flags: Int,
+ _userId: Int
+ ) {
+ if (_userId != userId) {
+ // Ignore changes outside of our user. We'll load the correct value on user
+ // change
+ return
+ }
+ loadTiles()
}
- loadTiles()
}
- }
- private val restoreReceiver = object : BroadcastReceiver() {
- override fun onReceive(context: Context, intent: Intent) {
- if (intent.action != Intent.ACTION_SETTING_RESTORED) return
- processRestoreIntent(intent)
+ private val restoreReceiver =
+ object : BroadcastReceiver() {
+ override fun onReceive(context: Context, intent: Intent) {
+ if (intent.action != Intent.ACTION_SETTING_RESTORED) return
+ processRestoreIntent(intent)
+ }
}
- }
private fun processRestoreIntent(intent: Intent) {
when (intent.getStringExtra(Intent.EXTRA_SETTING_NAME)) {
Settings.Secure.QS_TILES -> {
- restoredTiles = intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)
+ restoredTiles =
+ intent
+ .getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)
?.split(DELIMITER)
?.mapIndexed(::AutoTile)
?.associateBy(AutoTile::tileType)
@@ -109,13 +115,11 @@
}
Settings.Secure.QS_AUTO_ADDED_TILES -> {
restoredTiles?.let { restoredTiles ->
- val restoredAutoAdded = intent
- .getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)
- ?.split(DELIMITER)
+ val restoredAutoAdded =
+ intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE)?.split(DELIMITER)
?: emptyList()
- val autoAddedBeforeRestore = intent
- .getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE)
- ?.split(DELIMITER)
+ val autoAddedBeforeRestore =
+ intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE)?.split(DELIMITER)
?: emptyList()
val tilesToRemove = restoredAutoAdded.filter { it !in restoredTiles }
@@ -123,50 +127,51 @@
Log.d(TAG, "Removing tiles: $tilesToRemove")
qsHost.removeTiles(tilesToRemove)
}
- val tiles = synchronized(autoAdded) {
- autoAdded.clear()
- autoAdded.addAll(restoredAutoAdded + autoAddedBeforeRestore)
- getTilesFromListLocked()
- }
+ val tiles =
+ synchronized(autoAdded) {
+ autoAdded.clear()
+ autoAdded.addAll(restoredAutoAdded + autoAddedBeforeRestore)
+ getTilesFromListLocked()
+ }
saveTiles(tiles)
- } ?: run {
- Log.w(TAG, "${Settings.Secure.QS_AUTO_ADDED_TILES} restored before " +
- "${Settings.Secure.QS_TILES} for user $userId")
}
+ ?: run {
+ Log.w(
+ TAG,
+ "${Settings.Secure.QS_AUTO_ADDED_TILES} restored before " +
+ "${Settings.Secure.QS_TILES} for user $userId"
+ )
+ }
}
else -> {} // Do nothing for other Settings
}
}
- /**
- * Init method must be called after construction to start listening
- */
+ /** Init method must be called after construction to start listening */
fun initialize() {
dumpManager.registerDumpable(TAG, this)
loadTiles()
- secureSettings.registerContentObserverForUser(
- secureSettings.getUriFor(Settings.Secure.QS_AUTO_ADDED_TILES),
- contentObserver,
- UserHandle.USER_ALL
+ secureSettings.registerContentObserverForUserSync(
+ secureSettings.getUriFor(Settings.Secure.QS_AUTO_ADDED_TILES),
+ contentObserver,
+ UserHandle.USER_ALL
)
registerBroadcastReceiver()
}
- /**
- * Unregister listeners, receivers and observers
- */
+ /** Unregister listeners, receivers and observers */
fun destroy() {
dumpManager.unregisterDumpable(TAG)
- secureSettings.unregisterContentObserver(contentObserver)
+ secureSettings.unregisterContentObserverSync(contentObserver)
unregisterBroadcastReceiver()
}
private fun registerBroadcastReceiver() {
broadcastDispatcher.registerReceiver(
- restoreReceiver,
- FILTER,
- backgroundExecutor,
- UserHandle.of(userId)
+ restoreReceiver,
+ FILTER,
+ backgroundExecutor,
+ UserHandle.of(userId)
)
}
@@ -186,13 +191,9 @@
fun getRestoredTilePosition(tile: String): Int =
restoredTiles?.get(tile)?.index ?: QSHost.POSITION_AT_END
- /**
- * Returns `true` if the tile has been auto-added before
- */
+ /** Returns `true` if the tile has been auto-added before */
fun isAdded(tile: String): Boolean {
- return synchronized(autoAdded) {
- tile in autoAdded
- }
+ return synchronized(autoAdded) { tile in autoAdded }
}
/**
@@ -201,13 +202,14 @@
* From here on, [isAdded] will return true for that tile.
*/
fun setTileAdded(tile: String) {
- val tiles = synchronized(autoAdded) {
- if (autoAdded.add(tile)) {
- getTilesFromListLocked()
- } else {
- null
+ val tiles =
+ synchronized(autoAdded) {
+ if (autoAdded.add(tile)) {
+ getTilesFromListLocked()
+ } else {
+ null
+ }
}
- }
tiles?.let { saveTiles(it) }
}
@@ -217,13 +219,14 @@
* This allows for this tile to be auto-added again in the future.
*/
fun setTileRemoved(tile: String) {
- val tiles = synchronized(autoAdded) {
- if (autoAdded.remove(tile)) {
- getTilesFromListLocked()
- } else {
- null
+ val tiles =
+ synchronized(autoAdded) {
+ if (autoAdded.remove(tile)) {
+ getTilesFromListLocked()
+ } else {
+ null
+ }
}
- }
tiles?.let { saveTiles(it) }
}
@@ -233,12 +236,12 @@
private fun saveTiles(tiles: String) {
secureSettings.putStringForUser(
- Settings.Secure.QS_AUTO_ADDED_TILES,
- tiles,
- /* tag */ null,
- /* makeDefault */ false,
- userId,
- /* overrideableByRestore */ true
+ Settings.Secure.QS_AUTO_ADDED_TILES,
+ tiles,
+ /* tag */ null,
+ /* makeDefault */ false,
+ userId,
+ /* overrideableByRestore */ true
)
}
@@ -261,7 +264,9 @@
}
@SysUISingleton
- class Builder @Inject constructor(
+ class Builder
+ @Inject
+ constructor(
private val secureSettings: SecureSettings,
private val broadcastDispatcher: BroadcastDispatcher,
private val qsHost: QSHost,
@@ -278,16 +283,16 @@
fun build(): AutoAddTracker {
return AutoAddTracker(
- secureSettings,
- broadcastDispatcher,
- qsHost,
- dumpManager,
- handler,
- executor,
- userId
+ secureSettings,
+ broadcastDispatcher,
+ qsHost,
+ dumpManager,
+ handler,
+ executor,
+ userId
)
}
}
private data class AutoTile(val index: Int, val tileType: String)
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/ReduceBrightColorsControllerImpl.java b/packages/SystemUI/src/com/android/systemui/qs/ReduceBrightColorsControllerImpl.java
index 4fc6609..846d63f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/ReduceBrightColorsControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/ReduceBrightColorsControllerImpl.java
@@ -77,8 +77,8 @@
public void onUserChanged(int newUser, Context userContext) {
synchronized (mListeners) {
if (mListeners.size() > 0) {
- mSecureSettings.unregisterContentObserver(mContentObserver);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.unregisterContentObserverSync(mContentObserver);
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED,
false, mContentObserver, newUser);
}
@@ -94,7 +94,7 @@
if (!mListeners.contains(listener)) {
mListeners.add(listener);
if (mListeners.size() == 1) {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED,
false, mContentObserver, mUserTracker.getUserId());
}
@@ -106,7 +106,7 @@
public void removeCallback(@androidx.annotation.NonNull Listener listener) {
synchronized (mListeners) {
if (mListeners.remove(listener) && mListeners.size() == 0) {
- mSecureSettings.unregisterContentObserver(mContentObserver);
+ mSecureSettings.unregisterContentObserverSync(mContentObserver);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/SettingObserver.java b/packages/SystemUI/src/com/android/systemui/qs/SettingObserver.java
index eb11568..6092348 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/SettingObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/SettingObserver.java
@@ -74,10 +74,10 @@
mListening = listening;
if (listening) {
mObservedValue = getValueFromProvider();
- mSettingsProxy.registerContentObserver(
+ mSettingsProxy.registerContentObserverSync(
mSettingsProxy.getUriFor(mSettingName), false, this);
} else {
- mSettingsProxy.unregisterContentObserver(this);
+ mSettingsProxy.unregisterContentObserverSync(this);
mObservedValue = mDefaultValue;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/UserSettingObserver.java b/packages/SystemUI/src/com/android/systemui/qs/UserSettingObserver.java
index 539c2d6..1b34c33 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/UserSettingObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/UserSettingObserver.java
@@ -76,10 +76,10 @@
mListening = listening;
if (listening) {
mObservedValue = getValueFromProvider();
- mSettingsProxy.registerContentObserverForUser(
+ mSettingsProxy.registerContentObserverForUserSync(
mSettingsProxy.getUriFor(mSettingName), false, this, mUserId);
} else {
- mSettingsProxy.unregisterContentObserver(this);
+ mSettingsProxy.unregisterContentObserverSync(this);
mObservedValue = mDefaultValue;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserAutoAddRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserAutoAddRepository.kt
index d452241..9fcb0db 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserAutoAddRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserAutoAddRepository.kt
@@ -44,9 +44,8 @@
@Background private val bgDispatcher: CoroutineDispatcher,
) {
- private val changeEvents = MutableSharedFlow<ChangeAction>(
- extraBufferCapacity = CHANGES_BUFFER_SIZE
- )
+ private val changeEvents =
+ MutableSharedFlow<ChangeAction>(extraBufferCapacity = CHANGES_BUFFER_SIZE)
private lateinit var _autoAdded: StateFlow<Set<TileSpec>>
@@ -85,8 +84,8 @@
trySend(Unit)
}
}
- secureSettings.registerContentObserverForUser(SETTING, observer, userId)
- awaitClose { secureSettings.unregisterContentObserver(observer) }
+ secureSettings.registerContentObserverForUserSync(SETTING, observer, userId)
+ awaitClose { secureSettings.unregisterContentObserverSync(observer) }
}
.map { load() }
.flowOn(bgDispatcher)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt
index aca8733..1f9570a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt
@@ -98,8 +98,8 @@
trySend(Unit)
}
}
- secureSettings.registerContentObserverForUser(SETTING, observer, userId)
- awaitClose { secureSettings.unregisterContentObserver(observer) }
+ secureSettings.registerContentObserverForUserSync(SETTING, observer, userId)
+ awaitClose { secureSettings.unregisterContentObserverSync(observer) }
}
.map { loadTilesFromSettings(userId) }
.flowOn(backgroundDispatcher)
diff --git a/packages/SystemUI/src/com/android/systemui/retail/data/repository/RetailModeRepository.kt b/packages/SystemUI/src/com/android/systemui/retail/data/repository/RetailModeRepository.kt
index 3c0aa38..09fd7df 100644
--- a/packages/SystemUI/src/com/android/systemui/retail/data/repository/RetailModeRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/retail/data/repository/RetailModeRepository.kt
@@ -66,9 +66,9 @@
}
}
- globalSettings.registerContentObserver(RETAIL_MODE_SETTING, observer)
+ globalSettings.registerContentObserverSync(RETAIL_MODE_SETTING, observer)
- awaitClose { globalSettings.unregisterContentObserver(observer) }
+ awaitClose { globalSettings.unregisterContentObserverSync(observer) }
}
.onStart { emit(Unit) }
.map { globalSettings.getInt(RETAIL_MODE_SETTING, 0) != 0 }
diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java
index 37f2a21..49810762 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java
@@ -137,14 +137,14 @@
public void startObserving() {
if (!mObserving) {
mObserving = true;
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
BRIGHTNESS_MODE_URI,
false, this, UserHandle.USER_ALL);
}
}
public void stopObserving() {
- mSecureSettings.unregisterContentObserver(this);
+ mSecureSettings.unregisterContentObserverSync(this);
mObserving = false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java b/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java
index 95768e5..2dfc920 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ImmersiveModeConfirmation.java
@@ -318,10 +318,10 @@
};
// Register to listen for changes in Settings.Secure settings.
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS, mContentObserver,
UserHandle.USER_CURRENT);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.USER_SETUP_COMPLETE, mContentObserver,
UserHandle.USER_CURRENT);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt
index 4c2ef83..4c82bc1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt
@@ -37,11 +37,13 @@
import javax.inject.Inject
/**
- * A class which provides an adjustment object to the preparation coordinator which is uses
- * to ensure that notifications are reinflated when ranking-derived information changes.
+ * A class which provides an adjustment object to the preparation coordinator which is uses to
+ * ensure that notifications are reinflated when ranking-derived information changes.
*/
@SysUISingleton
-class NotifUiAdjustmentProvider @Inject constructor(
+class NotifUiAdjustmentProvider
+@Inject
+constructor(
@Main private val handler: Handler,
private val secureSettings: SecureSettings,
private val lockscreenUserManager: NotificationLockscreenUserManager,
@@ -53,14 +55,13 @@
private val dirtyListeners = ListenerSet<Runnable>()
private var isSnoozeSettingsEnabled = false
- /**
- * Update the snooze enabled value on user switch
- */
- private val userTrackerCallback = object : UserTracker.Callback {
- override fun onUserChanged(newUser: Int, userContext: Context) {
- updateSnoozeEnabled()
+ /** Update the snooze enabled value on user switch */
+ private val userTrackerCallback =
+ object : UserTracker.Callback {
+ override fun onUserChanged(newUser: Int, userContext: Context) {
+ updateSnoozeEnabled()
+ }
}
- }
init {
userTracker.addCallback(userTrackerCallback, HandlerExecutor(handler))
@@ -75,7 +76,7 @@
)
}
updateSnoozeEnabled()
- secureSettings.registerContentObserverForUser(
+ secureSettings.registerContentObserverForUserSync(
SHOW_NOTIFICATION_SNOOZE,
settingsObserver,
UserHandle.USER_ALL
@@ -93,7 +94,7 @@
onSensitiveStateChangedListener
)
}
- secureSettings.unregisterContentObserver(settingsObserver)
+ secureSettings.unregisterContentObserverSync(settingsObserver)
}
}
@@ -104,12 +105,13 @@
private val onSensitiveStateChangedListener = Runnable { dirtyListeners.forEach(Runnable::run) }
- private val settingsObserver = object : ContentObserver(handler) {
- override fun onChange(selfChange: Boolean) {
- updateSnoozeEnabled()
- dirtyListeners.forEach(Runnable::run)
+ private val settingsObserver =
+ object : ContentObserver(handler) {
+ override fun onChange(selfChange: Boolean) {
+ updateSnoozeEnabled()
+ dirtyListeners.forEach(Runnable::run)
+ }
}
- }
private fun updateSnoozeEnabled() {
isSnoozeSettingsEnabled =
@@ -126,22 +128,23 @@
}
/**
- * Returns a adjustment object for the given entry. This can be compared to a previous instance
+ * Returns a adjustment object for the given entry. This can be compared to a previous instance
* from the same notification using [NotifUiAdjustment.needReinflate] to determine if it should
* be reinflated.
*/
- fun calculateAdjustment(entry: NotificationEntry) = NotifUiAdjustment(
- key = entry.key,
- smartActions = entry.ranking.smartActions,
- smartReplies = entry.ranking.smartReplies,
- isConversation = entry.ranking.isConversation,
- isSnoozeEnabled = isSnoozeSettingsEnabled && !entry.isCanceled,
- isMinimized = isEntryMinimized(entry),
- needsRedaction =
- lockscreenUserManager.needsRedaction(entry) ||
- (screenshareNotificationHiding() &&
- sensitiveNotifProtectionController.shouldProtectNotification(entry)),
- isChildInGroup = entry.hasEverBeenGroupChild(),
- isGroupSummary = entry.hasEverBeenGroupSummary(),
- )
+ fun calculateAdjustment(entry: NotificationEntry) =
+ NotifUiAdjustment(
+ key = entry.key,
+ smartActions = entry.ranking.smartActions,
+ smartReplies = entry.ranking.smartReplies,
+ isConversation = entry.ranking.isConversation,
+ isSnoozeEnabled = isSnoozeSettingsEnabled && !entry.isCanceled,
+ isMinimized = isEntryMinimized(entry),
+ needsRedaction =
+ lockscreenUserManager.needsRedaction(entry) ||
+ (screenshareNotificationHiding() &&
+ sensitiveNotifProtectionController.shouldProtectNotification(entry)),
+ isChildInGroup = entry.hasEverBeenGroupChild(),
+ isGroupSummary = entry.hasEverBeenGroupSummary(),
+ )
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
index 42a5bdf..f84b5f4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
@@ -33,8 +33,8 @@
import android.provider.Settings
import android.provider.Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED
import android.provider.Settings.Global.HEADS_UP_OFF
+import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
-import com.android.internal.logging.UiEvent;
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.settings.UserTracker
@@ -86,7 +86,7 @@
}
}
- globalSettings.registerContentObserver(
+ globalSettings.registerContentObserverSync(
globalSettings.getUriFor(HEADS_UP_NOTIFICATIONS_ENABLED),
/* notifyForDescendants = */ true,
observer
@@ -94,7 +94,7 @@
// QQQ: Do we need to register for SETTING_HEADS_UP_TICKER? It seems unused.
- observer.onChange(/* selfChange = */ true)
+ observer.onChange(/* selfChange= */ true)
}
}
@@ -243,6 +243,7 @@
override fun shouldSuppress(entry: NotificationEntry) =
keyguardNotificationVisibilityProvider.shouldHideNotification(entry)
}
+
class AvalancheSuppressor(
private val avalancheProvider: AvalancheProvider,
private val systemClock: SystemClock,
@@ -268,38 +269,33 @@
SUPPRESS
}
- enum class AvalancheEvent(private val id: Int) : UiEventLogger.UiEventEnum {
- @UiEvent(doc = "An avalanche event occurred but this notification was suppressed by a " +
- "non-avalanche suppressor.")
- START(1802),
-
- @UiEvent(doc = "HUN was suppressed in avalanche.")
- SUPPRESS(1803),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is high priority.")
- ALLOW_CONVERSATION_AFTER_AVALANCHE(1804),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is a high priority conversation.")
- ALLOW_HIGH_PRIORITY_CONVERSATION_ANY_TIME(1805),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is a call.")
- ALLOW_CALLSTYLE(1806),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.")
- ALLOW_CATEGORY_REMINDER(1807),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.")
- ALLOW_CATEGORY_EVENT(1808),
-
- @UiEvent(doc = "HUN allowed during avalanche because it has a full screen intent and " +
- "the full screen intent permission is granted.")
- ALLOW_FSI_WITH_PERMISSION_ON(1809),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is colorized.")
- ALLOW_COLORIZED(1810),
-
- @UiEvent(doc = "HUN allowed during avalanche because it is an emergency notification.")
- ALLOW_EMERGENCY(1811);
+ enum class AvalancheEvent(private val id: Int) : UiEventLogger.UiEventEnum {
+ @UiEvent(
+ doc =
+ "An avalanche event occurred but this notification was suppressed by a " +
+ "non-avalanche suppressor."
+ )
+ START(1802),
+ @UiEvent(doc = "HUN was suppressed in avalanche.") SUPPRESS(1803),
+ @UiEvent(doc = "HUN allowed during avalanche because it is high priority.")
+ ALLOW_CONVERSATION_AFTER_AVALANCHE(1804),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a high priority conversation.")
+ ALLOW_HIGH_PRIORITY_CONVERSATION_ANY_TIME(1805),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a call.") ALLOW_CALLSTYLE(1806),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.")
+ ALLOW_CATEGORY_REMINDER(1807),
+ @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.")
+ ALLOW_CATEGORY_EVENT(1808),
+ @UiEvent(
+ doc =
+ "HUN allowed during avalanche because it has a full screen intent and " +
+ "the full screen intent permission is granted."
+ )
+ ALLOW_FSI_WITH_PERMISSION_ON(1809),
+ @UiEvent(doc = "HUN allowed during avalanche because it is colorized.")
+ ALLOW_COLORIZED(1810),
+ @UiEvent(doc = "HUN allowed during avalanche because it is an emergency notification.")
+ ALLOW_EMERGENCY(1811);
override fun getId(): Int {
return id
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt
index 332ece4..c7548aa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt
@@ -14,7 +14,6 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.flags.FeatureFlagsClassic
-import com.android.systemui.flags.Flags
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.NotificationLockscreenUserManager
@@ -41,8 +40,8 @@
/** Determines if notifications should be visible based on the state of the keyguard. */
interface KeyguardNotificationVisibilityProvider {
/**
- * Determines if the given notification should be hidden based on the current keyguard state.
- * If a [Consumer] registered via [addOnStateChangedListener] is invoked, the results of this
+ * Determines if the given notification should be hidden based on the current keyguard state. If
+ * a [Consumer] registered via [addOnStateChangedListener] is invoked, the results of this
* method may no longer be valid and should be re-queried.
*/
fun shouldHideNotification(entry: NotificationEntry): Boolean
@@ -61,8 +60,9 @@
@Module
interface KeyguardNotificationVisibilityProviderImplModule {
@Binds
- fun bindImpl(impl: KeyguardNotificationVisibilityProviderImpl):
- KeyguardNotificationVisibilityProvider
+ fun bindImpl(
+ impl: KeyguardNotificationVisibilityProviderImpl
+ ): KeyguardNotificationVisibilityProvider
@Binds
@IntoMap
@@ -71,7 +71,9 @@
}
@SysUISingleton
-class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
+class KeyguardNotificationVisibilityProviderImpl
+@Inject
+constructor(
@Main private val handler: Handler,
private val keyguardStateController: KeyguardStateController,
private val lockscreenUserManager: NotificationLockscreenUserManager,
@@ -84,76 +86,88 @@
private val featureFlags: FeatureFlagsClassic
) : CoreStartable, KeyguardNotificationVisibilityProvider {
private val showSilentNotifsUri =
- secureSettings.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS)
+ secureSettings.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS)
private val onStateChangedListeners = ListenerSet<Consumer<String>>()
private var hideSilentNotificationsOnLockscreen: Boolean = false
- private val userTrackerCallback = object : UserTracker.Callback {
- override fun onUserChanged(newUser: Int, userContext: Context) {
- readShowSilentNotificationSetting()
- if (isLockedOrLocking) {
- // maybe public mode changed
- notifyStateChanged("onUserSwitched")
+ private val userTrackerCallback =
+ object : UserTracker.Callback {
+ override fun onUserChanged(newUser: Int, userContext: Context) {
+ readShowSilentNotificationSetting()
+ if (isLockedOrLocking) {
+ // maybe public mode changed
+ notifyStateChanged("onUserSwitched")
+ }
}
}
- }
override fun start() {
readShowSilentNotificationSetting()
- keyguardStateController.addCallback(object : KeyguardStateController.Callback {
- override fun onUnlockedChanged() {
- notifyStateChanged("onUnlockedChanged")
- }
+ keyguardStateController.addCallback(
+ object : KeyguardStateController.Callback {
+ override fun onUnlockedChanged() {
+ notifyStateChanged("onUnlockedChanged")
+ }
- override fun onKeyguardShowingChanged() {
- notifyStateChanged("onKeyguardShowingChanged")
+ override fun onKeyguardShowingChanged() {
+ notifyStateChanged("onKeyguardShowingChanged")
+ }
}
- })
- keyguardUpdateMonitor.registerCallback(object : KeyguardUpdateMonitorCallback() {
- override fun onStrongAuthStateChanged(userId: Int) {
- notifyStateChanged("onStrongAuthStateChanged")
+ )
+ keyguardUpdateMonitor.registerCallback(
+ object : KeyguardUpdateMonitorCallback() {
+ override fun onStrongAuthStateChanged(userId: Int) {
+ notifyStateChanged("onStrongAuthStateChanged")
+ }
}
- })
+ )
// register lockscreen settings changed callbacks:
- val settingsObserver: ContentObserver = object : ContentObserver(handler) {
- override fun onChange(selfChange: Boolean, uri: Uri?) {
- if (uri == showSilentNotifsUri) {
- readShowSilentNotificationSetting()
- }
- if (isLockedOrLocking) {
- notifyStateChanged("Settings $uri changed")
+ val settingsObserver: ContentObserver =
+ object : ContentObserver(handler) {
+ override fun onChange(selfChange: Boolean, uri: Uri?) {
+ if (uri == showSilentNotifsUri) {
+ readShowSilentNotificationSetting()
+ }
+ if (isLockedOrLocking) {
+ notifyStateChanged("Settings $uri changed")
+ }
}
}
- }
- secureSettings.registerContentObserverForUser(
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- settingsObserver,
- UserHandle.USER_ALL)
+ secureSettings.registerContentObserverForUserSync(
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
+ settingsObserver,
+ UserHandle.USER_ALL
+ )
- secureSettings.registerContentObserverForUser(
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- true,
- settingsObserver,
- UserHandle.USER_ALL)
+ secureSettings.registerContentObserverForUserSync(
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
+ true,
+ settingsObserver,
+ UserHandle.USER_ALL
+ )
- globalSettings.registerContentObserver(Settings.Global.ZEN_MODE, settingsObserver)
+ globalSettings.registerContentObserverSync(Settings.Global.ZEN_MODE, settingsObserver)
- secureSettings.registerContentObserverForUser(
- Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
- settingsObserver,
- UserHandle.USER_ALL)
+ secureSettings.registerContentObserverForUserSync(
+ Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
+ settingsObserver,
+ UserHandle.USER_ALL
+ )
// register (maybe) public mode changed callbacks:
- statusBarStateController.addCallback(object : StatusBarStateController.StateListener {
- override fun onStateChanged(newState: Int) {
- notifyStateChanged("onStatusBarStateChanged")
+ statusBarStateController.addCallback(
+ object : StatusBarStateController.StateListener {
+ override fun onStateChanged(newState: Int) {
+ notifyStateChanged("onStatusBarStateChanged")
+ }
+
+ override fun onUpcomingStateChanged(state: Int) {
+ notifyStateChanged("onStatusBarUpcomingStateChanged")
+ }
}
- override fun onUpcomingStateChanged(state: Int) {
- notifyStateChanged("onStatusBarUpcomingStateChanged")
- }
- })
+ )
userTracker.addCallback(userTrackerCallback, HandlerExecutor(handler))
}
@@ -169,45 +183,48 @@
onStateChangedListeners.forEach { it.accept(reason) }
}
- override fun shouldHideNotification(entry: NotificationEntry): Boolean = when {
- // Keyguard state doesn't matter if the keyguard is not showing.
- !isLockedOrLocking -> false
- // Notifications not allowed on the lockscreen, always hide.
- !lockscreenUserManager.shouldShowLockscreenNotifications() -> true
- // User settings do not allow this notification on the lockscreen, so hide it.
- userSettingsDisallowNotification(entry) -> true
- // Entry is explicitly marked SECRET, so hide it.
- entry.sbn.notification.visibility == VISIBILITY_SECRET -> true
- // if entry is silent, apply custom logic to see if should hide
- shouldHideIfEntrySilent(entry) -> true
- else -> false
- }
+ override fun shouldHideNotification(entry: NotificationEntry): Boolean =
+ when {
+ // Keyguard state doesn't matter if the keyguard is not showing.
+ !isLockedOrLocking -> false
+ // Notifications not allowed on the lockscreen, always hide.
+ !lockscreenUserManager.shouldShowLockscreenNotifications() -> true
+ // User settings do not allow this notification on the lockscreen, so hide it.
+ userSettingsDisallowNotification(entry) -> true
+ // Entry is explicitly marked SECRET, so hide it.
+ entry.sbn.notification.visibility == VISIBILITY_SECRET -> true
+ // if entry is silent, apply custom logic to see if should hide
+ shouldHideIfEntrySilent(entry) -> true
+ else -> false
+ }
- private fun shouldHideIfEntrySilent(entry: ListEntry): Boolean = when {
- // Show if explicitly high priority (not hidden)
- highPriorityProvider.isExplicitlyHighPriority(entry) -> false
- // Ambient notifications are hidden always from lock screen
- entry.representativeEntry?.isAmbient == true -> true
- // [Now notification is silent]
- // Hide regardless of parent priority if user wants silent notifs hidden
- hideSilentNotificationsOnLockscreen -> true
- // Parent priority is high enough to be shown on the lockscreen, do not hide.
- entry.parent?.let(::shouldHideIfEntrySilent) == false -> false
- // Show when silent notifications are allowed on lockscreen
- else -> false
- }
+ private fun shouldHideIfEntrySilent(entry: ListEntry): Boolean =
+ when {
+ // Show if explicitly high priority (not hidden)
+ highPriorityProvider.isExplicitlyHighPriority(entry) -> false
+ // Ambient notifications are hidden always from lock screen
+ entry.representativeEntry?.isAmbient == true -> true
+ // [Now notification is silent]
+ // Hide regardless of parent priority if user wants silent notifs hidden
+ hideSilentNotificationsOnLockscreen -> true
+ // Parent priority is high enough to be shown on the lockscreen, do not hide.
+ entry.parent?.let(::shouldHideIfEntrySilent) == false -> false
+ // Show when silent notifications are allowed on lockscreen
+ else -> false
+ }
private fun userSettingsDisallowNotification(entry: NotificationEntry): Boolean {
- fun disallowForUser(user: Int) = when {
- // user is in lockdown, always disallow
- keyguardUpdateMonitor.isUserInLockdown(user) -> true
- // device isn't public, no need to check public-related settings, so allow
- !lockscreenUserManager.isLockscreenPublicMode(user) -> false
- // entry is meant to be secret on the lockscreen, disallow
- isRankingVisibilitySecret(entry) -> true
- // disallow if user disallows notifications in public
- else -> !lockscreenUserManager.userAllowsNotificationsInPublic(user)
- }
+ fun disallowForUser(user: Int) =
+ when {
+ // user is in lockdown, always disallow
+ keyguardUpdateMonitor.isUserInLockdown(user) -> true
+ // device isn't public, no need to check public-related settings, so allow
+ !lockscreenUserManager.isLockscreenPublicMode(user) -> false
+ // entry is meant to be secret on the lockscreen, disallow
+ isRankingVisibilitySecret(entry) -> true
+ // disallow if user disallows notifications in public
+ else -> !lockscreenUserManager.userAllowsNotificationsInPublic(user)
+ }
val currentUser = lockscreenUserManager.currentUserId
val notifUser = entry.sbn.user.identifier
return when {
@@ -222,28 +239,35 @@
// ranking.lockscreenVisibilityOverride contains possibly out of date DPC and Setting
// info, and NotificationLockscreenUserManagerImpl is already listening for updates
// to those
- return entry.ranking.channel != null && entry.ranking.channel.lockscreenVisibility ==
- VISIBILITY_SECRET
+ return entry.ranking.channel != null &&
+ entry.ranking.channel.lockscreenVisibility == VISIBILITY_SECRET
}
- override fun dump(pw: PrintWriter, args: Array<out String>) = pw.asIndenting().run {
- println("isLockedOrLocking", isLockedOrLocking)
- withIncreasedIndent {
- println("keyguardStateController.isShowing", keyguardStateController.isShowing)
- println("statusBarStateController.currentOrUpcomingState",
- statusBarStateController.currentOrUpcomingState)
+ override fun dump(pw: PrintWriter, args: Array<out String>) =
+ pw.asIndenting().run {
+ println("isLockedOrLocking", isLockedOrLocking)
+ withIncreasedIndent {
+ println("keyguardStateController.isShowing", keyguardStateController.isShowing)
+ println(
+ "statusBarStateController.currentOrUpcomingState",
+ statusBarStateController.currentOrUpcomingState
+ )
+ }
+ println("hideSilentNotificationsOnLockscreen", hideSilentNotificationsOnLockscreen)
}
- println("hideSilentNotificationsOnLockscreen", hideSilentNotificationsOnLockscreen)
- }
- private val isLockedOrLocking get() =
- keyguardStateController.isShowing ||
+ private val isLockedOrLocking
+ get() =
+ keyguardStateController.isShowing ||
statusBarStateController.currentOrUpcomingState == StatusBarState.KEYGUARD
private fun readShowSilentNotificationSetting() {
val showSilentNotifs =
- secureSettings.getBoolForUser(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
- false, UserHandle.USER_CURRENT)
+ secureSettings.getBoolForUser(
+ Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
+ false,
+ UserHandle.USER_CURRENT
+ )
hideSilentNotificationsOnLockscreen = !showSilentNotifs
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java
index 74925c8..fea360d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java
@@ -171,11 +171,11 @@
};
if (ENABLE_HEADS_UP) {
- mGlobalSettings.registerContentObserver(
+ mGlobalSettings.registerContentObserverSync(
mGlobalSettings.getUriFor(HEADS_UP_NOTIFICATIONS_ENABLED),
true,
headsUpObserver);
- mGlobalSettings.registerContentObserver(
+ mGlobalSettings.registerContentObserverSync(
mGlobalSettings.getUriFor(SETTING_HEADS_UP_TICKER), true,
headsUpObserver);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSettingsController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSettingsController.java
index a17c066..30dbfed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSettingsController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSettingsController.java
@@ -92,9 +92,9 @@
synchronized (mListeners) {
if (mListeners.size() > 0) {
- mSecureSettings.unregisterContentObserver(mContentObserver);
+ mSecureSettings.unregisterContentObserverSync(mContentObserver);
for (Uri uri : mListeners.keySet()) {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
uri, false, mContentObserver, newUser);
}
}
@@ -131,7 +131,7 @@
mListeners.put(uri, currentListeners);
if (currentListeners.size() == 1) {
mBackgroundHandler.post(() -> {
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
uri, false, mContentObserver, mUserTracker.getUserId());
});
}
@@ -159,7 +159,7 @@
if (mListeners.size() == 0) {
mBackgroundHandler.post(() -> {
- mSecureSettings.unregisterContentObserver(mContentObserver);
+ mSecureSettings.unregisterContentObserverSync(mContentObserver);
});
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/shared/NotificationRowContentBinderRefactor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/shared/NotificationRowContentBinderRefactor.kt
new file mode 100644
index 0000000..997acdd
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/shared/NotificationRowContentBinderRefactor.kt
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2024 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.notification.row.shared
+
+import com.android.systemui.Flags
+import com.android.systemui.flags.FlagToken
+import com.android.systemui.flags.RefactorFlagUtils
+
+/** Helper for reading or using the notification row content binder refactor flag state. */
+@Suppress("NOTHING_TO_INLINE")
+object NotificationRowContentBinderRefactor {
+ /** The aconfig flag name */
+ const val FLAG_NAME = Flags.FLAG_NOTIFICATION_ROW_CONTENT_BINDER_REFACTOR
+
+ /** A token used for dependency declaration */
+ val token: FlagToken
+ get() = FlagToken(FLAG_NAME, isEnabled)
+
+ /** Is the refactor enabled */
+ @JvmStatic
+ inline val isEnabled
+ get() = Flags.notificationRowContentBinderRefactor()
+
+ /**
+ * Called to ensure code is only run when the flag is enabled. This protects users from the
+ * unintended behaviors caused by accidentally running new logic, while also crashing on an eng
+ * build to ensure that the refactor author catches issues in testing.
+ */
+ @JvmStatic
+ inline fun isUnexpectedlyInLegacyMode() =
+ RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, FLAG_NAME)
+
+ /**
+ * Called to ensure code is only run when the flag is disabled. This will throw an exception if
+ * the flag is enabled to ensure that the refactor author catches issues in testing.
+ */
+ @JvmStatic
+ inline fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, FLAG_NAME)
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java
index 6d4301f..e44edcb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java
@@ -398,7 +398,7 @@
mSystemIconsContainer.setOnHoverListener(hoverListener);
mView.setOnApplyWindowInsetsListener(
(view, windowInsets) -> mView.updateWindowInsets(windowInsets, mInsetsProvider));
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON,
false,
mVolumeSettingObserver,
@@ -416,7 +416,7 @@
mStatusBarStateController.removeCallback(mStatusBarStateListener);
mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback);
mDisableStateTracker.stopTracking(mCommandQueue);
- mSecureSettings.unregisterContentObserver(mVolumeSettingObserver);
+ mSecureSettings.unregisterContentObserverSync(mVolumeSettingObserver);
if (mTintedIconManager != null) {
mStatusBarIconController.removeIconGroup(mTintedIconManager);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
index 479aef1..c53558e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
@@ -23,9 +23,9 @@
import com.android.systemui.keyguard.KeyguardViewMediator
import com.android.systemui.keyguard.MigrateClocksToBlueprint
import com.android.systemui.keyguard.WakefulnessLifecycle
-import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor
+import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor
import com.android.systemui.statusbar.CircleReveal
import com.android.systemui.statusbar.LightRevealScrim
import com.android.systemui.statusbar.NotificationShadeWindowController
@@ -162,7 +162,7 @@
this.centralSurfaces = centralSurfaces
updateAnimatorDurationScale()
- globalSettings.registerContentObserver(
+ globalSettings.registerContentObserverSync(
Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE),
/* notify for descendants */ false,
animatorDurationScaleObserver
@@ -376,8 +376,9 @@
// We currently draw both the light reveal scrim, and the AOD UI, in the shade. If it's
// already expanded and showing notifications/QS, the animation looks really messy. For now,
// disable it if the notification panel is expanded.
- if ((!this::centralSurfaces.isInitialized ||
- panelExpansionInteractorLazy.get().isPanelExpanded) &&
+ if (
+ (!this::centralSurfaces.isInitialized ||
+ panelExpansionInteractorLazy.get().isPanelExpanded) &&
// Status bar might be expanded because we have started
// playing the animation already
!isAnimationPlaying()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
index aac211a..3d8090d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
@@ -80,6 +80,10 @@
import com.android.systemui.util.CarrierConfigTracker.DefaultDataSubscriptionChangedListener;
import com.android.systemui.util.settings.SecureSettings;
+import kotlin.Unit;
+
+import kotlinx.coroutines.DisposableHandle;
+
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -90,10 +94,6 @@
import javax.inject.Inject;
-import kotlin.Unit;
-
-import kotlinx.coroutines.DisposableHandle;
-
/**
* Contains the collapsed status bar and handles hiding/showing based on disable flags
* and keyguard state. Also manages lifecycle to make sure the views it contains are being
@@ -431,7 +431,7 @@
initOngoingCallChip();
mAnimationScheduler.addCallback(this);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON,
false,
mVolumeSettingObserver,
@@ -445,7 +445,7 @@
mStatusBarStateController.removeCallback(this);
mOngoingCallController.removeCallback(mOngoingCallListener);
mAnimationScheduler.removeCallback(this);
- mSecureSettings.unregisterContentObserver(mVolumeSettingObserver);
+ mSecureSettings.unregisterContentObserverSync(mVolumeSettingObserver);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java
index 4bd8681..fad5df8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java
@@ -138,7 +138,7 @@
}
}
};
- globalSettings.registerContentObserver(
+ globalSettings.registerContentObserverSync(
globalSettings.getUriFor(SETTING_HEADS_UP_SNOOZE_LENGTH_MS),
/* notifyForDescendants = */ false,
settingsObserver);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.kt
index 8b63dfe..8123f8f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.kt
@@ -42,16 +42,16 @@
import javax.inject.Inject
@SysUISingleton
-open class DeviceProvisionedControllerImpl @Inject constructor(
+open class DeviceProvisionedControllerImpl
+@Inject
+constructor(
private val secureSettings: SecureSettings,
private val globalSettings: GlobalSettings,
private val userTracker: UserTracker,
private val dumpManager: DumpManager,
@Background private val backgroundHandler: Handler,
@Main private val mainExecutor: Executor
-) : DeviceProvisionedController,
- DeviceProvisionedController.DeviceProvisionedListener,
- Dumpable {
+) : DeviceProvisionedController, DeviceProvisionedController.DeviceProvisionedListener, Dumpable {
companion object {
private const val ALL_USERS = -1
@@ -63,8 +63,7 @@
private val userSetupUri = secureSettings.getUriFor(Settings.Secure.USER_SETUP_COMPLETE)
private val deviceProvisioned = AtomicBoolean(false)
- @GuardedBy("lock")
- private val userSetupComplete = SparseBooleanArray()
+ @GuardedBy("lock") private val userSetupComplete = SparseBooleanArray()
@GuardedBy("lock")
private val listeners = ArraySet<DeviceProvisionedController.DeviceProvisionedListener>()
@@ -81,42 +80,42 @@
return _currentUser
}
- private val observer = object : ContentObserver(backgroundHandler) {
- override fun onChange(
- selfChange: Boolean,
- uris: MutableCollection<Uri>,
- flags: Int,
- userId: Int
- ) {
- val updateDeviceProvisioned = deviceProvisionedUri in uris
- val updateUser = if (userSetupUri in uris) userId else NO_USERS
- updateValues(updateDeviceProvisioned, updateUser)
- if (updateDeviceProvisioned) {
- onDeviceProvisionedChanged()
- }
- if (updateUser != NO_USERS) {
- onUserSetupChanged()
+ private val observer =
+ object : ContentObserver(backgroundHandler) {
+ override fun onChange(
+ selfChange: Boolean,
+ uris: MutableCollection<Uri>,
+ flags: Int,
+ userId: Int
+ ) {
+ val updateDeviceProvisioned = deviceProvisionedUri in uris
+ val updateUser = if (userSetupUri in uris) userId else NO_USERS
+ updateValues(updateDeviceProvisioned, updateUser)
+ if (updateDeviceProvisioned) {
+ onDeviceProvisionedChanged()
+ }
+ if (updateUser != NO_USERS) {
+ onUserSetupChanged()
+ }
}
}
- }
- private val userChangedCallback = object : UserTracker.Callback {
- @WorkerThread
- override fun onUserChanged(newUser: Int, userContext: Context) {
- updateValues(updateDeviceProvisioned = false, updateUser = newUser)
- onUserSwitched()
+ private val userChangedCallback =
+ object : UserTracker.Callback {
+ @WorkerThread
+ override fun onUserChanged(newUser: Int, userContext: Context) {
+ updateValues(updateDeviceProvisioned = false, updateUser = newUser)
+ onUserSwitched()
+ }
+
+ override fun onProfilesChanged(profiles: List<UserInfo>) {}
}
- override fun onProfilesChanged(profiles: List<UserInfo>) {}
- }
-
init {
userSetupComplete.put(currentUser, false)
}
- /**
- * Call to initialize values and register observers
- */
+ /** Call to initialize values and register observers */
open fun init() {
if (!initted.compareAndSet(false, true)) {
return
@@ -124,31 +123,39 @@
dumpManager.registerDumpable(this)
updateValues()
userTracker.addCallback(userChangedCallback, backgroundExecutor)
- globalSettings.registerContentObserver(deviceProvisionedUri, observer)
- secureSettings.registerContentObserverForUser(userSetupUri, observer, UserHandle.USER_ALL)
+ globalSettings.registerContentObserverSync(deviceProvisionedUri, observer)
+ secureSettings.registerContentObserverForUserSync(
+ userSetupUri,
+ observer,
+ UserHandle.USER_ALL
+ )
}
@WorkerThread
- private fun updateValues(
- updateDeviceProvisioned: Boolean = true,
- updateUser: Int = ALL_USERS
- ) {
+ private fun updateValues(updateDeviceProvisioned: Boolean = true, updateUser: Int = ALL_USERS) {
if (updateDeviceProvisioned) {
- deviceProvisioned
- .set(globalSettings.getInt(Settings.Global.DEVICE_PROVISIONED, 0) != 0)
+ deviceProvisioned.set(globalSettings.getInt(Settings.Global.DEVICE_PROVISIONED, 0) != 0)
}
synchronized(lock) {
if (updateUser == ALL_USERS) {
val n = userSetupComplete.size()
for (i in 0 until n) {
val user = userSetupComplete.keyAt(i)
- val value = secureSettings
- .getIntForUser(Settings.Secure.USER_SETUP_COMPLETE, 0, user) != 0
+ val value =
+ secureSettings.getIntForUser(
+ Settings.Secure.USER_SETUP_COMPLETE,
+ 0,
+ user
+ ) != 0
userSetupComplete.put(user, value)
}
} else if (updateUser != NO_USERS) {
- val value = secureSettings
- .getIntForUser(Settings.Secure.USER_SETUP_COMPLETE, 0, updateUser) != 0
+ val value =
+ secureSettings.getIntForUser(
+ Settings.Secure.USER_SETUP_COMPLETE,
+ 0,
+ updateUser
+ ) != 0
userSetupComplete.put(updateUser, value)
}
}
@@ -160,15 +167,11 @@
* The listener will not be called when this happens.
*/
override fun addCallback(listener: DeviceProvisionedController.DeviceProvisionedListener) {
- synchronized(lock) {
- listeners.add(listener)
- }
+ synchronized(lock) { listeners.add(listener) }
}
override fun removeCallback(listener: DeviceProvisionedController.DeviceProvisionedListener) {
- synchronized(lock) {
- listeners.remove(listener)
- }
+ synchronized(lock) { listeners.remove(listener) }
}
override fun isDeviceProvisioned(): Boolean {
@@ -176,20 +179,14 @@
}
override fun isUserSetup(user: Int): Boolean {
- val index = synchronized(lock) {
- userSetupComplete.indexOfKey(user)
- }
+ val index = synchronized(lock) { userSetupComplete.indexOfKey(user) }
return if (index < 0) {
- val value = secureSettings
- .getIntForUser(Settings.Secure.USER_SETUP_COMPLETE, 0, user) != 0
- synchronized(lock) {
- userSetupComplete.put(user, value)
- }
+ val value =
+ secureSettings.getIntForUser(Settings.Secure.USER_SETUP_COMPLETE, 0, user) != 0
+ synchronized(lock) { userSetupComplete.put(user, value) }
value
} else {
- synchronized(lock) {
- userSetupComplete.get(user, false)
- }
+ synchronized(lock) { userSetupComplete.get(user, false) }
}
}
@@ -214,12 +211,8 @@
protected fun dispatchChange(
callback: DeviceProvisionedController.DeviceProvisionedListener.() -> Unit
) {
- val listenersCopy = synchronized(lock) {
- ArrayList(listeners)
- }
- mainExecutor.execute {
- listenersCopy.forEach(callback)
- }
+ val listenersCopy = synchronized(lock) { ArrayList(listeners) }
+ mainExecutor.execute { listenersCopy.forEach(callback) }
}
override fun dump(pw: PrintWriter, args: Array<out String>) {
@@ -229,4 +222,4 @@
pw.println("Listeners: $listeners")
}
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java
index 9eee5d0..f57b696 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java
@@ -115,7 +115,7 @@
};
// Register to listen for changes in Settings.Secure settings.
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, mContentObserver, UserHandle.USER_ALL);
// Register to listen for changes in DeviceConfig settings.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java
index 40bb67f..9ab8175 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SensitiveNotificationProtectionControllerImpl.java
@@ -188,7 +188,7 @@
});
}
};
- settings.registerContentObserver(
+ settings.registerContentObserverSync(
DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS,
developerOptionsObserver);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
index 600005b..e09e577 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
@@ -140,13 +140,13 @@
mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (registerZenModeContentObserverBackground()) {
bgHandler.post(() -> {
- globalSettings.registerContentObserver(Global.ZEN_MODE, modeContentObserver);
- globalSettings.registerContentObserver(Global.ZEN_MODE_CONFIG_ETAG,
+ globalSettings.registerContentObserverSync(Global.ZEN_MODE, modeContentObserver);
+ globalSettings.registerContentObserverSync(Global.ZEN_MODE_CONFIG_ETAG,
configContentObserver);
});
} else {
- globalSettings.registerContentObserver(Global.ZEN_MODE, modeContentObserver);
- globalSettings.registerContentObserver(Global.ZEN_MODE_CONFIG_ETAG,
+ globalSettings.registerContentObserverSync(Global.ZEN_MODE, modeContentObserver);
+ globalSettings.registerContentObserverSync(Global.ZEN_MODE_CONFIG_ETAG,
configContentObserver);
}
updateZenMode(getModeSettingValueFromProvider());
diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
index 7494649..4963aae 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
+++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
@@ -444,7 +444,7 @@
filter.addAction(Intent.ACTION_WALLPAPER_CHANGED);
mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter, mMainExecutor,
UserHandle.ALL);
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
false,
new ContentObserver(mBgHandler) {
diff --git a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxy.kt b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxy.kt
index ec89610..ed52233 100644
--- a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxy.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxy.kt
@@ -37,7 +37,6 @@
interface SettingsProxy {
/** Returns the [ContentResolver] this instance was constructed with. */
fun getContentResolver(): ContentResolver
-
/**
* Construct the content URI for a particular name/value pair, useful for monitoring changes
* with a ContentObserver.
@@ -46,42 +45,36 @@
* @return the corresponding content URI, or null if not present
*/
fun getUriFor(name: String): Uri
-
/**
* Convenience wrapper around [ContentResolver.registerContentObserver].'
*
* Implicitly calls [getUriFor] on the passed in name.
*/
- fun registerContentObserver(name: String, settingsObserver: ContentObserver) {
- registerContentObserver(getUriFor(name), settingsObserver)
+ fun registerContentObserverSync(name: String, settingsObserver: ContentObserver) {
+ registerContentObserverSync(getUriFor(name), settingsObserver)
}
-
/** Convenience wrapper around [ContentResolver.registerContentObserver].' */
- fun registerContentObserver(uri: Uri, settingsObserver: ContentObserver) =
- registerContentObserver(uri, false, settingsObserver)
-
+ fun registerContentObserverSync(uri: Uri, settingsObserver: ContentObserver) =
+ registerContentObserverSync(uri, false, settingsObserver)
/**
* Convenience wrapper around [ContentResolver.registerContentObserver].'
*
* Implicitly calls [getUriFor] on the passed in name.
*/
- fun registerContentObserver(
+ fun registerContentObserverSync(
name: String,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver
- ) = registerContentObserver(getUriFor(name), notifyForDescendants, settingsObserver)
-
+ ) = registerContentObserverSync(getUriFor(name), notifyForDescendants, settingsObserver)
/** Convenience wrapper around [ContentResolver.registerContentObserver].' */
- fun registerContentObserver(
+ fun registerContentObserverSync(
uri: Uri,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver
) = getContentResolver().registerContentObserver(uri, notifyForDescendants, settingsObserver)
-
/** See [ContentResolver.unregisterContentObserver]. */
- fun unregisterContentObserver(settingsObserver: ContentObserver) =
+ fun unregisterContentObserverSync(settingsObserver: ContentObserver) =
getContentResolver().unregisterContentObserver(settingsObserver)
-
/**
* Look up a name in the database.
*
@@ -89,7 +82,6 @@
* @return the corresponding value, or null if not present
*/
fun getString(name: String): String
-
/**
* Store a name/value pair into the database.
*
@@ -98,7 +90,6 @@
* @return true if the value was set, false on database errors
*/
fun putString(name: String, value: String): Boolean
-
/**
* Store a name/value pair into the database.
*
@@ -129,7 +120,6 @@
* @see .resetToDefaults
*/
fun putString(name: String, value: String, tag: String, makeDefault: Boolean): Boolean
-
/**
* Convenience function for retrieving a single secure settings value as an integer. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -148,7 +138,6 @@
def
}
}
-
/**
* Convenience function for retrieving a single secure settings value as an integer. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -171,7 +160,6 @@
throw SettingNotFoundException(name)
}
}
-
/**
* Convenience function for updating a single settings value as an integer. This will either
* create a new entry in the table if the given name does not exist, or modify the value of the
@@ -185,7 +173,6 @@
fun putInt(name: String, value: Int): Boolean {
return putString(name, value.toString())
}
-
/**
* Convenience function for retrieving a single secure settings value as a boolean. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -199,7 +186,6 @@
fun getBool(name: String, def: Boolean): Boolean {
return getInt(name, if (def) 1 else 0) != 0
}
-
/**
* Convenience function for retrieving a single secure settings value as a boolean. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -217,7 +203,6 @@
fun getBool(name: String): Boolean {
return getInt(name) != 0
}
-
/**
* Convenience function for updating a single settings value as a boolean. This will either
* create a new entry in the table if the given name does not exist, or modify the value of the
@@ -231,7 +216,6 @@
fun putBool(name: String, value: Boolean): Boolean {
return putInt(name, if (value) 1 else 0)
}
-
/**
* Convenience function for retrieving a single secure settings value as a `long`. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -246,7 +230,6 @@
val valString = getString(name)
return parseLongOrUseDefault(valString, def)
}
-
/**
* Convenience function for retrieving a single secure settings value as a `long`. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -265,7 +248,6 @@
val valString = getString(name)
return parseLongOrThrow(name, valString)
}
-
/**
* Convenience function for updating a secure settings value as a long integer. This will either
* create a new entry in the table if the given name does not exist, or modify the value of the
@@ -279,7 +261,6 @@
fun putLong(name: String, value: Long): Boolean {
return putString(name, value.toString())
}
-
/**
* Convenience function for retrieving a single secure settings value as a floating point
* number. Note that internally setting values are always stored as strings; this function
@@ -294,7 +275,6 @@
val v = getString(name)
return parseFloat(v, def)
}
-
/**
* Convenience function for retrieving a single secure settings value as a float. Note that
* internally setting values are always stored as strings; this function converts the string to
@@ -313,7 +293,6 @@
val v = getString(name)
return parseFloatOrThrow(name, v)
}
-
/**
* Convenience function for updating a single settings value as a floating point number. This
* will either create a new entry in the table if the given name does not exist, or modify the
@@ -327,7 +306,6 @@
fun putFloat(name: String, value: Float): Boolean {
return putString(name, value.toString())
}
-
companion object {
/** Convert a string to a long, or uses a default if the string is malformed or null */
@JvmStatic
@@ -341,7 +319,6 @@
}
return value
}
-
/** Convert a string to a long, or throws an exception if the string is malformed or null */
@JvmStatic
@Throws(SettingNotFoundException::class)
@@ -355,7 +332,6 @@
throw SettingNotFoundException(name)
}
}
-
/** Convert a string to a float, or uses a default if the string is malformed or null */
@JvmStatic
fun parseFloat(v: String?, def: Float): Float {
@@ -365,7 +341,6 @@
def
}
}
-
/**
* Convert a string to a float, or throws an exception if the string is malformed or null
*/
diff --git a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt
index 7484368..d757e33 100644
--- a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt
@@ -39,9 +39,9 @@
}
}
- names.forEach { name -> registerContentObserverForUser(name, observer, userId) }
+ names.forEach { name -> registerContentObserverForUserSync(name, observer, userId) }
- awaitClose { unregisterContentObserver(observer) }
+ awaitClose { unregisterContentObserverSync(observer) }
}
}
@@ -57,9 +57,9 @@
}
}
- names.forEach { name -> registerContentObserver(name, observer) }
+ names.forEach { name -> registerContentObserverSync(name, observer) }
- awaitClose { unregisterContentObserver(observer) }
+ awaitClose { unregisterContentObserverSync(observer) }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/util/settings/UserSettingsProxy.kt b/packages/SystemUI/src/com/android/systemui/util/settings/UserSettingsProxy.kt
index 2285270..ed13943 100644
--- a/packages/SystemUI/src/com/android/systemui/util/settings/UserSettingsProxy.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/settings/UserSettingsProxy.kt
@@ -41,10 +41,8 @@
* instances, unifying setting related actions in one place.
*/
interface UserSettingsProxy : SettingsProxy {
-
/** Returns that [UserTracker] this instance was constructed with. */
val userTracker: UserTracker
-
/** Returns the user id for the associated [ContentResolver]. */
var userId: Int
get() = getContentResolver().userId
@@ -53,7 +51,6 @@
"userId cannot be set in interface, use setter from an implementation instead."
)
}
-
/**
* Returns the actual current user handle when querying with the current user. Otherwise,
* returns the passed in user id.
@@ -63,63 +60,57 @@
userHandle
} else userTracker.userId
}
-
- override fun registerContentObserver(uri: Uri, settingsObserver: ContentObserver) {
- registerContentObserverForUser(uri, settingsObserver, userId)
+ override fun registerContentObserverSync(uri: Uri, settingsObserver: ContentObserver) {
+ registerContentObserverForUserSync(uri, settingsObserver, userId)
}
-
/** Convenience wrapper around [ContentResolver.registerContentObserver].' */
- override fun registerContentObserver(
+ override fun registerContentObserverSync(
uri: Uri,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver
) {
- registerContentObserverForUser(uri, notifyForDescendants, settingsObserver, userId)
+ registerContentObserverForUserSync(uri, notifyForDescendants, settingsObserver, userId)
}
-
/**
* Convenience wrapper around [ContentResolver.registerContentObserver]
*
* Implicitly calls [getUriFor] on the passed in name.
*/
- fun registerContentObserverForUser(
+ fun registerContentObserverForUserSync(
name: String,
settingsObserver: ContentObserver,
userHandle: Int
) {
- registerContentObserverForUser(getUriFor(name), settingsObserver, userHandle)
+ registerContentObserverForUserSync(getUriFor(name), settingsObserver, userHandle)
}
-
/** Convenience wrapper around [ContentResolver.registerContentObserver] */
- fun registerContentObserverForUser(
+ fun registerContentObserverForUserSync(
uri: Uri,
settingsObserver: ContentObserver,
userHandle: Int
) {
- registerContentObserverForUser(uri, false, settingsObserver, userHandle)
+ registerContentObserverForUserSync(uri, false, settingsObserver, userHandle)
}
-
/**
* Convenience wrapper around [ContentResolver.registerContentObserver]
*
* Implicitly calls [getUriFor] on the passed in name.
*/
- fun registerContentObserverForUser(
+ fun registerContentObserverForUserSync(
name: String,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver,
userHandle: Int
) {
- registerContentObserverForUser(
+ registerContentObserverForUserSync(
getUriFor(name),
notifyForDescendants,
settingsObserver,
userHandle
)
}
-
/** Convenience wrapper around [ContentResolver.registerContentObserver] */
- fun registerContentObserverForUser(
+ fun registerContentObserverForUserSync(
uri: Uri,
notifyForDescendants: Boolean,
settingsObserver: ContentObserver,
@@ -136,7 +127,6 @@
Unit
}
}
-
/**
* Look up a name in the database.
*
@@ -146,10 +136,8 @@
override fun getString(name: String): String {
return getStringForUser(name, userId)
}
-
/** See [getString]. */
fun getStringForUser(name: String, userHandle: Int): String
-
/**
* Store a name/value pair into the database. Values written by this method will be overridden
* if a restore happens in the future.
@@ -162,10 +150,8 @@
override fun putString(name: String, value: String): Boolean {
return putStringForUser(name, value, userId)
}
-
/** Similar implementation to [putString] for the specified [userHandle]. */
fun putStringForUser(name: String, value: String, userHandle: Int): Boolean
-
/** Similar implementation to [putString] for the specified [userHandle]. */
fun putStringForUser(
name: String,
@@ -175,11 +161,9 @@
@UserIdInt userHandle: Int,
overrideableByRestore: Boolean
): Boolean
-
override fun getInt(name: String, def: Int): Int {
return getIntForUser(name, def, userId)
}
-
/** Similar implementation to [getInt] for the specified [userHandle]. */
fun getIntForUser(name: String, def: Int, userHandle: Int): Int {
val v = getStringForUser(name, userHandle)
@@ -189,10 +173,8 @@
def
}
}
-
@Throws(SettingNotFoundException::class)
override fun getInt(name: String) = getIntForUser(name, userId)
-
/** Similar implementation to [getInt] for the specified [userHandle]. */
@Throws(SettingNotFoundException::class)
fun getIntForUser(name: String, userHandle: Int): Int {
@@ -203,66 +185,52 @@
throw SettingNotFoundException(name)
}
}
-
override fun putInt(name: String, value: Int) = putIntForUser(name, value, userId)
-
/** Similar implementation to [getInt] for the specified [userHandle]. */
fun putIntForUser(name: String, value: Int, userHandle: Int) =
putStringForUser(name, value.toString(), userHandle)
-
override fun getBool(name: String, def: Boolean) = getBoolForUser(name, def, userId)
-
/** Similar implementation to [getBool] for the specified [userHandle]. */
fun getBoolForUser(name: String, def: Boolean, userHandle: Int) =
getIntForUser(name, if (def) 1 else 0, userHandle) != 0
-
@Throws(SettingNotFoundException::class)
override fun getBool(name: String) = getBoolForUser(name, userId)
-
/** Similar implementation to [getBool] for the specified [userHandle]. */
@Throws(SettingNotFoundException::class)
fun getBoolForUser(name: String, userHandle: Int): Boolean {
return getIntForUser(name, userHandle) != 0
}
-
override fun putBool(name: String, value: Boolean): Boolean {
return putBoolForUser(name, value, userId)
}
-
/** Similar implementation to [putBool] for the specified [userHandle]. */
fun putBoolForUser(name: String, value: Boolean, userHandle: Int) =
putIntForUser(name, if (value) 1 else 0, userHandle)
-
/** Similar implementation to [getLong] for the specified [userHandle]. */
fun getLongForUser(name: String, def: Long, userHandle: Int): Long {
val valString = getStringForUser(name, userHandle)
return parseLongOrUseDefault(valString, def)
}
-
/** Similar implementation to [getLong] for the specified [userHandle]. */
@Throws(SettingNotFoundException::class)
fun getLongForUser(name: String, userHandle: Int): Long {
val valString = getStringForUser(name, userHandle)
return parseLongOrThrow(name, valString)
}
-
/** Similar implementation to [putLong] for the specified [userHandle]. */
fun putLongForUser(name: String, value: Long, userHandle: Int) =
putStringForUser(name, value.toString(), userHandle)
-
/** Similar implementation to [getFloat] for the specified [userHandle]. */
fun getFloatForUser(name: String, def: Float, userHandle: Int): Float {
val v = getStringForUser(name, userHandle)
return parseFloat(v, def)
}
-
/** Similar implementation to [getFloat] for the specified [userHandle]. */
@Throws(SettingNotFoundException::class)
fun getFloatForUser(name: String, userHandle: Int): Float {
val v = getStringForUser(name, userHandle)
return parseFloatOrThrow(name, v)
}
-
/** Similar implementation to [putFloat] for the specified [userHandle]. */
fun putFloatForUser(name: String, value: Float, userHandle: Int) =
putStringForUser(name, value.toString(), userHandle)
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java b/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java
index ff18418..1d32a4f 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java
@@ -149,12 +149,12 @@
if (event == WALLET_PREFERENCE_CHANGE && mWalletPreferenceObserver != null) {
mWalletPreferenceChangeEvents--;
if (mWalletPreferenceChangeEvents == 0) {
- mSecureSettings.unregisterContentObserver(mWalletPreferenceObserver);
+ mSecureSettings.unregisterContentObserverSync(mWalletPreferenceObserver);
}
} else if (event == DEFAULT_PAYMENT_APP_CHANGE && mDefaultPaymentAppObserver != null) {
mDefaultPaymentAppChangeEvents--;
if (mDefaultPaymentAppChangeEvents == 0) {
- mSecureSettings.unregisterContentObserver(mDefaultPaymentAppObserver);
+ mSecureSettings.unregisterContentObserverSync(mDefaultPaymentAppObserver);
}
} else if (event == DEFAULT_WALLET_APP_CHANGE && mDefaultWalletAppObserver != null) {
mDefaultWalletAppChangeEvents--;
@@ -312,7 +312,7 @@
}
};
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT,
false /* notifyForDescendants */,
mDefaultPaymentAppObserver,
@@ -351,7 +351,7 @@
}
};
- mSecureSettings.registerContentObserverForUser(
+ mSecureSettings.registerContentObserverForUserSync(
QuickAccessWalletClientImpl.SETTING_KEY,
false /* notifyForDescendants */,
mWalletPreferenceObserver,
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
index 99b5a4b..cfa74f0 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
@@ -181,7 +181,7 @@
ArgumentCaptor.forClass(ContentObserver.class);
mController.init();
mExecutor.runAllReady();
- verify(mSecureSettings).registerContentObserverForUser(
+ verify(mSecureSettings).registerContentObserverForUserSync(
eq(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK),
anyBoolean(), observerCaptor.capture(), eq(UserHandle.USER_ALL));
ContentObserver observer = observerCaptor.getValue();
@@ -247,7 +247,7 @@
ArgumentCaptor.forClass(ContentObserver.class);
mController.init();
mExecutor.runAllReady();
- verify(mSecureSettings).registerContentObserverForUser(
+ verify(mSecureSettings).registerContentObserverForUserSync(
eq(Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED), anyBoolean(),
observerCaptor.capture(), eq(UserHandle.USER_ALL));
ContentObserver observer = observerCaptor.getValue();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java
index 92b06ba..138fed2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java
@@ -393,7 +393,7 @@
mWindowMagnificationSettings.showSettingPanel();
- verify(mSecureSettings).registerContentObserverForUser(
+ verify(mSecureSettings).registerContentObserverForUserSync(
eq(ACCESSIBILITY_MAGNIFICATION_CAPABILITY),
any(ContentObserver.class),
eq(UserHandle.USER_CURRENT));
@@ -408,7 +408,7 @@
mWindowMagnificationSettings.showSettingPanel();
mWindowMagnificationSettings.hideSettingPanel();
- verify(mSecureSettings).unregisterContentObserver(any(ContentObserver.class));
+ verify(mSecureSettings).unregisterContentObserverSync(any(ContentObserver.class));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FaceSettingsRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FaceSettingsRepositoryImplTest.kt
index 9ba56d2..6391986 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FaceSettingsRepositoryImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FaceSettingsRepositoryImplTest.kt
@@ -82,7 +82,12 @@
val keys =
captureMany<String> {
verify(secureSettings)
- .registerContentObserverForUser(capture(), anyBoolean(), any(), eq(USER_ID))
+ .registerContentObserverForUserSync(
+ capture(),
+ anyBoolean(),
+ any(),
+ eq(USER_ID)
+ )
}
assertThat(keys).containsExactly(FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION)
@@ -102,7 +107,7 @@
val observer =
withArgCaptor<ContentObserver> {
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(setting),
anyBoolean(),
capture(),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/settings/ControlsSettingsDialogManagerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/settings/ControlsSettingsDialogManagerImplTest.kt
index 590989d..154c373 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/settings/ControlsSettingsDialogManagerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/settings/ControlsSettingsDialogManagerImplTest.kt
@@ -332,7 +332,7 @@
}
private fun attachRepositoryToSettings() {
- secureSettings.registerContentObserver(
+ secureSettings.registerContentObserverSync(
SETTING_SHOW,
object : ContentObserver(null) {
override fun onChange(selfChange: Boolean) {
@@ -343,7 +343,7 @@
}
)
- secureSettings.registerContentObserver(
+ secureSettings.registerContentObserverSync(
SETTING_ACTION,
object : ContentObserver(null) {
override fun onChange(selfChange: Boolean) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt
index 16dd9af..e33d75c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt
@@ -50,7 +50,6 @@
import com.android.systemui.keyguard.shared.quickaffordance.ActivationState
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancesMetricsLogger
-import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.ActivityStarter
@@ -290,7 +289,6 @@
underTest =
KeyguardQuickAffordancesCombinedViewModel(
- applicationScope = kosmos.applicationCoroutineScope,
quickAffordanceInteractor =
KeyguardQuickAffordanceInteractor(
keyguardInteractor = keyguardInteractor,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerTest.kt
index 3ca5b42..f7b3f2e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerTest.kt
@@ -196,7 +196,7 @@
whenever(mediaFlags.isPersistentSsCardEnabled()).thenReturn(false)
MediaPlayerData.clear()
verify(globalSettings)
- .registerContentObserver(
+ .registerContentObserverSync(
eq(Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE)),
capture(settingsObserverCaptor)
)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
index 5e14b1a..820c3de 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
@@ -175,7 +175,7 @@
mTileLifecycleManagerFactory, mUserFileManager, mQSPipelineFlagsRepository);
mMainExecutor.runAllReady();
- mSecureSettings.registerContentObserverForUser(SETTING, new ContentObserver(null) {
+ mSecureSettings.registerContentObserverForUserSync(SETTING, new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinatorTest.java
index 8012768..dc9c22f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinatorTest.java
@@ -320,7 +320,7 @@
.thenReturn(1);
ArgumentCaptor<ContentObserver> contentObserverCaptor = ArgumentCaptor.forClass(
ContentObserver.class);
- verify(mSecureSettings).registerContentObserverForUser(eq(SHOW_NOTIFICATION_SNOOZE),
+ verify(mSecureSettings).registerContentObserverForUserSync(eq(SHOW_NOTIFICATION_SNOOZE),
contentObserverCaptor.capture(), anyInt());
ContentObserver contentObserver = contentObserverCaptor.getValue();
contentObserver.onChange(false);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt
index 7943872..2f77b33 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt
@@ -69,22 +69,21 @@
private val groupMembershipManager: GroupMembershipManager = mock()
private val section = NotifSection(mock(), 0)
- private val entry = NotificationEntryBuilder()
- .setSection(section)
- .setParent(GroupEntry.ROOT_ENTRY)
- .build()
+ private val entry =
+ NotificationEntryBuilder().setSection(section).setParent(GroupEntry.ROOT_ENTRY).build()
private lateinit var contentObserver: ContentObserver
- private val adjustmentProvider = NotifUiAdjustmentProvider(
- handler,
- secureSettings,
- lockscreenUserManager,
- sensitiveNotifProtectionController,
- sectionStyleProvider,
- userTracker,
- groupMembershipManager,
- )
+ private val adjustmentProvider =
+ NotifUiAdjustmentProvider(
+ handler,
+ secureSettings,
+ lockscreenUserManager,
+ sensitiveNotifProtectionController,
+ sectionStyleProvider,
+ userTracker,
+ groupMembershipManager,
+ )
@Before
fun setup() {
@@ -92,9 +91,8 @@
adjustmentProvider.addDirtyListener(dirtyListener)
verify(secureSettings).getIntForUser(eq(SHOW_NOTIFICATION_SNOOZE), any(), any())
contentObserver = withArgCaptor {
- verify(secureSettings).registerContentObserverForUser(
- eq(SHOW_NOTIFICATION_SNOOZE), capture(), any()
- )
+ verify(secureSettings)
+ .registerContentObserverForUserSync(eq(SHOW_NOTIFICATION_SNOOZE), capture(), any())
}
verifyNoMoreInteractions(secureSettings, dirtyListener)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java
index 62bffdd..0d3ab86 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentInflaterTest.java
@@ -27,6 +27,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -50,7 +51,6 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.filters.Suppress;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.media.controls.util.MediaFeatureFlag;
@@ -81,7 +81,6 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
@RunWithLooper(setAsMainLooper = true)
-@Suppress
public class NotificationContentInflaterTest extends SysuiTestCase {
private NotificationContentInflater mNotificationInflater;
@@ -128,7 +127,7 @@
TestableLooper.get(this));
ExpandableNotificationRow row = mHelper.createRow(mBuilder.build());
mRow = spy(row);
- when(mNotifLayoutInflaterFactoryProvider.provide(any(), any()))
+ when(mNotifLayoutInflaterFactoryProvider.provide(any(), anyInt()))
.thenReturn(mNotifLayoutInflaterFactory);
mNotificationInflater = new NotificationContentInflater(
@@ -282,6 +281,7 @@
}
@Test
+ @Ignore
public void testUsesSameViewWhenCachedPossibleToReuse() throws Exception {
// GIVEN a cached view.
RemoteViews contractedRemoteView = mBuilder.createContentView();
@@ -347,6 +347,7 @@
}
@Test
+ @Ignore
public void testNotificationViewHeightTooSmallFailsValidation() {
View view = mock(View.class);
when(view.getHeight())
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSettingsControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSettingsControllerTest.kt
index 352b79f..310fa67 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSettingsControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSettingsControllerTest.kt
@@ -102,6 +102,7 @@
verify(userTracker).addCallback(any(), any())
verify(dumpManager).registerNormalDumpable(anyString(), eq(controller))
}
+
@Test
fun updateContentObserverRegistration_onUserChange_noSettingsListeners() {
verify(userTracker).addCallback(capture(userTrackerCallbackCaptor), any())
@@ -112,10 +113,11 @@
userCallback.onUserChanged(userId, context)
// Validate: Nothing to do, since we aren't monitoring settings
- verify(secureSettings, never()).unregisterContentObserver(any())
+ verify(secureSettings, never()).unregisterContentObserverSync(any())
verify(secureSettings, never())
- .registerContentObserverForUser(any(Uri::class.java), anyBoolean(), any(), anyInt())
+ .registerContentObserverForUserSync(any(Uri::class.java), anyBoolean(), any(), anyInt())
}
+
@Test
fun updateContentObserverRegistration_onUserChange_withSettingsListeners() {
// When: someone is listening to a setting
@@ -129,9 +131,9 @@
userCallback.onUserChanged(userId, context)
// Validate: The tracker is unregistered and re-registered with the new user
- verify(secureSettings).unregisterContentObserver(any())
+ verify(secureSettings).unregisterContentObserverSync(any())
verify(secureSettings)
- .registerContentObserverForUser(eq(settingUri1), eq(false), any(), eq(userId))
+ .registerContentObserverForUserSync(eq(settingUri1), eq(false), any(), eq(userId))
}
@Test
@@ -140,7 +142,7 @@
verifyZeroInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(settingUri1),
eq(false),
any(),
@@ -149,7 +151,7 @@
controller.addCallback(settingUri1, Mockito.mock(Listener::class.java))
verify(secureSettings)
- .registerContentObserverForUser(any(Uri::class.java), anyBoolean(), any(), anyInt())
+ .registerContentObserverForUserSync(any(Uri::class.java), anyBoolean(), any(), anyInt())
}
@Test
@@ -158,7 +160,7 @@
verifyZeroInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(settingUri1),
eq(false),
any(),
@@ -170,7 +172,7 @@
verifyNoMoreInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(settingUri2),
eq(false),
any(),
@@ -186,7 +188,7 @@
verifyZeroInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
eq(settingUri1),
eq(false),
any(),
@@ -198,18 +200,18 @@
verifyNoMoreInteractions(secureSettings)
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(eq(settingUri2), anyBoolean(), any(), anyInt())
+ .registerContentObserverForUserSync(eq(settingUri2), anyBoolean(), any(), anyInt())
clearInvocations(secureSettings)
controller.removeCallback(settingUri2, listenerSetting2)
testableLooper.processAllMessages()
- verify(secureSettings, never()).unregisterContentObserver(any())
+ verify(secureSettings, never()).unregisterContentObserverSync(any())
clearInvocations(secureSettings)
controller.removeCallback(settingUri1, listenerSetting1)
verifyNoMoreInteractions(secureSettings)
testableLooper.processAllMessages()
- verify(secureSettings).unregisterContentObserver(any())
+ verify(secureSettings).unregisterContentObserverSync(any())
}
@Test
@@ -253,7 +255,7 @@
testableLooper.processAllMessages()
verify(secureSettings)
- .registerContentObserverForUser(
+ .registerContentObserverForUserSync(
any(Uri::class.java),
anyBoolean(),
capture(settingsObserverCaptor),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
index 5ad88ad..d2c1dd5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
@@ -202,7 +202,7 @@
verify(mWakefulnessLifecycle).addObserver(mWakefulnessLifecycleObserver.capture());
verify(mDumpManager).registerDumpable(any(), any());
verify(mDeviceProvisionedController).addCallback(mDeviceProvisionedListener.capture());
- verify(mSecureSettings).registerContentObserverForUser(
+ verify(mSecureSettings).registerContentObserverForUserSync(
eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES),
eq(false), mSettingsObserver.capture(), eq(UserHandle.USER_ALL)
);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/settings/FakeSettingsTest.java b/packages/SystemUI/tests/src/com/android/systemui/util/settings/FakeSettingsTest.java
index 99f6303..25a44e3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/settings/FakeSettingsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/settings/FakeSettingsTest.java
@@ -83,7 +83,7 @@
@Test
public void testRegisterContentObserver() {
- mFakeSettings.registerContentObserver("cat", mContentObserver);
+ mFakeSettings.registerContentObserverSync("cat", mContentObserver);
mFakeSettings.putString("cat", "hat");
@@ -93,7 +93,7 @@
@Test
public void testRegisterContentObserverAllUsers() {
- mFakeSettings.registerContentObserverForUser(
+ mFakeSettings.registerContentObserverForUserSync(
mFakeSettings.getUriFor("cat"), false, mContentObserver, UserHandle.USER_ALL);
mFakeSettings.putString("cat", "hat");
@@ -104,8 +104,8 @@
@Test
public void testUnregisterContentObserver() {
- mFakeSettings.registerContentObserver("cat", mContentObserver);
- mFakeSettings.unregisterContentObserver(mContentObserver);
+ mFakeSettings.registerContentObserverSync("cat", mContentObserver);
+ mFakeSettings.unregisterContentObserverSync(mContentObserver);
mFakeSettings.putString("cat", "hat");
@@ -115,9 +115,9 @@
@Test
public void testUnregisterContentObserverAllUsers() {
- mFakeSettings.registerContentObserverForUser(
+ mFakeSettings.registerContentObserverForUserSync(
mFakeSettings.getUriFor("cat"), false, mContentObserver, UserHandle.USER_ALL);
- mFakeSettings.unregisterContentObserver(mContentObserver);
+ mFakeSettings.unregisterContentObserverSync(mContentObserver);
mFakeSettings.putString("cat", "hat");
@@ -128,7 +128,7 @@
@Test
public void testContentObserverDispatchCorrectUser() {
int user = 10;
- mFakeSettings.registerContentObserverForUser(
+ mFakeSettings.registerContentObserverForUserSync(
mFakeSettings.getUriFor("cat"), false, mContentObserver, UserHandle.USER_ALL
);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/settings/SettingsProxyTest.kt b/packages/SystemUI/tests/src/com/android/systemui/util/settings/SettingsProxyTest.kt
index ab95707..eb11e38 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/settings/SettingsProxyTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/settings/SettingsProxyTest.kt
@@ -52,14 +52,14 @@
@Test
fun registerContentObserver_inputString_success() {
- mSettings.registerContentObserver(TEST_SETTING, mContentObserver)
+ mSettings.registerContentObserverSync(TEST_SETTING, mContentObserver)
verify(mSettings.getContentResolver())
.registerContentObserver(eq(TEST_SETTING_URI), eq(false), eq(mContentObserver))
}
@Test
fun registerContentObserver_inputString_notifyForDescendants_true() {
- mSettings.registerContentObserver(
+ mSettings.registerContentObserverSync(
TEST_SETTING,
notifyForDescendants = true,
mContentObserver
@@ -70,14 +70,14 @@
@Test
fun registerContentObserver_inputUri_success() {
- mSettings.registerContentObserver(TEST_SETTING_URI, mContentObserver)
+ mSettings.registerContentObserverSync(TEST_SETTING_URI, mContentObserver)
verify(mSettings.getContentResolver())
.registerContentObserver(eq(TEST_SETTING_URI), eq(false), eq(mContentObserver))
}
@Test
fun registerContentObserver_inputUri_notifyForDescendants_true() {
- mSettings.registerContentObserver(
+ mSettings.registerContentObserverSync(
TEST_SETTING_URI,
notifyForDescendants = true,
mContentObserver
@@ -88,7 +88,7 @@
@Test
fun unregisterContentObserver() {
- mSettings.unregisterContentObserver(mContentObserver)
+ mSettings.unregisterContentObserverSync(mContentObserver)
verify(mSettings.getContentResolver()).unregisterContentObserver(eq(mContentObserver))
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/settings/UserSettingsProxyTest.kt b/packages/SystemUI/tests/src/com/android/systemui/util/settings/UserSettingsProxyTest.kt
index 56328b9..38469ee 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/settings/UserSettingsProxyTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/settings/UserSettingsProxyTest.kt
@@ -58,7 +58,7 @@
@Test
fun registerContentObserverForUser_inputString_success() {
- mSettings.registerContentObserverForUser(
+ mSettings.registerContentObserverForUserSync(
TEST_SETTING,
mContentObserver,
mUserTracker.userId
@@ -74,7 +74,7 @@
@Test
fun registerContentObserverForUser_inputString_notifyForDescendants_true() {
- mSettings.registerContentObserverForUser(
+ mSettings.registerContentObserverForUserSync(
TEST_SETTING,
notifyForDescendants = true,
mContentObserver,
@@ -91,7 +91,7 @@
@Test
fun registerContentObserverForUser_inputUri_success() {
- mSettings.registerContentObserverForUser(
+ mSettings.registerContentObserverForUserSync(
TEST_SETTING_URI,
mContentObserver,
mUserTracker.userId
@@ -107,7 +107,7 @@
@Test
fun registerContentObserverForUser_inputUri_notifyForDescendants_true() {
- mSettings.registerContentObserverForUser(
+ mSettings.registerContentObserverForUserSync(
TEST_SETTING_URI,
notifyForDescendants = true,
mContentObserver,
@@ -124,14 +124,14 @@
@Test
fun registerContentObserver_inputUri_success() {
- mSettings.registerContentObserver(TEST_SETTING_URI, mContentObserver)
+ mSettings.registerContentObserverSync(TEST_SETTING_URI, mContentObserver)
verify(mSettings.getContentResolver())
.registerContentObserver(eq(TEST_SETTING_URI), eq(false), eq(mContentObserver), eq(0))
}
@Test
fun registerContentObserver_inputUri_notifyForDescendants_true() {
- mSettings.registerContentObserver(
+ mSettings.registerContentObserverSync(
TEST_SETTING_URI,
notifyForDescendants = true,
mContentObserver
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorKosmos.kt
index cd2710e..fb983f7 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorKosmos.kt
@@ -21,6 +21,7 @@
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.applicationCoroutineScope
+import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.settings.userTracker
import com.android.systemui.user.domain.interactor.selectedUserInteractor
import com.android.systemui.util.mockito.mock
@@ -29,6 +30,7 @@
CommunalSettingsInteractor(
bgScope = applicationCoroutineScope,
bgExecutor = fakeExecutor,
+ bgDispatcher = testDispatcher,
repository = communalSettingsRepository,
userInteractor = selectedUserInteractor,
userTracker = userTracker,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeGlobalSettings.java b/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeGlobalSettings.java
index beabaf5..3a70cdf 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeGlobalSettings.java
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeGlobalSettings.java
@@ -44,7 +44,7 @@
}
@Override
- public void registerContentObserver(Uri uri, boolean notifyDescendants,
+ public void registerContentObserverSync(Uri uri, boolean notifyDescendants,
ContentObserver settingsObserver) {
List<ContentObserver> observers;
mContentObserversAllUsers.putIfAbsent(uri.toString(), new ArrayList<>());
@@ -53,7 +53,7 @@
}
@Override
- public void unregisterContentObserver(ContentObserver settingsObserver) {
+ public void unregisterContentObserverSync(ContentObserver settingsObserver) {
for (Map.Entry<String, List<ContentObserver>> entry :
mContentObserversAllUsers.entrySet()) {
entry.getValue().remove(settingsObserver);
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeSettings.java b/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeSettings.java
index a491886..cd219ec 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeSettings.java
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeSettings.java
@@ -66,7 +66,7 @@
}
@Override
- public void registerContentObserverForUser(Uri uri, boolean notifyDescendants,
+ public void registerContentObserverForUserSync(Uri uri, boolean notifyDescendants,
ContentObserver settingsObserver, int userHandle) {
List<ContentObserver> observers;
if (userHandle == UserHandle.USER_ALL) {
@@ -81,7 +81,7 @@
}
@Override
- public void unregisterContentObserver(ContentObserver settingsObserver) {
+ public void unregisterContentObserverSync(ContentObserver settingsObserver) {
for (SettingsKey key : mContentObservers.keySet()) {
List<ContentObserver> observers = mContentObservers.get(key);
observers.remove(settingsObserver);
diff --git a/services/core/java/com/android/server/notification/DefaultDeviceEffectsApplier.java b/services/core/java/com/android/server/notification/DefaultDeviceEffectsApplier.java
index 27b8574..d060f8f2 100644
--- a/services/core/java/com/android/server/notification/DefaultDeviceEffectsApplier.java
+++ b/services/core/java/com/android/server/notification/DefaultDeviceEffectsApplier.java
@@ -32,12 +32,13 @@
import android.service.notification.ZenDeviceEffects;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ConfigChangeOrigin;
+import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
/** Default implementation for {@link DeviceEffectsApplier}. */
class DefaultDeviceEffectsApplier implements DeviceEffectsApplier {
-
+ private static final String TAG = "DeviceEffectsApplier";
private static final String SUPPRESS_AMBIENT_DISPLAY_TOKEN =
"DefaultDeviceEffectsApplier:SuppressAmbientDisplay";
private static final int SATURATION_LEVEL_GRAYSCALE = 0;
@@ -75,28 +76,44 @@
Binder.withCleanCallingIdentity(() -> {
if (mLastAppliedEffects.shouldSuppressAmbientDisplay()
!= effects.shouldSuppressAmbientDisplay()) {
- mPowerManager.suppressAmbientDisplay(SUPPRESS_AMBIENT_DISPLAY_TOKEN,
- effects.shouldSuppressAmbientDisplay());
+ try {
+ mPowerManager.suppressAmbientDisplay(SUPPRESS_AMBIENT_DISPLAY_TOKEN,
+ effects.shouldSuppressAmbientDisplay());
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change AOD override", e);
+ }
}
if (mLastAppliedEffects.shouldDisplayGrayscale() != effects.shouldDisplayGrayscale()) {
if (mColorDisplayManager != null) {
- mColorDisplayManager.setSaturationLevel(
- effects.shouldDisplayGrayscale() ? SATURATION_LEVEL_GRAYSCALE
- : SATURATION_LEVEL_FULL_COLOR);
+ try {
+ mColorDisplayManager.setSaturationLevel(
+ effects.shouldDisplayGrayscale() ? SATURATION_LEVEL_GRAYSCALE
+ : SATURATION_LEVEL_FULL_COLOR);
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change grayscale override", e);
+ }
}
}
if (mLastAppliedEffects.shouldDimWallpaper() != effects.shouldDimWallpaper()) {
if (mWallpaperManager != null) {
- mWallpaperManager.setWallpaperDimAmount(
- effects.shouldDimWallpaper() ? WALLPAPER_DIM_AMOUNT_DIMMED
- : WALLPAPER_DIM_AMOUNT_NORMAL);
+ try {
+ mWallpaperManager.setWallpaperDimAmount(
+ effects.shouldDimWallpaper() ? WALLPAPER_DIM_AMOUNT_DIMMED
+ : WALLPAPER_DIM_AMOUNT_NORMAL);
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change wallpaper override", e);
+ }
}
}
if (mLastAppliedEffects.shouldUseNightMode() != effects.shouldUseNightMode()) {
- updateOrScheduleNightMode(effects.shouldUseNightMode(), origin);
+ try {
+ updateOrScheduleNightMode(effects.shouldUseNightMode(), origin);
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change dark theme override", e);
+ }
}
});
@@ -131,9 +148,13 @@
private void updateNightModeImmediately(boolean useNightMode) {
Binder.withCleanCallingIdentity(() -> {
- mUiModeManager.setAttentionModeThemeOverlay(
- useNightMode ? MODE_ATTENTION_THEME_OVERLAY_NIGHT
- : MODE_ATTENTION_THEME_OVERLAY_OFF);
+ try {
+ mUiModeManager.setAttentionModeThemeOverlay(
+ useNightMode ? MODE_ATTENTION_THEME_OVERLAY_NIGHT
+ : MODE_ATTENTION_THEME_OVERLAY_OFF);
+ } catch (Exception e) {
+ Slog.e(TAG, "Could not change wallpaper override", e);
+ }
});
}
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index ae29e1b..454bd20 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -149,6 +149,8 @@
private static final String IMPLICIT_RULE_ID_PREFIX = "implicit_"; // + pkg_name
+ private static final int MAX_ICON_RESOURCE_NAME_LENGTH = 1000;
+
/**
* Send new activation AutomaticZenRule statuses to apps with a min target SDK version
*/
@@ -2645,7 +2647,13 @@
requireNonNull(packageName);
try {
final Resources res = mPm.getResourcesForApplication(packageName);
- return res.getResourceName(resId);
+ String resourceName = res.getResourceName(resId);
+ if (resourceName != null && resourceName.length() > MAX_ICON_RESOURCE_NAME_LENGTH) {
+ Slog.e(TAG, "Resource name for ID=" + resId + " in package " + packageName
+ + " is too long (" + resourceName.length() + "); ignoring it");
+ return null;
+ }
+ return resourceName;
} catch (PackageManager.NameNotFoundException | Resources.NotFoundException e) {
Slog.e(TAG, "Resource name for ID=" + resId + " not found in package " + packageName
+ ". Resource IDs may change when the application is upgraded, and the system"
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/DefaultDeviceEffectsApplierTest.java b/services/tests/uiservicestests/src/com/android/server/notification/DefaultDeviceEffectsApplierTest.java
index bfbc81c..4bea95f 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/DefaultDeviceEffectsApplierTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/DefaultDeviceEffectsApplierTest.java
@@ -25,10 +25,12 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -322,4 +324,26 @@
argThat(filter -> Intent.ACTION_SCREEN_OFF.equals(filter.getAction(0))),
anyInt());
}
+
+ @Test
+ public void apply_servicesThrow_noCrash() {
+ mSetFlagsRule.enableFlags(android.app.Flags.FLAG_MODES_API);
+
+ doThrow(new RuntimeException()).when(mPowerManager)
+ .suppressAmbientDisplay(anyString(), anyBoolean());
+ doThrow(new RuntimeException()).when(mColorDisplayManager).setSaturationLevel(anyInt());
+ doThrow(new RuntimeException()).when(mWallpaperManager).setWallpaperDimAmount(anyFloat());
+ doThrow(new RuntimeException()).when(mUiModeManager).setAttentionModeThemeOverlay(anyInt());
+ mApplier = new DefaultDeviceEffectsApplier(mContext);
+
+ ZenDeviceEffects effects = new ZenDeviceEffects.Builder()
+ .setShouldSuppressAmbientDisplay(true)
+ .setShouldDimWallpaper(true)
+ .setShouldDisplayGrayscale(true)
+ .setShouldUseNightMode(true)
+ .build();
+ mApplier.apply(effects, UPDATE_ORIGIN_USER);
+
+ // No crashes
+ }
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
index e4188b0..72ace84 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
@@ -6168,6 +6168,23 @@
.isEqualTo(previousManualZenPolicy);
}
+ @Test
+ @EnableFlags(Flags.FLAG_MODES_API)
+ public void addRule_iconIdWithResourceNameTooLong_ignoresIcon() {
+ int resourceId = 999;
+ String veryLongResourceName = "com.android.server.notification:drawable/"
+ + "omg_this_is_one_long_resource_name".repeat(100);
+ when(mResources.getResourceName(resourceId)).thenReturn(veryLongResourceName);
+ when(mResources.getIdentifier(veryLongResourceName, null, null)).thenReturn(resourceId);
+
+ String ruleId = mZenModeHelper.addAutomaticZenRule(mContext.getPackageName(),
+ new AutomaticZenRule.Builder("Rule", CONDITION_ID).setIconResId(resourceId).build(),
+ UPDATE_ORIGIN_APP, "reason", CUSTOM_PKG_UID);
+ AutomaticZenRule storedRule = mZenModeHelper.getAutomaticZenRule(ruleId);
+
+ assertThat(storedRule.getIconResId()).isEqualTo(0);
+ }
+
private static void addZenRule(ZenModeConfig config, String id, String ownerPkg, int zenMode,
@Nullable ZenPolicy zenPolicy) {
ZenRule rule = new ZenRule();