From 0de0f5a2371411282a28b24500b233d9d3139cb0 Mon Sep 17 00:00:00 2001 From: Alex Stetson Date: Mon, 17 Oct 2022 15:16:59 -0700 Subject: [PATCH 1/2] Allow for replacement of MultiUserUtilsModule Allow variants of SystemUI to replace the MultiUserUtilsModule with their own implementations. Bug: 254099598 Test: build Change-Id: I42c2e19c3d2f98cfae806e4aae389ca1861dca27 --- .../com/android/systemui/dagger/ReferenceSystemUIModule.java | 2 ++ .../src/com/android/systemui/dagger/SystemUIModule.java | 2 -- .../SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSystemUIModule.java index 48bef97c30fba..2bee75e9435b4 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSystemUIModule.java @@ -41,6 +41,7 @@ import com.android.systemui.qs.tileimpl.QSFactoryImpl; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsImplementation; import com.android.systemui.screenshot.ReferenceScreenshotModule; +import com.android.systemui.settings.dagger.MultiUserUtilsModule; import com.android.systemui.shade.NotificationShadeWindowControllerImpl; import com.android.systemui.shade.ShadeController; import com.android.systemui.shade.ShadeControllerImpl; @@ -93,6 +94,7 @@ import dagger.Provides; AospPolicyModule.class, GestureModule.class, MediaModule.class, + MultiUserUtilsModule.class, PowerModule.class, QSModule.class, ReferenceScreenshotModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index dc3dadb326698..a7eaafdbcf494 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -55,7 +55,6 @@ import com.android.systemui.qs.footer.dagger.FooterActionsModule; import com.android.systemui.recents.Recents; import com.android.systemui.screenshot.dagger.ScreenshotModule; import com.android.systemui.security.data.repository.SecurityRepositoryModule; -import com.android.systemui.settings.dagger.MultiUserUtilsModule; import com.android.systemui.shade.ShadeController; import com.android.systemui.smartspace.dagger.SmartspaceModule; import com.android.systemui.statusbar.CommandQueue; @@ -134,7 +133,6 @@ import dagger.Provides; PrivacyModule.class, ScreenshotModule.class, SensorModule.class, - MultiUserUtilsModule.class, SecurityRepositoryModule.class, SettingsUtilModule.class, SmartRepliesInflationModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java b/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java index 10a09dd169e82..61eadeb1764fa 100644 --- a/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java @@ -44,6 +44,7 @@ import com.android.systemui.qs.tileimpl.QSFactoryImpl; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsImplementation; import com.android.systemui.screenshot.ReferenceScreenshotModule; +import com.android.systemui.settings.dagger.MultiUserUtilsModule; import com.android.systemui.shade.NotificationShadeWindowControllerImpl; import com.android.systemui.shade.ShadeController; import com.android.systemui.shade.ShadeControllerImpl; @@ -89,6 +90,7 @@ import dagger.multibindings.IntoSet; includes = { AospPolicyModule.class, GestureModule.class, + MultiUserUtilsModule.class, PowerModule.class, QSModule.class, ReferenceScreenshotModule.class, From 79a5831905b3de744d0cfa448a8c732f397ccec2 Mon Sep 17 00:00:00 2001 From: Alex Stetson Date: Mon, 17 Oct 2022 16:25:43 -0700 Subject: [PATCH 2/2] Make UserTrackerImpl more extensible Bug: 254133820 Test: build Change-Id: Ib290941fd1860011b0b03a33162e58b09c7d1560 --- .../android/systemui/settings/UserTrackerImpl.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt b/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt index 671173413e731..cd5647e510295 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt @@ -30,7 +30,6 @@ import androidx.annotation.GuardedBy import androidx.annotation.WorkerThread import com.android.systemui.Dumpable import com.android.systemui.dump.DumpManager -import com.android.systemui.people.widget.PeopleSpaceWidgetProvider.EXTRA_USER_HANDLE import com.android.systemui.util.Assert import java.io.PrintWriter import java.lang.ref.WeakReference @@ -53,7 +52,7 @@ import kotlin.reflect.KProperty * * Class constructed and initialized in [SettingsModule]. */ -class UserTrackerImpl internal constructor( +open class UserTrackerImpl internal constructor( private val context: Context, private val userManager: UserManager, private val dumpManager: DumpManager, @@ -70,13 +69,13 @@ class UserTrackerImpl internal constructor( private val mutex = Any() override var userId: Int by SynchronizedDelegate(context.userId) - private set + protected set override var userHandle: UserHandle by SynchronizedDelegate(context.user) - private set + protected set override var userContext: Context by SynchronizedDelegate(context) - private set + protected set override val userContentResolver: ContentResolver get() = userContext.contentResolver @@ -94,7 +93,7 @@ class UserTrackerImpl internal constructor( * modified. */ override var userProfiles: List by SynchronizedDelegate(emptyList()) - private set + protected set @GuardedBy("callbacks") private val callbacks: MutableList = ArrayList() @@ -155,7 +154,7 @@ class UserTrackerImpl internal constructor( } @WorkerThread - private fun handleSwitchUser(newUser: Int) { + protected open fun handleSwitchUser(newUser: Int) { Assert.isNotMainThread() if (newUser == UserHandle.USER_NULL) { Log.w(TAG, "handleSwitchUser - Couldn't get new id from intent") @@ -174,7 +173,7 @@ class UserTrackerImpl internal constructor( } @WorkerThread - private fun handleProfilesChanged() { + protected open fun handleProfilesChanged() { Assert.isNotMainThread() val profiles = userManager.getProfiles(userId)