diff options
| author | 2024-02-13 20:21:56 +0000 | |
|---|---|---|
| committer | 2024-02-13 20:21:56 +0000 | |
| commit | 08e44ec955c72f53b5a3d10169ac12f7008debab (patch) | |
| tree | 1523c98b24ce77bd4ea8c62158d4d6bbcaed8570 | |
| parent | 826fd09992f3ced67987370e3e890a4c6edef9ee (diff) | |
| parent | 155d4cfcf392b65112179f450551c68f642941e5 (diff) | |
Merge "Revert^2 "Fix a crash when registering/unregistering a smartspace timer listener."" into main
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/smartspace/data/repository/SmartspaceRepository.kt | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/smartspace/data/repository/SmartspaceRepository.kt b/packages/SystemUI/src/com/android/systemui/smartspace/data/repository/SmartspaceRepository.kt index 095d30ef55df..52a1c1555591 100644 --- a/packages/SystemUI/src/com/android/systemui/smartspace/data/repository/SmartspaceRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/smartspace/data/repository/SmartspaceRepository.kt @@ -21,7 +21,9 @@ import android.os.Parcelable import android.widget.RemoteViews import com.android.systemui.communal.smartspace.CommunalSmartspaceController import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.BcSmartspaceDataPlugin +import java.util.concurrent.Executor import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -41,6 +43,7 @@ class SmartspaceRepositoryImpl @Inject constructor( private val communalSmartspaceController: CommunalSmartspaceController, + @Main private val uiExecutor: Executor, ) : SmartspaceRepository, BcSmartspaceDataPlugin.SmartspaceTargetListener { override val isSmartspaceRemoteViewsEnabled: Boolean @@ -51,12 +54,18 @@ constructor( override val communalSmartspaceTargets: Flow<List<SmartspaceTarget>> = _communalSmartspaceTargets .onStart { - communalSmartspaceController.addListener(listener = this@SmartspaceRepositoryImpl) + uiExecutor.execute { + communalSmartspaceController.addListener( + listener = this@SmartspaceRepositoryImpl + ) + } } .onCompletion { - communalSmartspaceController.removeListener( - listener = this@SmartspaceRepositoryImpl - ) + uiExecutor.execute { + communalSmartspaceController.removeListener( + listener = this@SmartspaceRepositoryImpl + ) + } } override fun onSmartspaceTargetsUpdated(targetsNullable: MutableList<out Parcelable>?) { |