Loading packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,11 @@ interface ControlsBindingController : UserAwareController { */ fun unsubscribe() /** * Notify this controller that this component has been removed (uninstalled). */ fun onComponentRemoved(componentName: ComponentName) /** * Consumer for load calls. * Loading packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt +12 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,18 @@ open class ControlsBindingControllerImpl @Inject constructor( } } override fun onComponentRemoved(componentName: ComponentName) { backgroundExecutor.execute { synchronized(componentMap) { val removed = componentMap.remove(Key(componentName, currentUser)) removed?.let { it.unbindService() tokenMap.remove(it.token) } } } } override fun toString(): String { return StringBuilder(" ControlsBindingController:\n").apply { append(" refreshing=${refreshing.get()}\n") Loading packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt +31 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.android.internal.annotations.VisibleForTesting import com.android.systemui.Dumpable import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.controls.ControlStatus import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.controls.management.ControlsListingController import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.dagger.qualifiers.Background Loading Loading @@ -123,6 +124,7 @@ class ControlsControllerImpl @Inject constructor ( override fun onReceive(context: Context, intent: Intent) { if (intent.action == Intent.ACTION_USER_SWITCHED) { userChanging = true listingController.removeCallback(listingCallback) val newUser = UserHandle.of(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, sendingUserId)) if (currentUser == newUser) { Loading Loading @@ -153,6 +155,34 @@ class ControlsControllerImpl @Inject constructor ( } } // Handling of removed components /** * Check if any component has been removed and if so, remove all its favorites. * * If some component has been removed, the new set of favorites will also be saved. */ private val listingCallback = object : ControlsListingController.ControlsListingCallback { override fun onServicesUpdated(candidates: List<ControlsServiceInfo>) { executor.execute { val candidateComponents = candidates.map(ControlsServiceInfo::componentName) synchronized(currentFavorites) { val components = currentFavorites.keys.toSet() // create a copy components.forEach { if (it !in candidateComponents) { currentFavorites.remove(it) bindingController.onComponentRemoved(it) } } // Check if something has been removed, if so, store the new list if (components.size > currentFavorites.size) { persistenceWrapper.storeFavorites(favoritesAsListLocked()) } } } } } init { dumpManager.registerDumpable(javaClass.name, this) if (available) { Loading Loading @@ -187,6 +217,7 @@ class ControlsControllerImpl @Inject constructor ( currentFavorites.getOrPut(it.component, { mutableListOf() }).add(it) } } listingController.addCallback(listingCallback) } override fun loadForComponent( Loading packages/SystemUI/src/com/android/systemui/controls/management/AppAdapter.kt +2 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView import com.android.settingslib.applications.DefaultAppInfo import com.android.settingslib.widget.CandidateInfo import com.android.systemui.R import com.android.systemui.controls.ControlsServiceInfo import java.text.Collator import java.util.concurrent.Executor Loading Loading @@ -58,7 +59,7 @@ class AppAdapter( private var listOfServices = emptyList<CandidateInfo>() private val callback = object : ControlsListingController.ControlsListingCallback { override fun onServicesUpdated(candidates: List<CandidateInfo>) { override fun onServicesUpdated(candidates: List<ControlsServiceInfo>) { backgroundExecutor.execute { val collator = Collator.getInstance(resources.configuration.locales[0]) val localeComparator = compareBy<CandidateInfo, CharSequence>(collator) { Loading packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingController.kt +3 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package com.android.systemui.controls.management import android.content.ComponentName import com.android.settingslib.widget.CandidateInfo import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.controls.UserAwareController import com.android.systemui.statusbar.policy.CallbackController Loading @@ -31,7 +31,7 @@ interface ControlsListingController : /** * @return the current list of services that satisfies the [ServiceListing]. */ fun getCurrentServices(): List<CandidateInfo> fun getCurrentServices(): List<ControlsServiceInfo> /** * Get the app label for a given component. Loading @@ -45,6 +45,6 @@ interface ControlsListingController : @FunctionalInterface interface ControlsListingCallback { fun onServicesUpdated(candidates: List<CandidateInfo>) fun onServicesUpdated(candidates: List<ControlsServiceInfo>) } } Loading
packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,11 @@ interface ControlsBindingController : UserAwareController { */ fun unsubscribe() /** * Notify this controller that this component has been removed (uninstalled). */ fun onComponentRemoved(componentName: ComponentName) /** * Consumer for load calls. * Loading
packages/SystemUI/src/com/android/systemui/controls/controller/ControlsBindingControllerImpl.kt +12 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,18 @@ open class ControlsBindingControllerImpl @Inject constructor( } } override fun onComponentRemoved(componentName: ComponentName) { backgroundExecutor.execute { synchronized(componentMap) { val removed = componentMap.remove(Key(componentName, currentUser)) removed?.let { it.unbindService() tokenMap.remove(it.token) } } } } override fun toString(): String { return StringBuilder(" ControlsBindingController:\n").apply { append(" refreshing=${refreshing.get()}\n") Loading
packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt +31 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.android.internal.annotations.VisibleForTesting import com.android.systemui.Dumpable import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.controls.ControlStatus import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.controls.management.ControlsListingController import com.android.systemui.controls.ui.ControlsUiController import com.android.systemui.dagger.qualifiers.Background Loading Loading @@ -123,6 +124,7 @@ class ControlsControllerImpl @Inject constructor ( override fun onReceive(context: Context, intent: Intent) { if (intent.action == Intent.ACTION_USER_SWITCHED) { userChanging = true listingController.removeCallback(listingCallback) val newUser = UserHandle.of(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, sendingUserId)) if (currentUser == newUser) { Loading Loading @@ -153,6 +155,34 @@ class ControlsControllerImpl @Inject constructor ( } } // Handling of removed components /** * Check if any component has been removed and if so, remove all its favorites. * * If some component has been removed, the new set of favorites will also be saved. */ private val listingCallback = object : ControlsListingController.ControlsListingCallback { override fun onServicesUpdated(candidates: List<ControlsServiceInfo>) { executor.execute { val candidateComponents = candidates.map(ControlsServiceInfo::componentName) synchronized(currentFavorites) { val components = currentFavorites.keys.toSet() // create a copy components.forEach { if (it !in candidateComponents) { currentFavorites.remove(it) bindingController.onComponentRemoved(it) } } // Check if something has been removed, if so, store the new list if (components.size > currentFavorites.size) { persistenceWrapper.storeFavorites(favoritesAsListLocked()) } } } } } init { dumpManager.registerDumpable(javaClass.name, this) if (available) { Loading Loading @@ -187,6 +217,7 @@ class ControlsControllerImpl @Inject constructor ( currentFavorites.getOrPut(it.component, { mutableListOf() }).add(it) } } listingController.addCallback(listingCallback) } override fun loadForComponent( Loading
packages/SystemUI/src/com/android/systemui/controls/management/AppAdapter.kt +2 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView import com.android.settingslib.applications.DefaultAppInfo import com.android.settingslib.widget.CandidateInfo import com.android.systemui.R import com.android.systemui.controls.ControlsServiceInfo import java.text.Collator import java.util.concurrent.Executor Loading Loading @@ -58,7 +59,7 @@ class AppAdapter( private var listOfServices = emptyList<CandidateInfo>() private val callback = object : ControlsListingController.ControlsListingCallback { override fun onServicesUpdated(candidates: List<CandidateInfo>) { override fun onServicesUpdated(candidates: List<ControlsServiceInfo>) { backgroundExecutor.execute { val collator = Collator.getInstance(resources.configuration.locales[0]) val localeComparator = compareBy<CandidateInfo, CharSequence>(collator) { Loading
packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingController.kt +3 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package com.android.systemui.controls.management import android.content.ComponentName import com.android.settingslib.widget.CandidateInfo import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.controls.UserAwareController import com.android.systemui.statusbar.policy.CallbackController Loading @@ -31,7 +31,7 @@ interface ControlsListingController : /** * @return the current list of services that satisfies the [ServiceListing]. */ fun getCurrentServices(): List<CandidateInfo> fun getCurrentServices(): List<ControlsServiceInfo> /** * Get the app label for a given component. Loading @@ -45,6 +45,6 @@ interface ControlsListingController : @FunctionalInterface interface ControlsListingCallback { fun onServicesUpdated(candidates: List<CandidateInfo>) fun onServicesUpdated(candidates: List<ControlsServiceInfo>) } }