Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3e3fd35 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Wrapping intentstarter in event notifier instead of in the view directly

Bug: 390572144
Test: Manual
Flag: EXEMPT refactor
Change-Id: I513f05e4dd7e4f3bed9e842cd31d871293e75a89
parent c13f76aa
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -94,8 +94,6 @@ class CommunalSmartspaceControllerTest : SysuiTestCase() {

        override fun setDozeAmount(amount: Float) {}

        override fun setIntentStarter(intentStarter: BcSmartspaceDataPlugin.IntentStarter?) {}

        override fun setFalsingManager(falsingManager: FalsingManager?) {}

        override fun setDnd(image: Drawable?, description: String?) {}
@@ -200,6 +198,6 @@ class CommunalSmartspaceControllerTest : SysuiTestCase() {

        // And the listener receives an empty list of targets and unregisters the notifier
        verify(plugin).onTargetsAvailable(emptyList())
        verify(plugin).registerSmartspaceEventNotifier(null)
        verify(plugin).setEventDispatcher(null)
    }
}
+1 −3
Original line number Diff line number Diff line
@@ -115,8 +115,6 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {

        override fun setDozeAmount(amount: Float) {}

        override fun setIntentStarter(intentStarter: BcSmartspaceDataPlugin.IntentStarter?) {}

        override fun setFalsingManager(falsingManager: FalsingManager?) {}

        override fun setDnd(image: Drawable?, description: String?) {}
@@ -299,6 +297,6 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {

        // And the listener receives an empty list of targets and unregisters the notifier
        verify(weatherPlugin).onTargetsAvailable(emptyList())
        verify(weatherPlugin).registerSmartspaceEventNotifier(null)
        verify(weatherPlugin).setEventDispatcher(null)
    }
}
+4 −16
Original line number Diff line number Diff line
@@ -273,7 +273,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
        // THEN the session is created
        verify(smartspaceManager).createSmartspaceSession(any())
        // THEN an event notifier is registered
        verify(plugin).registerSmartspaceEventNotifier(any())
        verify(plugin).setEventDispatcher(any())
    }

    @Test
@@ -320,10 +320,10 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {

        // THEN the listener receives an empty list of targets and unregisters the notifier
        verify(plugin).onTargetsAvailable(emptyList())
        verify(plugin).registerSmartspaceEventNotifier(null)
        verify(plugin).setEventDispatcher(null)
        verify(weatherPlugin).onTargetsAvailable(emptyList())
        verify(weatherPlugin).registerSmartspaceEventNotifier(null)
        verify(datePlugin).registerSmartspaceEventNotifier(null)
        verify(weatherPlugin).setEventDispatcher(null)
        verify(datePlugin).setEventDispatcher(null)
    }

    @Test
@@ -977,10 +977,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {

                override fun setDozeAmount(amount: Float) {}

                override fun setIntentStarter(
                    intentStarter: BcSmartspaceDataPlugin.IntentStarter?
                ) {}

                override fun setFalsingManager(falsingManager: FalsingManager?) {}

                override fun setDnd(image: Drawable?, description: String?) {}
@@ -1008,10 +1004,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {

                override fun setDozeAmount(amount: Float) {}

                override fun setIntentStarter(
                    intentStarter: BcSmartspaceDataPlugin.IntentStarter?
                ) {}

                override fun setFalsingManager(falsingManager: FalsingManager?) {}
            }
        )
@@ -1038,10 +1030,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {

                override fun setKeyguardBypassEnabled(enabled: Boolean) {}

                override fun setIntentStarter(
                    intentStarter: BcSmartspaceDataPlugin.IntentStarter?
                ) {}

                override fun setFalsingManager(falsingManager: FalsingManager?) {}

                override fun setDnd(image: Drawable?, description: String?) {}
+22 −19
Original line number Diff line number Diff line
@@ -61,21 +61,17 @@ public interface BcSmartspaceDataPlugin extends Plugin {
        throw new UnsupportedOperationException("Not implemented by " + getClass());
    }

    /** Register a SmartspaceEventNotifier. */
    default void registerSmartspaceEventNotifier(SmartspaceEventNotifier notifier) {
        throw new UnsupportedOperationException("Not implemented by " + getClass());
    }
    /** Sets the event dispatcher for smart space targets. */
    void setEventDispatcher(SmartspaceEventDispatcher eventDispatcher);

    /** Push a SmartspaceTargetEvent to the SmartspaceEventNotifier. */
    default void notifySmartspaceEvent(SmartspaceTargetEvent event) {
        throw new UnsupportedOperationException("Not implemented by " + getClass());
    }
    /**
     * Overrides how Intents/PendingIntents gets launched. Mostly to support auth from
     * the lockscreen.
     */
    void setIntentStarter(IntentStarter intentStarter);

    /** Allows for notifying the SmartspaceSession of SmartspaceTargetEvents. */
    interface SmartspaceEventNotifier {
        /** Pushes a given SmartspaceTargetEvent to the SmartspaceSession. */
        void notifySmartspaceEvent(SmartspaceTargetEvent event);
    }
    /** Returns the smartspace event notifier */
    SmartspaceEventNotifier getEventNotifier();

    /**
     * Create a view to be shown within the parent. Do not add the view, as the parent
@@ -171,12 +167,6 @@ public interface BcSmartspaceDataPlugin extends Plugin {
         */
        default void setKeyguardBypassEnabled(boolean enabled) {}

        /**
         * Overrides how Intents/PendingIntents gets launched. Mostly to support auth from
         * the lockscreen.
         */
        void setIntentStarter(IntentStarter intentStarter);

        /**
         * When on the lockscreen, use the FalsingManager to help detect errant touches
         */
@@ -259,6 +249,19 @@ public interface BcSmartspaceDataPlugin extends Plugin {
        void startPendingIntent(View v, PendingIntent pi, boolean showOnLockscreen);
    }

    /** SmartspaceEventDispatcher which also controls controlling intent launching behavior */
    interface SmartspaceEventNotifier extends SmartspaceEventDispatcher {

        /** The intent starter for controlling activity launches */
        @Nullable IntentStarter getIntentStarter();
    }

    /** Allows for notifying the SmartspaceSession of SmartspaceTargetEvents. */
    interface SmartspaceEventDispatcher {
        /** Pushes a given SmartspaceTargetEvent to the SmartspaceSession. */
        void notifySmartspaceEvent(SmartspaceTargetEvent event);
    }

    /** Interface for delegating time updates */
    interface TimeChangedDelegate {
        /** Register the callback to be called when time is updated **/
+2 −2
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ constructor(
        newSession?.addOnTargetsAvailableListener(uiExecutor, sessionListener)
        this.session = newSession

        plugin?.registerSmartspaceEventNotifier { e -> session?.notifySmartspaceEvent(e) }
        plugin.setEventDispatcher { e -> session?.notifySmartspaceEvent(e) }

        reloadSmartspace()
    }
@@ -152,7 +152,7 @@ constructor(

        session = null

        plugin?.registerSmartspaceEventNotifier(null)
        plugin?.setEventDispatcher(null)
        plugin?.onTargetsAvailable(emptyList())
        Log.d(TAG, "Ending smartspace session for communal")
    }
Loading