diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index 47e4b49e519de516735ce3c76e7f2bab71066656..f688d4f17841a90cb3a85a400aa8abc34ffb304b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -308,14 +308,14 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS 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 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS 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 ca24ccb3e6ec0eb1b97c57923703ae88e73da9cd..f2a68a8d9fd7bde2e0f63021e22bca859f819ad8 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 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest } // Unregister observer before removing view - mSecureSettings.unregisterContentObserver(mMagnificationCapabilityObserver); + mSecureSettings.unregisterContentObserverSync(mMagnificationCapabilityObserver); mWindowManager.removeView(mSettingView); mIsVisible = false; if (resetPosition) { @@ -380,7 +380,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest 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 eb840f1f4c901ed418dbbe7d58405a6285211c5b..ffb5f3d47bcc0611fd56383eb1288aab74b355da 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 @@ class MenuInfoRepository { } 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 91bc0c14477370c39e58f8de8963d5d860f668d0..eaf541d7b5592c2291e391096fc9e4099c714079 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.SeekBar 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 javax.inject.Inject 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 @@ class FontScalingDialogDelegate @Inject constructor( 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 @@ class FontScalingDialogDelegate @Inject constructor( } ) doneButton.setOnClickListener { dialog.dismiss() } - systemSettings.registerContentObserver(Settings.System.FONT_SCALE, fontSizeObserver) + systemSettings.registerContentObserverSync(Settings.System.FONT_SCALE, fontSizeObserver) } /** @@ -165,7 +167,7 @@ class FontScalingDialogDelegate @Inject constructor( 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 68c4a10fcfad6f771fbf7b4d4b0bf3abc8105929..2970890c3fa73cfc99af0ee75020e70facef916f 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 @@ private fun SecureSettings.watch( ) { 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/complication/ComplicationTypesUpdater.java b/packages/SystemUI/src/com/android/systemui/complication/ComplicationTypesUpdater.java index 0bdc7f1dfb96704a1b9a82b9ba04d0f50b23f3a1..84807fbc8ece2e80fd2cc23e6c510245ee84fd89 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 @@ public class ComplicationTypesUpdater extends ConditionalCoreStartable { } }; - 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/doze/DozeSensors.java b/packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java index 3194942527867b5e2c39537dc1d85d78d7a21f51..7ae840938fe78d6485ddc3b1e1ca903eff54cc3c 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 @@ public class DozeSensors { } if (!anyListening) { - mSecureSettings.unregisterContentObserver(mSettingsObserver); + mSecureSettings.unregisterContentObserverSync(mSettingsObserver); } else if (!mSettingRegistered) { for (TriggerSensor s : mTriggerSensors) { s.registerSettingsObserver(mSettingsObserver); @@ -750,7 +750,7 @@ public class DozeSensors { 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 49be03cb08adea8cea170d82407fe9652eb81fc9..1e4fb4f1506292cca22357e9d475841f8113ca79 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 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene // 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 class GlobalActionsDialogLite implements DialogInterface.OnDismissListene 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/media/controls/ui/controller/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt index 7bacdeb998087aa6c2abf29e71d111c1e0d4d700..edead51dd8e07a5fce219d34a1aee0a2892879a5 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 @@ constructor( 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 6589038d7096d41a5be9d3b0b5810be85b4718ae..601d563ffc458060ed0a32b516a03c381c6faf75 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 @@ constructor( 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 @@ constructor( } } } - 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 2d460a0d28fbe2d27af287bfb59035d62796c758..765b45bdbf2e032ccde01ec603f5731bba7734dc 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 @@ public class QRCodeScannerController implements } 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 @@ public class QRCodeScannerController implements }); } }); - 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 2fafba1f188a76a6af3485f473ff65907136f19a..e4bafcd9fdb3bc4aafc5d38e740a3c4abd9b5924 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 @@ private const val DELIMITER = "," * * 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 @@ class AutoAddTracker @VisibleForTesting constructor( 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 @@ class AutoAddTracker @VisibleForTesting constructor( } 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 @@ class AutoAddTracker @VisibleForTesting constructor( 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 @@ class AutoAddTracker @VisibleForTesting constructor( 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 @@ class AutoAddTracker @VisibleForTesting constructor( * 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 @@ class AutoAddTracker @VisibleForTesting constructor( * 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 @@ class AutoAddTracker @VisibleForTesting constructor( 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 @@ class AutoAddTracker @VisibleForTesting constructor( } @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 @@ class AutoAddTracker @VisibleForTesting constructor( 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 4fc660948926bb5bdcffae83ba1da6b5c2751cf0..846d63f10875be59fb35f074d964ee62fda1ee60 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 class ReduceBrightColorsControllerImpl implements 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 @@ public class ReduceBrightColorsControllerImpl implements 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 class ReduceBrightColorsControllerImpl implements 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 eb11568614b7e21c5074c65f287ee256a556b1ad..6092348b964e8ba69f774f7d48e8e62e9eb3e428 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 @@ public abstract class SettingObserver extends ContentObserver implements Listena 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 539c2d6e64da65be8f56cf26d95ad687e41e5eaa..1b34c33c9ca0593b02faa8ce53239c8862109088 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 @@ public abstract class UserSettingObserver extends ContentObserver implements Lis 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 d452241e86e212c72a6670ebf2e04c146d62f9bc..9fcb0db0c88d076beac05634197f1c3d46010611 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 @@ constructor( @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 @@ constructor( 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 aca8733bff7bc0646d4933ebed9d031cc32c8de2..1f9570a5722e3bfdeb2e8b17567cbec37520cb5b 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 @@ constructor( 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 3c0aa384d98c43225b38523082f77cb95fb971d8..09fd7df15dc2aefe5f2297979421a0832bd9e242 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 @@ constructor( } } - 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 37f2a21b145ee15bda4cc62bd432042ded8787f5..498107624f9b7081dce18e8439f27d61e3c5f034 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 class BrightnessController implements ToggleSlider.Listener, MirroredBrig 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 95768e55de3405edcfedfa6148f261fc81f73f4d..2dfc920b4f20b04b8b56460e25841a6e0a8199b6 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 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca }; // 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 4c2ef83227317f58f7e63914bd5c602e1626587d..4c82bc193c773814164eba50c98e73b14647b443 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 com.android.systemui.util.settings.SecureSettings 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 @@ class NotifUiAdjustmentProvider @Inject constructor( 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 @@ class NotifUiAdjustmentProvider @Inject constructor( ) } updateSnoozeEnabled() - secureSettings.registerContentObserverForUser( + secureSettings.registerContentObserverForUserSync( SHOW_NOTIFICATION_SNOOZE, settingsObserver, UserHandle.USER_ALL @@ -93,7 +94,7 @@ class NotifUiAdjustmentProvider @Inject constructor( onSensitiveStateChangedListener ) } - secureSettings.unregisterContentObserver(settingsObserver) + secureSettings.unregisterContentObserverSync(settingsObserver) } } @@ -104,12 +105,13 @@ class NotifUiAdjustmentProvider @Inject constructor( 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 @@ class NotifUiAdjustmentProvider @Inject constructor( } /** - * 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 42a5bdf0f19ba8234dd45d7c9ee7e8bb8a1f3a92..f84b5f48c864131e4a032a56323c8ba4d9561074 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.os.PowerManager 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 @@ class PeekDisabledSuppressor( } } - globalSettings.registerContentObserver( + globalSettings.registerContentObserverSync( globalSettings.getUriFor(HEADS_UP_NOTIFICATIONS_ENABLED), /* notifyForDescendants = */ true, observer @@ -94,7 +94,7 @@ class PeekDisabledSuppressor( // 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 @@ class AlertKeyguardVisibilitySuppressor( override fun shouldSuppress(entry: NotificationEntry) = keyguardNotificationVisibilityProvider.shouldHideNotification(entry) } + class AvalancheSuppressor( private val avalancheProvider: AvalancheProvider, private val systemClock: SystemClock, @@ -268,38 +269,33 @@ class AvalancheSuppressor( 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 332ece428a6e6ed54ec8675de7411b2802058dbf..c7548aae713191109206ae56105083730cee16a7 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.CoreStartable 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 @@ import javax.inject.Inject /** 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 @@ object KeyguardNotificationVisibilityProviderModule @Module interface KeyguardNotificationVisibilityProviderImplModule { @Binds - fun bindImpl(impl: KeyguardNotificationVisibilityProviderImpl): - KeyguardNotificationVisibilityProvider + fun bindImpl( + impl: KeyguardNotificationVisibilityProviderImpl + ): KeyguardNotificationVisibilityProvider @Binds @IntoMap @@ -71,7 +71,9 @@ interface KeyguardNotificationVisibilityProviderImplModule { } @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 @@ class KeyguardNotificationVisibilityProviderImpl @Inject constructor( 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") - } - override fun onUpcomingStateChanged(state: Int) { - notifyStateChanged("onStatusBarUpcomingStateChanged") + statusBarStateController.addCallback( + object : StatusBarStateController.StateListener { + override fun onStateChanged(newState: Int) { + notifyStateChanged("onStatusBarStateChanged") + } + + override fun onUpcomingStateChanged(state: Int) { + notifyStateChanged("onStatusBarUpcomingStateChanged") + } } - }) + ) userTracker.addCallback(userTrackerCallback, HandlerExecutor(handler)) } @@ -169,45 +183,48 @@ class KeyguardNotificationVisibilityProviderImpl @Inject constructor( 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 @@ class KeyguardNotificationVisibilityProviderImpl @Inject constructor( // 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 74925c8dd5066210ecd276588252fa8956556392..fea360d4e02a8420effbca4ab1acb34050699841 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 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter }; 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 a17c066953e1c8c5f4b2f35235f0187f6c9c9f4f..30dbfed0349f6fe86543034a5f8231d5b0c44943 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 @@ public class NotificationSettingsController implements Dumpable { 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 @@ public class NotificationSettingsController implements Dumpable { mListeners.put(uri, currentListeners); if (currentListeners.size() == 1) { mBackgroundHandler.post(() -> { - mSecureSettings.registerContentObserverForUser( + mSecureSettings.registerContentObserverForUserSync( uri, false, mContentObserver, mUserTracker.getUserId()); }); } @@ -159,7 +159,7 @@ public class NotificationSettingsController implements Dumpable { if (mListeners.size() == 0) { mBackgroundHandler.post(() -> { - mSecureSettings.unregisterContentObserver(mContentObserver); + mSecureSettings.unregisterContentObserverSync(mContentObserver); }); } } 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 6d4301f8475ffcc24fa7b6c19d349c5208f4e796..e44edcbd4ebb2e2fe4fe1477aab5a683ae094678 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 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat 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 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat 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 479aef167b5bfb61a153a61d94ea972a5d66890f..c53558ea7fd2dec2eb4a09f34b98b8e7ee39b779 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.dagger.SysUISingleton 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 @@ constructor( 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 @@ constructor( // 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 aac211ae6b46ffe03fc56fb52f043fb64c9a70e3..3d8090d70faa97ac8b487993f3d73b7af489c15b 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.CarrierConfigChangedListen 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 java.util.concurrent.Executor; 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 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue initOngoingCallChip(); mAnimationScheduler.addCallback(this); - mSecureSettings.registerContentObserverForUser( + mSecureSettings.registerContentObserverForUserSync( Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, false, mVolumeSettingObserver, @@ -445,7 +445,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue 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 4bd868179fafbc963bf122f02ff6b865ef771f63..fad5df827ffa1b30a6887843eeccccb6abd4c959 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 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } } }; - 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 8b63dfe28f08d400397d03c4f5af49260fd10023..8123f8f3bd3d13d8984f7a3a3947adaadf6e9a76 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 java.util.concurrent.atomic.AtomicBoolean 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 @@ open class DeviceProvisionedControllerImpl @Inject constructor( 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 @@ open class DeviceProvisionedControllerImpl @Inject constructor( 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 @@ open class DeviceProvisionedControllerImpl @Inject constructor( 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 @@ open class DeviceProvisionedControllerImpl @Inject constructor( * 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 @@ open class DeviceProvisionedControllerImpl @Inject constructor( } 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 @@ open class DeviceProvisionedControllerImpl @Inject constructor( 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 @@ open class DeviceProvisionedControllerImpl @Inject constructor( 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 9eee5d00f7085ecefb2a9e96e94b33e05c8c2d34..f57b69639677116e19f94e7e38423f10da9f18e4 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 @@ public class LocationControllerImpl extends BroadcastReceiver implements Locatio }; // 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 40bb67f2e7464ebe2d25ab06b5c0b1f388fad2a4..9ab8175e13b8c880a837614078d7d4f94fde847e 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 @@ public class SensitiveNotificationProtectionControllerImpl }); } }; - 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 600005b9761064b59a4ca3735874071cc0b311c7..e09e5777a9a364811a6d80d294997575b0560dd7 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 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { 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 7494649294f5ede69a9cbe5f3c1c819e8d77ce99..4963aae08ab74e0cee62ba240da220f47da18db7 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 @@ public class ThemeOverlayController implements CoreStartable, Dumpable { 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 ec89610ce014a29a67adfca40b12daf313ee98f3..ed522331baef4f69f501a12b369390140d3d1abd 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 @@ import android.provider.Settings.SettingNotFoundException 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 @@ interface SettingsProxy { * @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 @@ interface SettingsProxy { * @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 @@ interface SettingsProxy { * @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 @@ interface SettingsProxy { * @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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { } 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 @@ interface SettingsProxy { 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 @@ interface SettingsProxy { 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 74843685893cfaf35424de495b46bb4fe114d056..d757e33fcc29f3ddc2343d1fb1ba4c7179ffa5c1 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 @@ object SettingsProxyExt { } } - names.forEach { name -> registerContentObserverForUser(name, observer, userId) } + names.forEach { name -> registerContentObserverForUserSync(name, observer, userId) } - awaitClose { unregisterContentObserver(observer) } + awaitClose { unregisterContentObserverSync(observer) } } } @@ -57,9 +57,9 @@ object SettingsProxyExt { } } - 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 2285270b0bc7e42ed3554d17a1b742131ffe5745..ed139434d3bdfe0b85f8197b755fd4bccb2c36b8 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 @@ import com.android.systemui.util.settings.SettingsProxy.Companion.parseLongOrUse * 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 @@ interface UserSettingsProxy : SettingsProxy { "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 @@ interface UserSettingsProxy : SettingsProxy { 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 @@ interface UserSettingsProxy : SettingsProxy { Unit } } - /** * Look up a name in the database. * @@ -146,10 +136,8 @@ interface UserSettingsProxy : SettingsProxy { 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 @@ interface UserSettingsProxy : SettingsProxy { 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 @@ interface UserSettingsProxy : SettingsProxy { @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 @@ interface UserSettingsProxy : SettingsProxy { 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 @@ interface UserSettingsProxy : SettingsProxy { 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 ff1841819dea2fca158fa57290518331377177f4..1d32a4fd69d61e0ea9959a2495bfc2d009b72c59 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 @@ public class QuickAccessWalletController { 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 @@ public class QuickAccessWalletController { } }; - mSecureSettings.registerContentObserverForUser( + mSecureSettings.registerContentObserverForUserSync( Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT, false /* notifyForDescendants */, mDefaultPaymentAppObserver, @@ -351,7 +351,7 @@ public class QuickAccessWalletController { } }; - 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 99b5a4b631a7c10253c91cb33e078fde7f3403df..cfa74f0ef4322838ebab49ce6c10cb677f19d9b9 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 @@ public class KeyguardClockSwitchControllerTest extends KeyguardClockSwitchContro 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 @@ public class KeyguardClockSwitchControllerTest extends KeyguardClockSwitchContro 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 92b06ba3f714b4d7f5af85c72102fb0e4a080f72..138fed298ef14a78859c378bef941365f7cccd8e 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 @@ public class WindowMagnificationSettingsTest extends SysuiTestCase { mWindowMagnificationSettings.showSettingPanel(); - verify(mSecureSettings).registerContentObserverForUser( + verify(mSecureSettings).registerContentObserverForUserSync( eq(ACCESSIBILITY_MAGNIFICATION_CAPABILITY), any(ContentObserver.class), eq(UserHandle.USER_CURRENT)); @@ -408,7 +408,7 @@ public class WindowMagnificationSettingsTest extends SysuiTestCase { 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 9ba56d27fdf3deff29f156e9621b8018a1b3df5c..63919865d8abafdb6f1e0ba9ff98dc6d80a528c8 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 @@ class FaceSettingsRepositoryImplTest : SysuiTestCase() { 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 @@ class FaceSettingsRepositoryImplTest : SysuiTestCase() { 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 590989d3a9875e768602d34a58f42a9bcf8058d7..154c3734558d8999316f1ef7445b6c6df771c201 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 @@ class ControlsSettingsDialogManagerImplTest : SysuiTestCase() { } private fun attachRepositoryToSettings() { - secureSettings.registerContentObserver( + secureSettings.registerContentObserverSync( SETTING_SHOW, object : ContentObserver(null) { override fun onChange(selfChange: Boolean) { @@ -343,7 +343,7 @@ class ControlsSettingsDialogManagerImplTest : SysuiTestCase() { } ) - secureSettings.registerContentObserver( + secureSettings.registerContentObserverSync( SETTING_ACTION, object : ContentObserver(null) { override fun onChange(selfChange: Boolean) { 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 3ca5b421a7a433f4a5cce8471741cefd56d1d7e4..f7b3f2ea2804c61001a012f1618557a7a0798e41 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 @@ class MediaCarouselControllerTest : SysuiTestCase() { 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 5e14b1a60ddbae7a336ba865d53ce8b18a0aa1ca..820c3de50d75687cedf0eeb49ed59b107c84e6df 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 @@ public class QSTileHostTest extends SysuiTestCase { 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 80127682be02c492215ed0af10af687ce842dd46..dc9c22f566bf13dbb7f1854dc05f99a9220e1f24 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 @@ public class PreparationCoordinatorTest extends SysuiTestCase { .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 7943872558c35e76a126ce3280de085ee5464354..2f77b33c96cbe78eb86f9de4bcf756fcb439da7f 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 @@ class NotifUiAdjustmentProviderTest : SysuiTestCase() { 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 @@ class NotifUiAdjustmentProviderTest : SysuiTestCase() { 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/NotificationSettingsControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationSettingsControllerTest.kt index 352b79f50b902adf8caf5fc5ae33a9440f0bc3b1..310fa67a3c6b247ac378b2f5fa07548f24409289 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 @@ class NotificationSettingsControllerTest : SysuiTestCase() { 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 @@ class NotificationSettingsControllerTest : SysuiTestCase() { 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 @@ class NotificationSettingsControllerTest : SysuiTestCase() { 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 @@ class NotificationSettingsControllerTest : SysuiTestCase() { verifyZeroInteractions(secureSettings) testableLooper.processAllMessages() verify(secureSettings) - .registerContentObserverForUser( + .registerContentObserverForUserSync( eq(settingUri1), eq(false), any(), @@ -149,7 +151,7 @@ class NotificationSettingsControllerTest : SysuiTestCase() { 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 @@ class NotificationSettingsControllerTest : SysuiTestCase() { verifyZeroInteractions(secureSettings) testableLooper.processAllMessages() verify(secureSettings) - .registerContentObserverForUser( + .registerContentObserverForUserSync( eq(settingUri1), eq(false), any(), @@ -170,7 +172,7 @@ class NotificationSettingsControllerTest : SysuiTestCase() { verifyNoMoreInteractions(secureSettings) testableLooper.processAllMessages() verify(secureSettings) - .registerContentObserverForUser( + .registerContentObserverForUserSync( eq(settingUri2), eq(false), any(), @@ -186,7 +188,7 @@ class NotificationSettingsControllerTest : SysuiTestCase() { verifyZeroInteractions(secureSettings) testableLooper.processAllMessages() verify(secureSettings) - .registerContentObserverForUser( + .registerContentObserverForUserSync( eq(settingUri1), eq(false), any(), @@ -198,18 +200,18 @@ class NotificationSettingsControllerTest : SysuiTestCase() { 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 @@ class NotificationSettingsControllerTest : SysuiTestCase() { 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 5ad88ad1f47c62267965e70de07d25b9503a5ba7..d2c1dd50821eb17f08e6e653c667c22ac7d381c4 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 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { 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 99f6303ad73d89ace8bd07a90f8f144937009361..25a44e3cc80954542c7dfd40ed5efee3949e0a75 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 @@ public class FakeSettingsTest extends SysuiTestCase { @Test public void testRegisterContentObserver() { - mFakeSettings.registerContentObserver("cat", mContentObserver); + mFakeSettings.registerContentObserverSync("cat", mContentObserver); mFakeSettings.putString("cat", "hat"); @@ -93,7 +93,7 @@ public class FakeSettingsTest extends SysuiTestCase { @Test public void testRegisterContentObserverAllUsers() { - mFakeSettings.registerContentObserverForUser( + mFakeSettings.registerContentObserverForUserSync( mFakeSettings.getUriFor("cat"), false, mContentObserver, UserHandle.USER_ALL); mFakeSettings.putString("cat", "hat"); @@ -104,8 +104,8 @@ public class FakeSettingsTest extends SysuiTestCase { @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 @@ public class FakeSettingsTest extends SysuiTestCase { @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 @@ public class FakeSettingsTest extends SysuiTestCase { @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 ab95707046d9b4c41316193f898f9e3dc8a735e2..eb11e383d51942520f0f3e589071f4e37f198ed5 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 @@ class SettingsProxyTest : SysuiTestCase() { @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 @@ class SettingsProxyTest : SysuiTestCase() { @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 @@ class SettingsProxyTest : SysuiTestCase() { @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 56328b9336027b6e1dc8c85727a0a97ef766c5d7..38469ee7955d5d518be68dabdfd11e45af673ac1 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 @@ class UserSettingsProxyTest : SysuiTestCase() { @Test fun registerContentObserverForUser_inputString_success() { - mSettings.registerContentObserverForUser( + mSettings.registerContentObserverForUserSync( TEST_SETTING, mContentObserver, mUserTracker.userId @@ -74,7 +74,7 @@ class UserSettingsProxyTest : SysuiTestCase() { @Test fun registerContentObserverForUser_inputString_notifyForDescendants_true() { - mSettings.registerContentObserverForUser( + mSettings.registerContentObserverForUserSync( TEST_SETTING, notifyForDescendants = true, mContentObserver, @@ -91,7 +91,7 @@ class UserSettingsProxyTest : SysuiTestCase() { @Test fun registerContentObserverForUser_inputUri_success() { - mSettings.registerContentObserverForUser( + mSettings.registerContentObserverForUserSync( TEST_SETTING_URI, mContentObserver, mUserTracker.userId @@ -107,7 +107,7 @@ class UserSettingsProxyTest : SysuiTestCase() { @Test fun registerContentObserverForUser_inputUri_notifyForDescendants_true() { - mSettings.registerContentObserverForUser( + mSettings.registerContentObserverForUserSync( TEST_SETTING_URI, notifyForDescendants = true, mContentObserver, @@ -124,14 +124,14 @@ class UserSettingsProxyTest : SysuiTestCase() { @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/util/settings/FakeGlobalSettings.java b/packages/SystemUI/tests/utils/src/com/android/systemui/util/settings/FakeGlobalSettings.java index beabaf5f59545d695d04f2904cba999ea0e22e34..3a70cdfc42edea373a10da9f59fef5dd22907999 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 @@ public class FakeGlobalSettings implements GlobalSettings { } @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 @@ public class FakeGlobalSettings implements GlobalSettings { } @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 a49188687100df0370bffc0e993ea81341af53c4..cd219ec127fc4cc390103420765406d78474fe28 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 @@ public class FakeSettings implements SecureSettings, SystemSettings { } @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 @@ public class FakeSettings implements SecureSettings, SystemSettings { } @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);