Loading core/java/android/provider/Settings.java +3 −0 Original line number Diff line number Diff line Loading @@ -9428,9 +9428,12 @@ public final class Settings { * 0 indicates disabled and 1 indicates enabled. A non existent value should be treated as * enabled. * * @deprecated Controls are migrated to Quick Settings, rendering this unnecessary and will * be removed in a future release. * @hide */ @Readable @Deprecated public static final String CONTROLS_ENABLED = "controls_enabled"; /** Loading packages/SystemUI/src/com/android/systemui/controls/controller/ControlsController.kt +0 −5 Original line number Diff line number Diff line Loading @@ -40,11 +40,6 @@ import java.util.function.Consumer */ interface ControlsController : UserAwareController { /** * Whether the controls system is available for the current user. */ val available: Boolean // SERVICE COMMUNICATION /** Loading packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt +6 −26 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.database.ContentObserver import android.net.Uri import android.os.Environment import android.os.UserHandle import android.provider.Settings import android.service.controls.Control import android.service.controls.actions.ControlAction import android.util.ArrayMap Loading Loading @@ -70,15 +69,10 @@ class ControlsControllerImpl @Inject constructor ( companion object { private const val TAG = "ControlsControllerImpl" internal const val CONTROLS_AVAILABLE = Settings.Secure.CONTROLS_ENABLED internal val URI = Settings.Secure.getUriFor(CONTROLS_AVAILABLE) private const val USER_CHANGE_RETRY_DELAY = 500L // ms private const val DEFAULT_ENABLED = 1 private const val PERMISSION_SELF = "com.android.systemui.permission.SELF" const val SUGGESTED_CONTROLS_PER_STRUCTURE = 6 private fun isAvailable(userId: Int, cr: ContentResolver) = Settings.Secure.getIntForUser( cr, CONTROLS_AVAILABLE, DEFAULT_ENABLED, userId) != 0 } private var userChanging: Boolean = true Loading @@ -93,8 +87,6 @@ class ControlsControllerImpl @Inject constructor ( private val contentResolver: ContentResolver get() = context.contentResolver override var available = isAvailable(currentUserId, contentResolver) private set private val persistenceWrapper: ControlsFavoritePersistenceWrapper @VisibleForTesting Loading Loading @@ -126,8 +118,7 @@ class ControlsControllerImpl @Inject constructor ( BackupManager(userStructure.userContext) ) auxiliaryPersistenceWrapper.changeFile(userStructure.auxiliaryFile) available = isAvailable(newUser.identifier, contentResolver) resetFavorites(available) resetFavorites() bindingController.changeUser(newUser) listingController.changeUser(newUser) userChanging = false Loading Loading @@ -157,7 +148,7 @@ class ControlsControllerImpl @Inject constructor ( Log.d(TAG, "Restore finished, storing auxiliary favorites") auxiliaryPersistenceWrapper.initialize() persistenceWrapper.storeFavorites(auxiliaryPersistenceWrapper.favorites) resetFavorites(available) resetFavorites() } } } Loading @@ -176,8 +167,7 @@ class ControlsControllerImpl @Inject constructor ( if (userChanging || userId != currentUserId) { return } available = isAvailable(currentUserId, contentResolver) resetFavorites(available) resetFavorites() } } Loading Loading @@ -242,7 +232,7 @@ class ControlsControllerImpl @Inject constructor ( init { dumpManager.registerDumpable(javaClass.name, this) resetFavorites(available) resetFavorites() userChanging = false broadcastDispatcher.registerReceiver( userSwitchReceiver, Loading @@ -256,34 +246,25 @@ class ControlsControllerImpl @Inject constructor ( PERMISSION_SELF, null ) contentResolver.registerContentObserver(URI, false, settingObserver, UserHandle.USER_ALL) listingController.addCallback(listingCallback) } fun destroy() { broadcastDispatcher.unregisterReceiver(userSwitchReceiver) context.unregisterReceiver(restoreFinishedReceiver) contentResolver.unregisterContentObserver(settingObserver) listingController.removeCallback(listingCallback) } private fun resetFavorites(shouldLoad: Boolean) { private fun resetFavorites() { Favorites.clear() if (shouldLoad) { Favorites.load(persistenceWrapper.readFavorites()) } } private fun confirmAvailability(): Boolean { if (userChanging) { Log.w(TAG, "Controls not available while user is changing") return false } if (!available) { Log.d(TAG, "Controls not available") return false } return true } Loading Loading @@ -577,7 +558,6 @@ class ControlsControllerImpl @Inject constructor ( override fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<out String>) { pw.println("ControlsController state:") pw.println(" Available: $available") pw.println(" Changing users: $userChanging") pw.println(" Current user: ${currentUser.identifier}") pw.println(" Favorites:") Loading packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsComponent.kt +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ class ControlsComponent @Inject constructor( /** * @return true if controls are feature-enabled and the user has the setting enabled */ fun isEnabled() = featureEnabled && lazyControlsController.get().available fun isEnabled() = featureEnabled /** * Returns one of 3 states: Loading packages/SystemUI/src/com/android/systemui/controls/management/ControlsRequestDialog.kt +1 −4 Original line number Diff line number Diff line Loading @@ -71,10 +71,7 @@ open class ControlsRequestDialog @Inject constructor( override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (!controller.available) { Log.w(TAG, "Quick Controls not available for this user ") finish() } currentUserTracker.startTracking() controlsListingController.addCallback(callback) Loading Loading
core/java/android/provider/Settings.java +3 −0 Original line number Diff line number Diff line Loading @@ -9428,9 +9428,12 @@ public final class Settings { * 0 indicates disabled and 1 indicates enabled. A non existent value should be treated as * enabled. * * @deprecated Controls are migrated to Quick Settings, rendering this unnecessary and will * be removed in a future release. * @hide */ @Readable @Deprecated public static final String CONTROLS_ENABLED = "controls_enabled"; /** Loading
packages/SystemUI/src/com/android/systemui/controls/controller/ControlsController.kt +0 −5 Original line number Diff line number Diff line Loading @@ -40,11 +40,6 @@ import java.util.function.Consumer */ interface ControlsController : UserAwareController { /** * Whether the controls system is available for the current user. */ val available: Boolean // SERVICE COMMUNICATION /** Loading
packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt +6 −26 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import android.database.ContentObserver import android.net.Uri import android.os.Environment import android.os.UserHandle import android.provider.Settings import android.service.controls.Control import android.service.controls.actions.ControlAction import android.util.ArrayMap Loading Loading @@ -70,15 +69,10 @@ class ControlsControllerImpl @Inject constructor ( companion object { private const val TAG = "ControlsControllerImpl" internal const val CONTROLS_AVAILABLE = Settings.Secure.CONTROLS_ENABLED internal val URI = Settings.Secure.getUriFor(CONTROLS_AVAILABLE) private const val USER_CHANGE_RETRY_DELAY = 500L // ms private const val DEFAULT_ENABLED = 1 private const val PERMISSION_SELF = "com.android.systemui.permission.SELF" const val SUGGESTED_CONTROLS_PER_STRUCTURE = 6 private fun isAvailable(userId: Int, cr: ContentResolver) = Settings.Secure.getIntForUser( cr, CONTROLS_AVAILABLE, DEFAULT_ENABLED, userId) != 0 } private var userChanging: Boolean = true Loading @@ -93,8 +87,6 @@ class ControlsControllerImpl @Inject constructor ( private val contentResolver: ContentResolver get() = context.contentResolver override var available = isAvailable(currentUserId, contentResolver) private set private val persistenceWrapper: ControlsFavoritePersistenceWrapper @VisibleForTesting Loading Loading @@ -126,8 +118,7 @@ class ControlsControllerImpl @Inject constructor ( BackupManager(userStructure.userContext) ) auxiliaryPersistenceWrapper.changeFile(userStructure.auxiliaryFile) available = isAvailable(newUser.identifier, contentResolver) resetFavorites(available) resetFavorites() bindingController.changeUser(newUser) listingController.changeUser(newUser) userChanging = false Loading Loading @@ -157,7 +148,7 @@ class ControlsControllerImpl @Inject constructor ( Log.d(TAG, "Restore finished, storing auxiliary favorites") auxiliaryPersistenceWrapper.initialize() persistenceWrapper.storeFavorites(auxiliaryPersistenceWrapper.favorites) resetFavorites(available) resetFavorites() } } } Loading @@ -176,8 +167,7 @@ class ControlsControllerImpl @Inject constructor ( if (userChanging || userId != currentUserId) { return } available = isAvailable(currentUserId, contentResolver) resetFavorites(available) resetFavorites() } } Loading Loading @@ -242,7 +232,7 @@ class ControlsControllerImpl @Inject constructor ( init { dumpManager.registerDumpable(javaClass.name, this) resetFavorites(available) resetFavorites() userChanging = false broadcastDispatcher.registerReceiver( userSwitchReceiver, Loading @@ -256,34 +246,25 @@ class ControlsControllerImpl @Inject constructor ( PERMISSION_SELF, null ) contentResolver.registerContentObserver(URI, false, settingObserver, UserHandle.USER_ALL) listingController.addCallback(listingCallback) } fun destroy() { broadcastDispatcher.unregisterReceiver(userSwitchReceiver) context.unregisterReceiver(restoreFinishedReceiver) contentResolver.unregisterContentObserver(settingObserver) listingController.removeCallback(listingCallback) } private fun resetFavorites(shouldLoad: Boolean) { private fun resetFavorites() { Favorites.clear() if (shouldLoad) { Favorites.load(persistenceWrapper.readFavorites()) } } private fun confirmAvailability(): Boolean { if (userChanging) { Log.w(TAG, "Controls not available while user is changing") return false } if (!available) { Log.d(TAG, "Controls not available") return false } return true } Loading Loading @@ -577,7 +558,6 @@ class ControlsControllerImpl @Inject constructor ( override fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<out String>) { pw.println("ControlsController state:") pw.println(" Available: $available") pw.println(" Changing users: $userChanging") pw.println(" Current user: ${currentUser.identifier}") pw.println(" Favorites:") Loading
packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsComponent.kt +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ class ControlsComponent @Inject constructor( /** * @return true if controls are feature-enabled and the user has the setting enabled */ fun isEnabled() = featureEnabled && lazyControlsController.get().available fun isEnabled() = featureEnabled /** * Returns one of 3 states: Loading
packages/SystemUI/src/com/android/systemui/controls/management/ControlsRequestDialog.kt +1 −4 Original line number Diff line number Diff line Loading @@ -71,10 +71,7 @@ open class ControlsRequestDialog @Inject constructor( override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (!controller.available) { Log.w(TAG, "Quick Controls not available for this user ") finish() } currentUserTracker.startTracking() controlsListingController.addCallback(callback) Loading