diff options
9 files changed, 128 insertions, 119 deletions
diff --git a/packages/SystemUI/pods/Android.bp b/packages/SystemUI/pods/Android.bp index 1547ae26a85d..fba89621cdd0 100644 --- a/packages/SystemUI/pods/Android.bp +++ b/packages/SystemUI/pods/Android.bp @@ -31,7 +31,7 @@ java_defaults { warning_checks: ["MissingApacheLicenseDetector"], }, kotlincflags: [ - "-Xexplicit-api=warning", + "-Xexplicit-api=strict", "-Xjvm-default=all", ], defaults_visibility: [":__subpackages__"], diff --git a/packages/SystemUI/pods/com/android/systemui/retail/RetailModeModule.kt b/packages/SystemUI/pods/com/android/systemui/retail/RetailModeModule.kt index c20e368f1690..fe78bb3da9f4 100644 --- a/packages/SystemUI/pods/com/android/systemui/retail/RetailModeModule.kt +++ b/packages/SystemUI/pods/com/android/systemui/retail/RetailModeModule.kt @@ -24,11 +24,15 @@ import dagger.Binds import dagger.Module @Module -abstract class RetailModeModule { +public abstract class RetailModeModule { @Binds - abstract fun bindsRetailModeRepository(impl: RetailModeSettingsRepository): RetailModeRepository + public abstract fun bindsRetailModeRepository( + impl: RetailModeSettingsRepository + ): RetailModeRepository @Binds - abstract fun bindsRetailModeInteractor(impl: RetailModeInteractorImpl): RetailModeInteractor + public abstract fun bindsRetailModeInteractor( + impl: RetailModeInteractorImpl + ): RetailModeInteractor } diff --git a/packages/SystemUI/pods/com/android/systemui/retail/data/repository/RetailModeRepository.kt b/packages/SystemUI/pods/com/android/systemui/retail/data/repository/RetailModeRepository.kt index c9eac2588811..4fd69855f30b 100644 --- a/packages/SystemUI/pods/com/android/systemui/retail/data/repository/RetailModeRepository.kt +++ b/packages/SystemUI/pods/com/android/systemui/retail/data/repository/RetailModeRepository.kt @@ -19,11 +19,11 @@ package com.android.systemui.retail.data.repository import kotlinx.coroutines.flow.StateFlow /** Repository to track if the device is in Retail mode */ -interface RetailModeRepository { +public interface RetailModeRepository { /** Flow of whether the device is currently in retail mode. */ - val retailMode: StateFlow<Boolean> + public val retailMode: StateFlow<Boolean> /** Last value of whether the device is in retail mode. */ - val inRetailMode: Boolean + public val inRetailMode: Boolean get() = retailMode.value } diff --git a/packages/SystemUI/pods/com/android/systemui/retail/data/repository/impl/RetailModeSettingsRepository.kt b/packages/SystemUI/pods/com/android/systemui/retail/data/repository/impl/RetailModeSettingsRepository.kt index 8955263595f3..7296835d420e 100644 --- a/packages/SystemUI/pods/com/android/systemui/retail/data/repository/impl/RetailModeSettingsRepository.kt +++ b/packages/SystemUI/pods/com/android/systemui/retail/data/repository/impl/RetailModeSettingsRepository.kt @@ -38,17 +38,17 @@ import kotlinx.coroutines.flow.stateIn /** * Tracks [Settings.Global.DEVICE_DEMO_MODE]. * - * @see UserManager.isDeviceInDemoMode + * @see android.os.UserManager.isDeviceInDemoMode */ @SysUISingleton -class RetailModeSettingsRepository +public class RetailModeSettingsRepository @Inject constructor( globalSettings: GlobalSettings, @Background backgroundDispatcher: CoroutineDispatcher, @Application scope: CoroutineScope, ) : RetailModeRepository { - override val retailMode = + override val retailMode: StateFlow<Boolean> = conflatedCallbackFlow { val observer = object : ContentObserver(null) { @@ -66,7 +66,7 @@ constructor( .flowOn(backgroundDispatcher) .stateIn(scope, SharingStarted.Eagerly, false) - companion object { + public companion object { private const val RETAIL_MODE_SETTING = Settings.Global.DEVICE_DEMO_MODE } } diff --git a/packages/SystemUI/pods/com/android/systemui/retail/domain/interactor/RetailModeInteractor.kt b/packages/SystemUI/pods/com/android/systemui/retail/domain/interactor/RetailModeInteractor.kt index 748e34d430d8..3e44f8dbca76 100644 --- a/packages/SystemUI/pods/com/android/systemui/retail/domain/interactor/RetailModeInteractor.kt +++ b/packages/SystemUI/pods/com/android/systemui/retail/domain/interactor/RetailModeInteractor.kt @@ -17,7 +17,7 @@ package com.android.systemui.retail.domain.interactor /** Interactor to determine if the device is currently in retail mode */ -interface RetailModeInteractor { +public interface RetailModeInteractor { /** Whether the device is currently in retail mode */ - val isInRetailMode: Boolean + public val isInRetailMode: Boolean } diff --git a/packages/SystemUI/pods/com/android/systemui/retail/domain/interactor/impl/RetailModeInteractorImpl.kt b/packages/SystemUI/pods/com/android/systemui/retail/domain/interactor/impl/RetailModeInteractorImpl.kt index 8dbe562c2ed7..52b4bcc81976 100644 --- a/packages/SystemUI/pods/com/android/systemui/retail/domain/interactor/impl/RetailModeInteractorImpl.kt +++ b/packages/SystemUI/pods/com/android/systemui/retail/domain/interactor/impl/RetailModeInteractorImpl.kt @@ -22,11 +22,9 @@ import com.android.systemui.retail.domain.interactor.RetailModeInteractor import javax.inject.Inject @SysUISingleton -class RetailModeInteractorImpl +public class RetailModeInteractorImpl @Inject -constructor( - private val repository: RetailModeRepository, -) : RetailModeInteractor { +constructor(private val repository: RetailModeRepository) : RetailModeInteractor { override val isInRetailMode: Boolean get() = repository.inRetailMode } diff --git a/packages/SystemUI/pods/com/android/systemui/util/settings/SettingsProxy.kt b/packages/SystemUI/pods/com/android/systemui/util/settings/SettingsProxy.kt index 597276a66dfa..a8d4f7906115 100644 --- a/packages/SystemUI/pods/com/android/systemui/util/settings/SettingsProxy.kt +++ b/packages/SystemUI/pods/com/android/systemui/util/settings/SettingsProxy.kt @@ -19,6 +19,7 @@ import android.annotation.UserIdInt import android.content.ContentResolver import android.database.ContentObserver import android.net.Uri +import android.provider.Settings import android.provider.Settings.SettingNotFoundException import androidx.annotation.AnyThread import androidx.annotation.WorkerThread @@ -28,6 +29,7 @@ import com.android.app.tracing.coroutines.withContextTraced as withContext import kotlin.coroutines.coroutineContext import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job /** * Used to interact with mainly with Settings.Global, but can also be used for Settings.System and @@ -43,15 +45,15 @@ import kotlinx.coroutines.CoroutineScope * This class also provides [.registerContentObserver] methods, normally found on [ContentResolver] * instances, unifying setting related actions in one place. */ -interface SettingsProxy { +public interface SettingsProxy { /** Returns the [ContentResolver] this instance was constructed with. */ - fun getContentResolver(): ContentResolver + public fun getContentResolver(): ContentResolver /** Returns the [CoroutineScope] that the async APIs will use. */ - val settingsScope: CoroutineScope + public val settingsScope: CoroutineScope @OptIn(ExperimentalStdlibApi::class) - suspend fun executeOnSettingsScopeDispatcher(name: String, block: () -> Unit) { + public suspend fun executeOnSettingsScopeDispatcher(name: String, block: () -> Unit) { val settingsDispatcher = settingsScope.coroutineContext[CoroutineDispatcher] if ( settingsDispatcher != null && @@ -70,7 +72,7 @@ interface SettingsProxy { * @param name to look up in the table * @return the corresponding content URI, or null if not present */ - @AnyThread fun getUriFor(name: String): Uri + @AnyThread public fun getUriFor(name: String): Uri /** * Registers listener for a given content observer <b>while blocking the current thread</b>. @@ -80,7 +82,7 @@ interface SettingsProxy { * [registerContentObserverAsync] instead. */ @WorkerThread - fun registerContentObserverSync(name: String, settingsObserver: ContentObserver) { + public fun registerContentObserverSync(name: String, settingsObserver: ContentObserver) { registerContentObserverSync(getUriFor(name), settingsObserver) } @@ -91,7 +93,7 @@ interface SettingsProxy { * registration happens on a worker thread. Caller may wrap the API in an async block if they * wish to synchronize execution. */ - suspend fun registerContentObserver(name: String, settingsObserver: ContentObserver) { + public suspend fun registerContentObserver(name: String, settingsObserver: ContentObserver) { executeOnSettingsScopeDispatcher("registerContentObserver-A") { registerContentObserverSync(getUriFor(name), settingsObserver) } @@ -103,7 +105,7 @@ interface SettingsProxy { * API corresponding to [registerContentObserver] for Java usage. */ @AnyThread - fun registerContentObserverAsync(name: String, settingsObserver: ContentObserver) = + public fun registerContentObserverAsync(name: String, settingsObserver: ContentObserver): Job = settingsScope.launch("registerContentObserverAsync-A") { registerContentObserverSync(getUriFor(name), settingsObserver) } @@ -116,11 +118,11 @@ interface SettingsProxy { * value. */ @AnyThread - fun registerContentObserverAsync( + public fun registerContentObserverAsync( name: String, settingsObserver: ContentObserver, @WorkerThread registered: Runnable, - ) = + ): Job = settingsScope.launch("registerContentObserverAsync-B") { registerContentObserverSync(getUriFor(name), settingsObserver) registered.run() @@ -133,8 +135,9 @@ interface SettingsProxy { * [registerContentObserverAsync] instead. */ @WorkerThread - fun registerContentObserverSync(uri: Uri, settingsObserver: ContentObserver) = + public fun registerContentObserverSync(uri: Uri, settingsObserver: ContentObserver) { registerContentObserverSync(uri, false, settingsObserver) + } /** * Convenience wrapper around [ContentResolver.registerContentObserver].' @@ -143,7 +146,7 @@ interface SettingsProxy { * registration happens on a worker thread. Caller may wrap the API in an async block if they * wish to synchronize execution. */ - suspend fun registerContentObserver(uri: Uri, settingsObserver: ContentObserver) { + public suspend fun registerContentObserver(uri: Uri, settingsObserver: ContentObserver) { executeOnSettingsScopeDispatcher("registerContentObserver-B") { registerContentObserverSync(uri, settingsObserver) } @@ -155,7 +158,7 @@ interface SettingsProxy { * API corresponding to [registerContentObserver] for Java usage. */ @AnyThread - fun registerContentObserverAsync(uri: Uri, settingsObserver: ContentObserver) = + public fun registerContentObserverAsync(uri: Uri, settingsObserver: ContentObserver): Job = settingsScope.launch("registerContentObserverAsync-C") { registerContentObserverSync(uri, settingsObserver) } @@ -168,11 +171,11 @@ interface SettingsProxy { * value. */ @AnyThread - fun registerContentObserverAsync( + public fun registerContentObserverAsync( uri: Uri, settingsObserver: ContentObserver, @WorkerThread registered: Runnable, - ) = + ): Job = settingsScope.launch("registerContentObserverAsync-D") { registerContentObserverSync(uri, settingsObserver) registered.run() @@ -184,11 +187,13 @@ interface SettingsProxy { * Implicitly calls [getUriFor] on the passed in name. */ @WorkerThread - fun registerContentObserverSync( + public fun registerContentObserverSync( name: String, notifyForDescendants: Boolean, settingsObserver: ContentObserver, - ) = registerContentObserverSync(getUriFor(name), notifyForDescendants, settingsObserver) + ) { + registerContentObserverSync(getUriFor(name), notifyForDescendants, settingsObserver) + } /** * Convenience wrapper around [ContentResolver.registerContentObserver].' @@ -197,7 +202,7 @@ interface SettingsProxy { * registration happens on a worker thread. Caller may wrap the API in an async block if they * wish to synchronize execution. */ - suspend fun registerContentObserver( + public suspend fun registerContentObserver( name: String, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @@ -213,11 +218,11 @@ interface SettingsProxy { * API corresponding to [registerContentObserver] for Java usage. */ @AnyThread - fun registerContentObserverAsync( + public fun registerContentObserverAsync( name: String, notifyForDescendants: Boolean, settingsObserver: ContentObserver, - ) = + ): Job = settingsScope.launch("registerContentObserverAsync-E") { registerContentObserverSync(getUriFor(name), notifyForDescendants, settingsObserver) } @@ -230,12 +235,12 @@ interface SettingsProxy { * value. */ @AnyThread - fun registerContentObserverAsync( + public fun registerContentObserverAsync( name: String, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @WorkerThread registered: Runnable, - ) = + ): Job = settingsScope.launch("registerContentObserverAsync-F") { registerContentObserverSync(getUriFor(name), notifyForDescendants, settingsObserver) registered.run() @@ -248,7 +253,7 @@ interface SettingsProxy { * [registerContentObserverAsync] instead. */ @WorkerThread - fun registerContentObserverSync( + public fun registerContentObserverSync( uri: Uri, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @@ -266,7 +271,7 @@ interface SettingsProxy { * registration happens on a worker thread. Caller may wrap the API in an async block if they * wish to synchronize execution. */ - suspend fun registerContentObserver( + public suspend fun registerContentObserver( uri: Uri, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @@ -282,11 +287,11 @@ interface SettingsProxy { * API corresponding to [registerContentObserver] for Java usage. */ @AnyThread - fun registerContentObserverAsync( + public fun registerContentObserverAsync( uri: Uri, notifyForDescendants: Boolean, settingsObserver: ContentObserver, - ) = + ): Job = settingsScope.launch("registerContentObserverAsync-G") { registerContentObserverSync(uri, notifyForDescendants, settingsObserver) } @@ -299,12 +304,12 @@ interface SettingsProxy { * value. */ @AnyThread - fun registerContentObserverAsync( + public fun registerContentObserverAsync( uri: Uri, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @WorkerThread registered: Runnable, - ) = + ): Job = settingsScope.launch("registerContentObserverAsync-H") { registerContentObserverSync(uri, notifyForDescendants, settingsObserver) registered.run() @@ -317,7 +322,7 @@ interface SettingsProxy { * [unregisterContentObserverAsync] instead. */ @WorkerThread - fun unregisterContentObserverSync(settingsObserver: ContentObserver) { + public fun unregisterContentObserverSync(settingsObserver: ContentObserver) { trace({ "SP#unregisterObserver" }) { getContentResolver().unregisterContentObserver(settingsObserver) } @@ -330,7 +335,7 @@ interface SettingsProxy { * [ContentObserver] un-registration happens on a worker thread. Caller may wrap the API in an * async block if they wish to synchronize execution. */ - suspend fun unregisterContentObserver(settingsObserver: ContentObserver) { + public suspend fun unregisterContentObserver(settingsObserver: ContentObserver) { executeOnSettingsScopeDispatcher("unregisterContentObserver") { unregisterContentObserverSync(settingsObserver) } @@ -343,7 +348,7 @@ interface SettingsProxy { * [ContentObserver] registration happens on a worker thread. */ @AnyThread - fun unregisterContentObserverAsync(settingsObserver: ContentObserver) = + public fun unregisterContentObserverAsync(settingsObserver: ContentObserver): Job = settingsScope.launch("unregisterContentObserverAsync") { unregisterContentObserver(settingsObserver) } @@ -354,7 +359,7 @@ interface SettingsProxy { * @param name to look up in the table * @return the corresponding value, or null if not present */ - fun getString(name: String): String? + public fun getString(name: String): String? /** * Store a name/value pair into the database. @@ -363,7 +368,7 @@ interface SettingsProxy { * @param value to associate with the name * @return true if the value was set, false on database errors */ - fun putString(name: String, value: String?): Boolean + public fun putString(name: String, value: String?): Boolean /** * Store a name/value pair into the database. @@ -394,7 +399,7 @@ interface SettingsProxy { * @return true if the value was set, false on database errors. * @see .resetToDefaults */ - fun putString(name: String, value: String?, tag: String?, makeDefault: Boolean): Boolean + public 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 @@ -406,7 +411,7 @@ interface SettingsProxy { * @param default Value to return if the setting is not defined. * @return The setting's current value, or default if it is not defined or not a valid integer. */ - fun getInt(name: String, default: Int): Int { + public fun getInt(name: String, default: Int): Int { val v = getString(name) return try { v?.toInt() ?: default @@ -429,7 +434,7 @@ interface SettingsProxy { * found or the setting value is not an integer. */ @Throws(SettingNotFoundException::class) - fun getInt(name: String): Int { + public fun getInt(name: String): Int { val v = getString(name) ?: throw SettingNotFoundException(name) return try { v.toInt() @@ -448,7 +453,7 @@ interface SettingsProxy { * @param value The new value for the setting. * @return true if the value was set, false on database errors */ - fun putInt(name: String, value: Int): Boolean { + public fun putInt(name: String, value: Int): Boolean { return putString(name, value.toString()) } @@ -462,7 +467,7 @@ interface SettingsProxy { * @param default Value to return if the setting is not defined. * @return The setting's current value, or default if it is not defined or not a valid boolean. */ - fun getBool(name: String, default: Boolean): Boolean { + public fun getBool(name: String, default: Boolean): Boolean { return getInt(name, if (default) 1 else 0) != 0 } @@ -480,7 +485,7 @@ interface SettingsProxy { * found or the setting value is not a boolean. */ @Throws(SettingNotFoundException::class) - fun getBool(name: String): Boolean { + public fun getBool(name: String): Boolean { return getInt(name) != 0 } @@ -494,7 +499,7 @@ interface SettingsProxy { * @param value The new value for the setting. * @return true if the value was set, false on database errors */ - fun putBool(name: String, value: Boolean): Boolean { + public fun putBool(name: String, value: Boolean): Boolean { return putInt(name, if (value) 1 else 0) } @@ -508,7 +513,7 @@ interface SettingsProxy { * @param def Value to return if the setting is not defined. * @return The setting's current value, or 'def' if it is not defined or not a valid `long`. */ - fun getLong(name: String, def: Long): Long { + public fun getLong(name: String, def: Long): Long { val valString = getString(name) return parseLongOrUseDefault(valString, def) } @@ -527,7 +532,7 @@ interface SettingsProxy { * found or the setting value is not an integer. */ @Throws(SettingNotFoundException::class) - fun getLong(name: String): Long { + public fun getLong(name: String): Long { val valString = getString(name) return parseLongOrThrow(name, valString) } @@ -542,7 +547,7 @@ interface SettingsProxy { * @param value The new value for the setting. * @return true if the value was set, false on database errors */ - fun putLong(name: String, value: Long): Boolean { + public fun putLong(name: String, value: Long): Boolean { return putString(name, value.toString()) } @@ -556,7 +561,7 @@ interface SettingsProxy { * @param def Value to return if the setting is not defined. * @return The setting's current value, or 'def' if it is not defined or not a valid float. */ - fun getFloat(name: String, def: Float): Float { + public fun getFloat(name: String, def: Float): Float { val v = getString(name) return parseFloat(v, def) } @@ -575,7 +580,7 @@ interface SettingsProxy { * found or the setting value is not a float. */ @Throws(SettingNotFoundException::class) - fun getFloat(name: String): Float { + public fun getFloat(name: String): Float { val v = getString(name) return parseFloatOrThrow(name, v) } @@ -590,14 +595,14 @@ interface SettingsProxy { * @param value The new value for the setting. * @return true if the value was set, false on database errors */ - fun putFloat(name: String, value: Float): Boolean { + public fun putFloat(name: String, value: Float): Boolean { return putString(name, value.toString()) } - companion object { + public companion object { /** Convert a string to a long, or uses a default if the string is malformed or null */ @JvmStatic - fun parseLongOrUseDefault(valString: String?, default: Long): Long { + public fun parseLongOrUseDefault(valString: String?, default: Long): Long { val value: Long = try { valString?.toLong() ?: default @@ -610,7 +615,7 @@ interface SettingsProxy { /** Convert a string to a long, or throws an exception if the string is malformed or null */ @JvmStatic @Throws(SettingNotFoundException::class) - fun parseLongOrThrow(name: String, valString: String?): Long { + public fun parseLongOrThrow(name: String, valString: String?): Long { if (valString == null) { throw SettingNotFoundException(name) } @@ -623,7 +628,7 @@ interface SettingsProxy { /** 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 { + public fun parseFloat(v: String?, def: Float): Float { return try { v?.toFloat() ?: def } catch (e: NumberFormatException) { @@ -636,7 +641,7 @@ interface SettingsProxy { */ @JvmStatic @Throws(SettingNotFoundException::class) - fun parseFloatOrThrow(name: String, v: String?): Float { + public fun parseFloatOrThrow(name: String, v: String?): Float { if (v == null) { throw SettingNotFoundException(name) } @@ -648,7 +653,7 @@ interface SettingsProxy { } } - fun interface CurrentUserIdProvider { - @UserIdInt fun getUserId(): Int + public fun interface CurrentUserIdProvider { + @UserIdInt public fun getUserId(): Int } } diff --git a/packages/SystemUI/pods/com/android/systemui/util/settings/SettingsProxyExt.kt b/packages/SystemUI/pods/com/android/systemui/util/settings/SettingsProxyExt.kt index 364681444c1b..60feaf1315e6 100644 --- a/packages/SystemUI/pods/com/android/systemui/util/settings/SettingsProxyExt.kt +++ b/packages/SystemUI/pods/com/android/systemui/util/settings/SettingsProxyExt.kt @@ -17,6 +17,7 @@ package com.android.systemui.util.settings +import android.annotation.SuppressLint import android.annotation.UserIdInt import android.database.ContentObserver import com.android.systemui.Flags @@ -25,10 +26,11 @@ import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow /** Kotlin extension functions for [SettingsProxy]. */ -object SettingsProxyExt { +@SuppressLint("RegisterContentObserverSyncWarning") +public object SettingsProxyExt { /** Returns a flow of [Unit] that is invoked each time that content is updated. */ - fun UserSettingsProxy.observerFlow( + public fun UserSettingsProxy.observerFlow( @UserIdInt userId: Int, vararg names: String, ): Flow<Unit> { @@ -59,9 +61,7 @@ object SettingsProxyExt { } /** Returns a flow of [Unit] that is invoked each time that content is updated. */ - fun SettingsProxy.observerFlow( - vararg names: String, - ): Flow<Unit> { + public fun SettingsProxy.observerFlow(vararg names: String): Flow<Unit> { return conflatedCallbackFlow { val observer = object : ContentObserver(null) { diff --git a/packages/SystemUI/pods/com/android/systemui/util/settings/UserSettingsProxy.kt b/packages/SystemUI/pods/com/android/systemui/util/settings/UserSettingsProxy.kt index 3ccac9e374a2..61c7f7359820 100644 --- a/packages/SystemUI/pods/com/android/systemui/util/settings/UserSettingsProxy.kt +++ b/packages/SystemUI/pods/com/android/systemui/util/settings/UserSettingsProxy.kt @@ -15,6 +15,7 @@ */ package com.android.systemui.util.settings +import android.annotation.SuppressLint import android.annotation.UserIdInt import android.annotation.WorkerThread import android.content.ContentResolver @@ -28,6 +29,7 @@ import com.android.systemui.util.settings.SettingsProxy.Companion.parseFloat import com.android.systemui.util.settings.SettingsProxy.Companion.parseFloatOrThrow import com.android.systemui.util.settings.SettingsProxy.Companion.parseLongOrThrow import com.android.systemui.util.settings.SettingsProxy.Companion.parseLongOrUseDefault +import kotlinx.coroutines.Job /** * Used to interact with per-user Settings.Secure and Settings.System settings (but not @@ -42,11 +44,12 @@ import com.android.systemui.util.settings.SettingsProxy.Companion.parseLongOrUse * This class also provides [.registerContentObserver] methods, normally found on [ContentResolver] * instances, unifying setting related actions in one place. */ -interface UserSettingsProxy : SettingsProxy { - val currentUserProvider: SettingsProxy.CurrentUserIdProvider +@SuppressLint("RegisterContentObserverSyncWarning") +public interface UserSettingsProxy : SettingsProxy { + public val currentUserProvider: SettingsProxy.CurrentUserIdProvider /** Returns the user id for the associated [ContentResolver]. */ - var userId: Int + public var userId: Int get() = getContentResolver().userId set(_) { throw UnsupportedOperationException( @@ -58,7 +61,7 @@ interface UserSettingsProxy : SettingsProxy { * Returns the actual current user handle when querying with the current user. Otherwise, * returns the passed in user id. */ - fun getRealUserHandle(userHandle: Int): Int { + public fun getRealUserHandle(userHandle: Int): Int { return if (userHandle != UserHandle.USER_CURRENT) { userHandle } else currentUserProvider.getUserId() @@ -75,7 +78,7 @@ interface UserSettingsProxy : SettingsProxy { } } - override fun registerContentObserverAsync(uri: Uri, settingsObserver: ContentObserver) = + override fun registerContentObserverAsync(uri: Uri, settingsObserver: ContentObserver): Job = settingsScope.launch("registerContentObserverAsync-A") { registerContentObserverForUserSync(uri, settingsObserver, userId) } @@ -109,7 +112,7 @@ interface UserSettingsProxy : SettingsProxy { uri: Uri, notifyForDescendants: Boolean, settingsObserver: ContentObserver, - ) = + ): Job = settingsScope.launch("registerContentObserverAsync-B") { registerContentObserverForUserSync(uri, notifyForDescendants, settingsObserver, userId) } @@ -120,7 +123,7 @@ interface UserSettingsProxy : SettingsProxy { * Implicitly calls [getUriFor] on the passed in name. */ @WorkerThread - fun registerContentObserverForUserSync( + public fun registerContentObserverForUserSync( name: String, settingsObserver: ContentObserver, userHandle: Int, @@ -135,7 +138,7 @@ interface UserSettingsProxy : SettingsProxy { * [ContentObserver] registration happens on a worker thread. Caller may wrap the API in an * async block if they wish to synchronize execution. */ - suspend fun registerContentObserverForUser( + public suspend fun registerContentObserverForUser( name: String, settingsObserver: ContentObserver, userHandle: Int, @@ -150,11 +153,11 @@ interface UserSettingsProxy : SettingsProxy { * * API corresponding to [registerContentObserverForUser] for Java usage. */ - fun registerContentObserverForUserAsync( + public fun registerContentObserverForUserAsync( name: String, settingsObserver: ContentObserver, userHandle: Int, - ) = + ): Job = settingsScope.launch("registerContentObserverForUserAsync-A") { try { registerContentObserverForUserSync(getUriFor(name), settingsObserver, userHandle) @@ -165,7 +168,7 @@ interface UserSettingsProxy : SettingsProxy { /** Convenience wrapper around [ContentResolver.registerContentObserver] */ @WorkerThread - fun registerContentObserverForUserSync( + public fun registerContentObserverForUserSync( uri: Uri, settingsObserver: ContentObserver, userHandle: Int, @@ -180,7 +183,7 @@ interface UserSettingsProxy : SettingsProxy { * [ContentObserver] registration happens on a worker thread. Caller may wrap the API in an * async block if they wish to synchronize execution. */ - suspend fun registerContentObserverForUser( + public suspend fun registerContentObserverForUser( uri: Uri, settingsObserver: ContentObserver, userHandle: Int, @@ -195,11 +198,11 @@ interface UserSettingsProxy : SettingsProxy { * * API corresponding to [registerContentObserverForUser] for Java usage. */ - fun registerContentObserverForUserAsync( + public fun registerContentObserverForUserAsync( uri: Uri, settingsObserver: ContentObserver, userHandle: Int, - ) = + ): Job = settingsScope.launch("registerContentObserverForUserAsync-B") { try { registerContentObserverForUserSync(uri, settingsObserver, userHandle) @@ -215,12 +218,12 @@ interface UserSettingsProxy : SettingsProxy { * complete, the callback block is called on the <b>background thread</b> to allow for update of * value. */ - fun registerContentObserverForUserAsync( + public fun registerContentObserverForUserAsync( uri: Uri, settingsObserver: ContentObserver, userHandle: Int, @WorkerThread registered: Runnable, - ) = + ): Job = settingsScope.launch("registerContentObserverForUserAsync-C") { try { registerContentObserverForUserSync(uri, settingsObserver, userHandle) @@ -236,7 +239,7 @@ interface UserSettingsProxy : SettingsProxy { * Implicitly calls [getUriFor] on the passed in name. */ @WorkerThread - fun registerContentObserverForUserSync( + public fun registerContentObserverForUserSync( name: String, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @@ -257,7 +260,7 @@ interface UserSettingsProxy : SettingsProxy { * [ContentObserver] registration happens on a worker thread. Caller may wrap the API in an * async block if they wish to synchronize execution. */ - suspend fun registerContentObserverForUser( + public suspend fun registerContentObserverForUser( name: String, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @@ -278,7 +281,7 @@ interface UserSettingsProxy : SettingsProxy { * * API corresponding to [registerContentObserverForUser] for Java usage. */ - fun registerContentObserverForUserAsync( + public fun registerContentObserverForUserAsync( name: String, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @@ -300,7 +303,7 @@ interface UserSettingsProxy : SettingsProxy { /** Convenience wrapper around [ContentResolver.registerContentObserver] */ @WorkerThread - fun registerContentObserverForUserSync( + public fun registerContentObserverForUserSync( uri: Uri, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @@ -314,7 +317,6 @@ interface UserSettingsProxy : SettingsProxy { settingsObserver, getRealUserHandle(userHandle), ) - Unit } } @@ -325,7 +327,7 @@ interface UserSettingsProxy : SettingsProxy { * [ContentObserver] registration happens on a worker thread. Caller may wrap the API in an * async block if they wish to synchronize execution. */ - suspend fun registerContentObserverForUser( + public suspend fun registerContentObserverForUser( uri: Uri, notifyForDescendants: Boolean, settingsObserver: ContentObserver, @@ -346,12 +348,12 @@ interface UserSettingsProxy : SettingsProxy { * * API corresponding to [registerContentObserverForUser] for Java usage. */ - fun registerContentObserverForUserAsync( + public fun registerContentObserverForUserAsync( uri: Uri, notifyForDescendants: Boolean, settingsObserver: ContentObserver, userHandle: Int, - ) = + ): Job = settingsScope.launch("registerContentObserverForUserAsync-E") { try { registerContentObserverForUserSync( @@ -376,7 +378,7 @@ interface UserSettingsProxy : SettingsProxy { } /** See [getString]. */ - fun getStringForUser(name: String, userHandle: Int): String? + public fun getStringForUser(name: String, userHandle: Int): String? /** * Store a name/value pair into the database. Values written by this method will be overridden @@ -386,17 +388,17 @@ interface UserSettingsProxy : SettingsProxy { * @param value to associate with the name * @return true if the value was set, false on database errors */ - fun putString(name: String, value: String?, overrideableByRestore: Boolean): Boolean + public fun putString(name: String, value: String?, overrideableByRestore: Boolean): Boolean 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 + public fun putStringForUser(name: String, value: String?, userHandle: Int): Boolean /** Similar implementation to [putString] for the specified [userHandle]. */ - fun putStringForUser( + public fun putStringForUser( name: String, value: String?, tag: String?, @@ -410,7 +412,7 @@ interface UserSettingsProxy : SettingsProxy { } /** Similar implementation to [getInt] for the specified [userHandle]. */ - fun getIntForUser(name: String, default: Int, userHandle: Int): Int { + public fun getIntForUser(name: String, default: Int, userHandle: Int): Int { val v = getStringForUser(name, userHandle) return try { v?.toInt() ?: default @@ -420,11 +422,11 @@ interface UserSettingsProxy : SettingsProxy { } @Throws(SettingNotFoundException::class) - override fun getInt(name: String) = getIntForUser(name, userId) + override fun getInt(name: String): Int = getIntForUser(name, userId) /** Similar implementation to [getInt] for the specified [userHandle]. */ @Throws(SettingNotFoundException::class) - fun getIntForUser(name: String, userHandle: Int): Int { + public fun getIntForUser(name: String, userHandle: Int): Int { val v = getStringForUser(name, userHandle) ?: throw SettingNotFoundException(name) return try { v.toInt() @@ -433,24 +435,24 @@ interface UserSettingsProxy : SettingsProxy { } } - override fun putInt(name: String, value: Int) = putIntForUser(name, value, userId) + override fun putInt(name: String, value: Int): Boolean = putIntForUser(name, value, userId) /** Similar implementation to [getInt] for the specified [userHandle]. */ - fun putIntForUser(name: String, value: Int, userHandle: Int) = + public fun putIntForUser(name: String, value: Int, userHandle: Int): Boolean = putStringForUser(name, value.toString(), userHandle) - override fun getBool(name: String, def: Boolean) = getBoolForUser(name, def, userId) + override fun getBool(name: String, def: Boolean): Boolean = getBoolForUser(name, def, userId) /** Similar implementation to [getBool] for the specified [userHandle]. */ - fun getBoolForUser(name: String, def: Boolean, userHandle: Int) = + public fun getBoolForUser(name: String, def: Boolean, userHandle: Int): Boolean = getIntForUser(name, if (def) 1 else 0, userHandle) != 0 @Throws(SettingNotFoundException::class) - override fun getBool(name: String) = getBoolForUser(name, userId) + override fun getBool(name: String): Boolean = getBoolForUser(name, userId) /** Similar implementation to [getBool] for the specified [userHandle]. */ @Throws(SettingNotFoundException::class) - fun getBoolForUser(name: String, userHandle: Int): Boolean { + public fun getBoolForUser(name: String, userHandle: Int): Boolean { return getIntForUser(name, userHandle) != 0 } @@ -459,40 +461,40 @@ interface UserSettingsProxy : SettingsProxy { } /** Similar implementation to [putBool] for the specified [userHandle]. */ - fun putBoolForUser(name: String, value: Boolean, userHandle: Int) = + public fun putBoolForUser(name: String, value: Boolean, userHandle: Int): Boolean = 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 { + public 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 { + public 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) = + public fun putLongForUser(name: String, value: Long, userHandle: Int): Boolean = putStringForUser(name, value.toString(), userHandle) /** Similar implementation to [getFloat] for the specified [userHandle]. */ - fun getFloatForUser(name: String, def: Float, userHandle: Int): Float { + public 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 { + public 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) = + public fun putFloatForUser(name: String, value: Float, userHandle: Int): Boolean = putStringForUser(name, value.toString(), userHandle) } |