Add SmartspaceView.setUiSurface and set it for lockscreen Smartspace.
Currently, we only need to set this for lockscreen Smartspace. When the UI surface is set to "lockscreen", the date will update on Always-On Display. See ag/20750544. We can also deprecate the existing setIsDreaming method in favor of setUiSurface. That's a separate issue and will be addressed separately. Bug: 262046287 Test: manunal. Compared behavior and trace before/after the fix. Test: atest LockscreenSmartspaceControllerTest.kt Change-Id: I57126499dce033444d2c134f33a8b417e111ba65
This commit is contained in:
@@ -40,6 +40,11 @@ import java.util.List;
|
||||
*/
|
||||
@ProvidesInterface(action = BcSmartspaceDataPlugin.ACTION, version = BcSmartspaceDataPlugin.VERSION)
|
||||
public interface BcSmartspaceDataPlugin extends Plugin {
|
||||
String UI_SURFACE_LOCK_SCREEN_AOD = "lockscreen";
|
||||
String UI_SURFACE_HOME_SCREEN = "home";
|
||||
String UI_SURFACE_MEDIA = "media_data_manager";
|
||||
String UI_SURFACE_DREAM = "dream";
|
||||
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_BC_SMARTSPACE_DATA";
|
||||
int VERSION = 1;
|
||||
String TAG = "BcSmartspaceDataPlugin";
|
||||
@@ -99,6 +104,11 @@ public interface BcSmartspaceDataPlugin extends Plugin {
|
||||
*/
|
||||
void setIsDreaming(boolean isDreaming);
|
||||
|
||||
/**
|
||||
* Set the UI surface for the cards. Should be called immediately after the view is created.
|
||||
*/
|
||||
void setUiSurface(String uiSurface);
|
||||
|
||||
/**
|
||||
* Range [0.0 - 1.0] when transitioning from Lockscreen to/from AOD
|
||||
*/
|
||||
|
||||
@@ -238,6 +238,7 @@ class LockscreenSmartspaceController @Inject constructor(
|
||||
}
|
||||
|
||||
val ssView = plugin.getView(parent)
|
||||
ssView.setUiSurface(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
||||
ssView.registerDataProvider(plugin)
|
||||
|
||||
ssView.setIntentStarter(object : BcSmartspaceDataPlugin.IntentStarter {
|
||||
@@ -281,8 +282,10 @@ class LockscreenSmartspaceController @Inject constructor(
|
||||
}
|
||||
|
||||
val newSession = smartspaceManager.createSmartspaceSession(
|
||||
SmartspaceConfig.Builder(context, "lockscreen").build())
|
||||
Log.d(TAG, "Starting smartspace session for lockscreen")
|
||||
SmartspaceConfig.Builder(
|
||||
context, BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD).build())
|
||||
Log.d(TAG, "Starting smartspace session for " +
|
||||
BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
||||
newSession.addOnTargetsAvailableListener(uiExecutor, sessionListener)
|
||||
this.session = newSession
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {
|
||||
|
||||
override fun setIsDreaming(isDreaming: Boolean) {}
|
||||
|
||||
override fun setUiSurface(uiSurface: String) {}
|
||||
|
||||
override fun setDozeAmount(amount: Float) {}
|
||||
|
||||
override fun setIntentStarter(intentStarter: BcSmartspaceDataPlugin.IntentStarter?) {}
|
||||
|
||||
@@ -55,21 +55,21 @@ import com.android.systemui.util.mockito.capture
|
||||
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
|
||||
import org.mockito.Captor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.anyInt
|
||||
import org.mockito.Mockito.clearInvocations
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.spy
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.MockitoAnnotations
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.Executor
|
||||
|
||||
@SmallTest
|
||||
class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
||||
@@ -518,6 +518,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
||||
|
||||
// THEN the existing session is reused and views are registered
|
||||
verify(smartspaceManager, never()).createSmartspaceSession(any())
|
||||
verify(smartspaceView2).setUiSurface(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
||||
verify(smartspaceView2).registerDataProvider(plugin)
|
||||
}
|
||||
|
||||
@@ -554,6 +555,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
||||
|
||||
controller.stateChangeListener.onViewAttachedToWindow(view)
|
||||
|
||||
verify(smartspaceView).setUiSurface(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
||||
verify(smartspaceView).registerDataProvider(plugin)
|
||||
verify(smartspaceSession)
|
||||
.addOnTargetsAvailableListener(any(), capture(sessionListenerCaptor))
|
||||
@@ -642,6 +644,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
||||
override fun setIsDreaming(isDreaming: Boolean) {
|
||||
}
|
||||
|
||||
override fun setUiSurface(uiSurface: String) {
|
||||
}
|
||||
|
||||
override fun setDozeAmount(amount: Float) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user