Loading packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +12 −6 Original line number Diff line number Diff line Loading @@ -91,7 +91,6 @@ class LockscreenSmartspaceController constructor( private val context: Context, private val featureFlags: FeatureFlags, private val smartspaceManager: SmartspaceManager?, private val activityStarter: ActivityStarter, private val falsingManager: FalsingManager, private val systemClock: SystemClock, Loading Loading @@ -124,6 +123,7 @@ constructor( private const val MAX_RECENT_SMARTSPACE_DATA_FOR_DUMP = 5 } private var userSmartspaceManager: SmartspaceManager? = null private var session: SmartspaceSession? = null private val datePlugin: BcSmartspaceDataPlugin? = optionalDatePlugin.orElse(null) private val weatherPlugin: BcSmartspaceDataPlugin? = optionalWeatherPlugin.orElse(null) Loading Loading @@ -461,7 +461,11 @@ constructor( } private fun connectSession() { if (smartspaceManager == null) return if (userSmartspaceManager == null) { userSmartspaceManager = userTracker.userContext.getSystemService(SmartspaceManager::class.java) } if (userSmartspaceManager == null) return if (datePlugin == null && weatherPlugin == null && plugin == null) return if (session != null || smartspaceViews.isEmpty()) { return Loading @@ -474,12 +478,14 @@ constructor( return } val newSession = smartspaceManager.createSmartspaceSession( val newSession = userSmartspaceManager?.createSmartspaceSession( SmartspaceConfig.Builder( context, BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD).build()) userTracker.userContext, BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD ).build() ) Log.d(TAG, "Starting smartspace session for " + BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD) newSession.addOnTargetsAvailableListener(uiExecutor, sessionListener) newSession?.addOnTargetsAvailableListener(uiExecutor, sessionListener) this.session = newSession deviceProvisionedController.removeCallback(deviceProvisionedListener) Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt +13 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.app.smartspace.SmartspaceSession.OnTargetsAvailableListener import android.app.smartspace.SmartspaceTarget import android.content.ComponentName import android.content.ContentResolver import android.content.Context import android.content.pm.UserInfo import android.database.ContentObserver import android.graphics.drawable.Drawable Loading Loading @@ -207,6 +208,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { private val userHandleManaged: UserHandle = UserHandle(2) private val userHandleSecondary: UserHandle = UserHandle(3) @Mock private lateinit var userContextPrimary: Context @Mock private lateinit var userContextSecondary: Context private val userList = listOf( mockUserInfo(userHandlePrimary, isManagedProfile = false), mockUserInfo(userHandleManaged, isManagedProfile = true), Loading Loading @@ -234,7 +238,11 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { `when`(deviceProvisionedController.isDeviceProvisioned).thenReturn(true) `when`(deviceProvisionedController.isCurrentUserSetup).thenReturn(true) setActiveUser(userHandlePrimary) `when`(userContextPrimary.getSystemService(SmartspaceManager::class.java)).thenReturn( smartspaceManager ) setActiveUser(userHandlePrimary, userContextPrimary) setAllowPrivateNotifications(userHandlePrimary, true) setAllowPrivateNotifications(userHandleManaged, true) setAllowPrivateNotifications(userHandleSecondary, true) Loading @@ -252,7 +260,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { controller = LockscreenSmartspaceController( context, featureFlags, smartspaceManager, activityStarter, falsingManager, clock, Loading Loading @@ -709,7 +716,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { connectSession() // WHEN the secondary user becomes the active user setActiveUser(userHandleSecondary) // Note: it doesn't switch to the SmartspaceManager for userContextSecondary setActiveUser(userHandleSecondary, userContextSecondary) userListener.onUserChanged(userHandleSecondary.identifier, context) // WHEN we receive a new list of targets Loading Loading @@ -912,9 +920,10 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { clearInvocations(smartspaceView) } private fun setActiveUser(userHandle: UserHandle) { private fun setActiveUser(userHandle: UserHandle, userContext: Context) { `when`(userTracker.userId).thenReturn(userHandle.identifier) `when`(userTracker.userHandle).thenReturn(userHandle) `when`(userTracker.userContext).thenReturn(userContext) } private fun mockUserInfo(userHandle: UserHandle, isManagedProfile: Boolean): UserInfo { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +12 −6 Original line number Diff line number Diff line Loading @@ -91,7 +91,6 @@ class LockscreenSmartspaceController constructor( private val context: Context, private val featureFlags: FeatureFlags, private val smartspaceManager: SmartspaceManager?, private val activityStarter: ActivityStarter, private val falsingManager: FalsingManager, private val systemClock: SystemClock, Loading Loading @@ -124,6 +123,7 @@ constructor( private const val MAX_RECENT_SMARTSPACE_DATA_FOR_DUMP = 5 } private var userSmartspaceManager: SmartspaceManager? = null private var session: SmartspaceSession? = null private val datePlugin: BcSmartspaceDataPlugin? = optionalDatePlugin.orElse(null) private val weatherPlugin: BcSmartspaceDataPlugin? = optionalWeatherPlugin.orElse(null) Loading Loading @@ -461,7 +461,11 @@ constructor( } private fun connectSession() { if (smartspaceManager == null) return if (userSmartspaceManager == null) { userSmartspaceManager = userTracker.userContext.getSystemService(SmartspaceManager::class.java) } if (userSmartspaceManager == null) return if (datePlugin == null && weatherPlugin == null && plugin == null) return if (session != null || smartspaceViews.isEmpty()) { return Loading @@ -474,12 +478,14 @@ constructor( return } val newSession = smartspaceManager.createSmartspaceSession( val newSession = userSmartspaceManager?.createSmartspaceSession( SmartspaceConfig.Builder( context, BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD).build()) userTracker.userContext, BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD ).build() ) Log.d(TAG, "Starting smartspace session for " + BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD) newSession.addOnTargetsAvailableListener(uiExecutor, sessionListener) newSession?.addOnTargetsAvailableListener(uiExecutor, sessionListener) this.session = newSession deviceProvisionedController.removeCallback(deviceProvisionedListener) Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt +13 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.app.smartspace.SmartspaceSession.OnTargetsAvailableListener import android.app.smartspace.SmartspaceTarget import android.content.ComponentName import android.content.ContentResolver import android.content.Context import android.content.pm.UserInfo import android.database.ContentObserver import android.graphics.drawable.Drawable Loading Loading @@ -207,6 +208,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { private val userHandleManaged: UserHandle = UserHandle(2) private val userHandleSecondary: UserHandle = UserHandle(3) @Mock private lateinit var userContextPrimary: Context @Mock private lateinit var userContextSecondary: Context private val userList = listOf( mockUserInfo(userHandlePrimary, isManagedProfile = false), mockUserInfo(userHandleManaged, isManagedProfile = true), Loading Loading @@ -234,7 +238,11 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { `when`(deviceProvisionedController.isDeviceProvisioned).thenReturn(true) `when`(deviceProvisionedController.isCurrentUserSetup).thenReturn(true) setActiveUser(userHandlePrimary) `when`(userContextPrimary.getSystemService(SmartspaceManager::class.java)).thenReturn( smartspaceManager ) setActiveUser(userHandlePrimary, userContextPrimary) setAllowPrivateNotifications(userHandlePrimary, true) setAllowPrivateNotifications(userHandleManaged, true) setAllowPrivateNotifications(userHandleSecondary, true) Loading @@ -252,7 +260,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { controller = LockscreenSmartspaceController( context, featureFlags, smartspaceManager, activityStarter, falsingManager, clock, Loading Loading @@ -709,7 +716,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { connectSession() // WHEN the secondary user becomes the active user setActiveUser(userHandleSecondary) // Note: it doesn't switch to the SmartspaceManager for userContextSecondary setActiveUser(userHandleSecondary, userContextSecondary) userListener.onUserChanged(userHandleSecondary.identifier, context) // WHEN we receive a new list of targets Loading Loading @@ -912,9 +920,10 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { clearInvocations(smartspaceView) } private fun setActiveUser(userHandle: UserHandle) { private fun setActiveUser(userHandle: UserHandle, userContext: Context) { `when`(userTracker.userId).thenReturn(userHandle.identifier) `when`(userTracker.userHandle).thenReturn(userHandle) `when`(userTracker.userContext).thenReturn(userContext) } private fun mockUserInfo(userHandle: UserHandle, isManagedProfile: Boolean): UserInfo { Loading