Loading packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +67 −18 Original line number Diff line number Diff line Loading @@ -31,11 +31,13 @@ import android.os.UserHandle import android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS import android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS import android.util.Log import android.view.ContextThemeWrapper import android.view.View import android.view.ViewGroup import com.android.settingslib.Utils import com.android.systemui.R import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags Loading @@ -46,6 +48,7 @@ import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView import com.android.systemui.plugins.FalsingManager import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.settings.UserTracker import com.android.systemui.shared.regionsampling.RegionSamplingInstance import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.DeviceProvisionedController Loading Loading @@ -74,6 +77,7 @@ class LockscreenSmartspaceController @Inject constructor( private val bypassController: KeyguardBypassController, private val execution: Execution, @Main private val uiExecutor: Executor, @Background private val bgExecutor: Executor, @Main private val handler: Handler, optionalPlugin: Optional<BcSmartspaceDataPlugin> ) { Loading @@ -86,15 +90,36 @@ class LockscreenSmartspaceController @Inject constructor( // Smartspace can be used on multiple displays, such as when the user casts their screen private var smartspaceViews = mutableSetOf<SmartspaceView>() private var regionSamplingInstances = mutableMapOf<SmartspaceView, RegionSamplingInstance>() private val regionSamplingEnabled = featureFlags.isEnabled(Flags.REGION_SAMPLING) private var showNotifications = false private var showSensitiveContentForCurrentUser = false private var showSensitiveContentForManagedUser = false private var managedUserHandle: UserHandle? = null private val updateFun = object : RegionSamplingInstance.UpdateColorCallback { override fun updateColors() { updateTextColorFromRegionSampler() } } var stateChangeListener = object : View.OnAttachStateChangeListener { override fun onViewAttachedToWindow(v: View) { smartspaceViews.add(v as SmartspaceView) var regionSamplingInstance = RegionSamplingInstance( v, uiExecutor, bgExecutor, regionSamplingEnabled, updateFun ) regionSamplingInstance.startRegionSampler() regionSamplingInstances.put(v, regionSamplingInstance) connectSession() updateTextColorFromWallpaper() Loading @@ -104,6 +129,10 @@ class LockscreenSmartspaceController @Inject constructor( override fun onViewDetachedFromWindow(v: View) { smartspaceViews.remove(v as SmartspaceView) var regionSamplingInstance = regionSamplingInstances.getValue(v) regionSamplingInstance.stopRegionSampler() regionSamplingInstances.remove(v) if (smartspaceViews.isEmpty()) { disconnect() } Loading Loading @@ -332,9 +361,29 @@ class LockscreenSmartspaceController @Inject constructor( } } private fun updateTextColorFromRegionSampler() { smartspaceViews.forEach { val isRegionDark = regionSamplingInstances.getValue(it).currentRegionDarkness() val themeID = if (isRegionDark.isDark) { R.style.Theme_SystemUI } else { R.style.Theme_SystemUI_LightWallpaper } val themedContext = ContextThemeWrapper(context, themeID) val wallpaperTextColor = Utils.getColorAttrDefaultColor(themedContext, R.attr.wallpaperTextColor) it.setPrimaryTextColor(wallpaperTextColor) } } private fun updateTextColorFromWallpaper() { val wallpaperTextColor = Utils.getColorAttrDefaultColor(context, R.attr.wallpaperTextColor) if (!regionSamplingEnabled) { val wallpaperTextColor = Utils.getColorAttrDefaultColor(context, R.attr.wallpaperTextColor) smartspaceViews.forEach { it.setPrimaryTextColor(wallpaperTextColor) } } else { updateTextColorFromRegionSampler() } } private fun reloadSmartspace() { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt +5 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import com.android.systemui.util.mockito.eq import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.time.FakeSystemClock import java.util.Optional import java.util.concurrent.Executor import org.junit.Before import org.junit.Test import org.mockito.ArgumentCaptor Loading Loading @@ -104,6 +105,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { @Mock private lateinit var deviceProvisionedController: DeviceProvisionedController @Mock private lateinit var bgExecutor: Executor @Mock private lateinit var handler: Handler Loading Loading @@ -203,6 +207,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { keyguardBypassController, execution, executor, bgExecutor, handler, Optional.of(plugin) ) Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +67 −18 Original line number Diff line number Diff line Loading @@ -31,11 +31,13 @@ import android.os.UserHandle import android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS import android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS import android.util.Log import android.view.ContextThemeWrapper import android.view.View import android.view.ViewGroup import com.android.settingslib.Utils import com.android.systemui.R import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags Loading @@ -46,6 +48,7 @@ import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView import com.android.systemui.plugins.FalsingManager import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.settings.UserTracker import com.android.systemui.shared.regionsampling.RegionSamplingInstance import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.DeviceProvisionedController Loading Loading @@ -74,6 +77,7 @@ class LockscreenSmartspaceController @Inject constructor( private val bypassController: KeyguardBypassController, private val execution: Execution, @Main private val uiExecutor: Executor, @Background private val bgExecutor: Executor, @Main private val handler: Handler, optionalPlugin: Optional<BcSmartspaceDataPlugin> ) { Loading @@ -86,15 +90,36 @@ class LockscreenSmartspaceController @Inject constructor( // Smartspace can be used on multiple displays, such as when the user casts their screen private var smartspaceViews = mutableSetOf<SmartspaceView>() private var regionSamplingInstances = mutableMapOf<SmartspaceView, RegionSamplingInstance>() private val regionSamplingEnabled = featureFlags.isEnabled(Flags.REGION_SAMPLING) private var showNotifications = false private var showSensitiveContentForCurrentUser = false private var showSensitiveContentForManagedUser = false private var managedUserHandle: UserHandle? = null private val updateFun = object : RegionSamplingInstance.UpdateColorCallback { override fun updateColors() { updateTextColorFromRegionSampler() } } var stateChangeListener = object : View.OnAttachStateChangeListener { override fun onViewAttachedToWindow(v: View) { smartspaceViews.add(v as SmartspaceView) var regionSamplingInstance = RegionSamplingInstance( v, uiExecutor, bgExecutor, regionSamplingEnabled, updateFun ) regionSamplingInstance.startRegionSampler() regionSamplingInstances.put(v, regionSamplingInstance) connectSession() updateTextColorFromWallpaper() Loading @@ -104,6 +129,10 @@ class LockscreenSmartspaceController @Inject constructor( override fun onViewDetachedFromWindow(v: View) { smartspaceViews.remove(v as SmartspaceView) var regionSamplingInstance = regionSamplingInstances.getValue(v) regionSamplingInstance.stopRegionSampler() regionSamplingInstances.remove(v) if (smartspaceViews.isEmpty()) { disconnect() } Loading Loading @@ -332,9 +361,29 @@ class LockscreenSmartspaceController @Inject constructor( } } private fun updateTextColorFromRegionSampler() { smartspaceViews.forEach { val isRegionDark = regionSamplingInstances.getValue(it).currentRegionDarkness() val themeID = if (isRegionDark.isDark) { R.style.Theme_SystemUI } else { R.style.Theme_SystemUI_LightWallpaper } val themedContext = ContextThemeWrapper(context, themeID) val wallpaperTextColor = Utils.getColorAttrDefaultColor(themedContext, R.attr.wallpaperTextColor) it.setPrimaryTextColor(wallpaperTextColor) } } private fun updateTextColorFromWallpaper() { val wallpaperTextColor = Utils.getColorAttrDefaultColor(context, R.attr.wallpaperTextColor) if (!regionSamplingEnabled) { val wallpaperTextColor = Utils.getColorAttrDefaultColor(context, R.attr.wallpaperTextColor) smartspaceViews.forEach { it.setPrimaryTextColor(wallpaperTextColor) } } else { updateTextColorFromRegionSampler() } } private fun reloadSmartspace() { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt +5 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import com.android.systemui.util.mockito.eq import com.android.systemui.util.settings.SecureSettings import com.android.systemui.util.time.FakeSystemClock import java.util.Optional import java.util.concurrent.Executor import org.junit.Before import org.junit.Test import org.mockito.ArgumentCaptor Loading Loading @@ -104,6 +105,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { @Mock private lateinit var deviceProvisionedController: DeviceProvisionedController @Mock private lateinit var bgExecutor: Executor @Mock private lateinit var handler: Handler Loading Loading @@ -203,6 +207,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { keyguardBypassController, execution, executor, bgExecutor, handler, Optional.of(plugin) ) Loading