Loading packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +11 −4 Original line number Diff line number Diff line Loading @@ -20,9 +20,11 @@ import android.app.PendingIntent; import android.app.smartspace.SmartspaceAction; import android.app.smartspace.SmartspaceTarget; import android.app.smartspace.SmartspaceTargetEvent; import android.content.ActivityNotFoundException; import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Parcelable; import android.util.Log; import android.view.View; import android.view.ViewGroup; Loading @@ -39,6 +41,7 @@ import java.util.List; public interface BcSmartspaceDataPlugin extends Plugin { String ACTION = "com.android.systemui.action.PLUGIN_BC_SMARTSPACE_DATA"; int VERSION = 1; String TAG = "BcSmartspaceDataPlugin"; /** Register a listener to get Smartspace data. */ void registerListener(SmartspaceTargetListener listener); Loading Loading @@ -124,11 +127,15 @@ public interface BcSmartspaceDataPlugin extends Plugin { /** Interface for launching Intents, which can differ on the lockscreen */ interface IntentStarter { default void startFromAction(SmartspaceAction action, View v, boolean showOnLockscreen) { try { if (action.getIntent() != null) { startIntent(v, action.getIntent(), showOnLockscreen); } else if (action.getPendingIntent() != null) { startPendingIntent(action.getPendingIntent(), showOnLockscreen); } } catch (ActivityNotFoundException e) { Log.w(TAG, "Could not launch intent for action: " + action, e); } } /** Start the intent */ Loading packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,10 @@ class LockscreenSmartspaceController @Inject constructor( configurationController.addCallback(configChangeListener) statusBarStateController.addCallback(statusBarStateListener) plugin.registerSmartspaceEventNotifier { e -> session?.notifySmartspaceEvent(e) } reloadSmartspace() } Loading @@ -265,6 +269,7 @@ class LockscreenSmartspaceController @Inject constructor( statusBarStateController.removeCallback(statusBarStateListener) session = null plugin?.registerSmartspaceEventNotifier(null) plugin?.onTargetsAvailable(emptyList()) Log.d(TAG, "Ending smartspace session for lockscreen") } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt +5 −2 Original line number Diff line number Diff line Loading @@ -213,6 +213,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { // THEN the session is created verify(smartspaceManager).createSmartspaceSession(any()) // THEN an event notifier is registered verify(plugin).registerSmartspaceEventNotifier(any()) } @Test Loading Loading @@ -240,7 +242,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { } @Test fun testEmptyListIsEmittedAfterDisconnect() { fun testEmptyListIsEmittedAndNotifierRemovedAfterDisconnect() { // GIVEN a registered listener on an active session connectSession() clearInvocations(plugin) Loading @@ -249,8 +251,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View) controller.disconnect() // THEN the listener receives an empty list of targets // THEN the listener receives an empty list of targets and unregisters the notifier verify(plugin).onTargetsAvailable(emptyList()) verify(plugin).registerSmartspaceEventNotifier(null) } @Test Loading Loading
packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +11 −4 Original line number Diff line number Diff line Loading @@ -20,9 +20,11 @@ import android.app.PendingIntent; import android.app.smartspace.SmartspaceAction; import android.app.smartspace.SmartspaceTarget; import android.app.smartspace.SmartspaceTargetEvent; import android.content.ActivityNotFoundException; import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Parcelable; import android.util.Log; import android.view.View; import android.view.ViewGroup; Loading @@ -39,6 +41,7 @@ import java.util.List; public interface BcSmartspaceDataPlugin extends Plugin { String ACTION = "com.android.systemui.action.PLUGIN_BC_SMARTSPACE_DATA"; int VERSION = 1; String TAG = "BcSmartspaceDataPlugin"; /** Register a listener to get Smartspace data. */ void registerListener(SmartspaceTargetListener listener); Loading Loading @@ -124,11 +127,15 @@ public interface BcSmartspaceDataPlugin extends Plugin { /** Interface for launching Intents, which can differ on the lockscreen */ interface IntentStarter { default void startFromAction(SmartspaceAction action, View v, boolean showOnLockscreen) { try { if (action.getIntent() != null) { startIntent(v, action.getIntent(), showOnLockscreen); } else if (action.getPendingIntent() != null) { startPendingIntent(action.getPendingIntent(), showOnLockscreen); } } catch (ActivityNotFoundException e) { Log.w(TAG, "Could not launch intent for action: " + action, e); } } /** Start the intent */ Loading
packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,10 @@ class LockscreenSmartspaceController @Inject constructor( configurationController.addCallback(configChangeListener) statusBarStateController.addCallback(statusBarStateListener) plugin.registerSmartspaceEventNotifier { e -> session?.notifySmartspaceEvent(e) } reloadSmartspace() } Loading @@ -265,6 +269,7 @@ class LockscreenSmartspaceController @Inject constructor( statusBarStateController.removeCallback(statusBarStateListener) session = null plugin?.registerSmartspaceEventNotifier(null) plugin?.onTargetsAvailable(emptyList()) Log.d(TAG, "Ending smartspace session for lockscreen") } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt +5 −2 Original line number Diff line number Diff line Loading @@ -213,6 +213,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { // THEN the session is created verify(smartspaceManager).createSmartspaceSession(any()) // THEN an event notifier is registered verify(plugin).registerSmartspaceEventNotifier(any()) } @Test Loading Loading @@ -240,7 +242,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { } @Test fun testEmptyListIsEmittedAfterDisconnect() { fun testEmptyListIsEmittedAndNotifierRemovedAfterDisconnect() { // GIVEN a registered listener on an active session connectSession() clearInvocations(plugin) Loading @@ -249,8 +251,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View) controller.disconnect() // THEN the listener receives an empty list of targets // THEN the listener receives an empty list of targets and unregisters the notifier verify(plugin).onTargetsAvailable(emptyList()) verify(plugin).registerSmartspaceEventNotifier(null) } @Test Loading