Merge "Add SmartspaceView.setUiSurface and set it for lockscreen Smartspace." into tm-qpr-dev

This commit is contained in:
Xiaowen Lei
2023-01-06 00:48:15 +00:00
committed by Android (Google) Code Review
4 changed files with 25 additions and 5 deletions

View File

@@ -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
*/

View File

@@ -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

View File

@@ -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?) {}

View File

@@ -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) {
}