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

Commit d4e9cfb0 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

New Pipeline: Remote Input 1/4: Extract legacy pipeline logic within NotificationRemoteInputManager

Fixes: 204127880
Bug: 203938360
Test: atest NotificationRemoteInputManagerTest SmartReplyControllerTest
Merged-In: I5424d3525601fda2b217c3d13130769106d4f50d
Change-Id: I5424d3525601fda2b217c3d13130769106d4f50d
parent 69c191b6
Loading
Loading
Loading
Loading
+324 −215

File changed.

Preview size limit exceeded, changes collapsed.

+3 −0
Original line number Diff line number Diff line
@@ -299,6 +299,9 @@ public class RemoteInputController {
        default void onRemoteInputSent(NotificationEntry entry) {}
    }

    /**
     * This is a delegate which implements some view controller pieces of the remote input process
     */
    public interface Delegate {
        /**
         * Activate remote input if necessary.
+4 −0
Original line number Diff line number Diff line
@@ -96,9 +96,11 @@ public interface StatusBarDependenciesModule {
    @Provides
    static NotificationRemoteInputManager provideNotificationRemoteInputManager(
            Context context,
            FeatureFlags featureFlags,
            NotificationLockscreenUserManager lockscreenUserManager,
            SmartReplyController smartReplyController,
            NotificationEntryManager notificationEntryManager,
            NotifPipeline notifPipeline,
            Lazy<Optional<StatusBar>> statusBarOptionalLazy,
            StatusBarStateController statusBarStateController,
            Handler mainHandler,
@@ -108,9 +110,11 @@ public interface StatusBarDependenciesModule {
            DumpManager dumpManager) {
        return new NotificationRemoteInputManager(
                context,
                featureFlags,
                lockscreenUserManager,
                smartReplyController,
                notificationEntryManager,
                notifPipeline,
                statusBarOptionalLazy,
                statusBarStateController,
                mainHandler,
+36 −14
Original line number Diff line number Diff line
@@ -22,14 +22,16 @@ import android.service.notification.StatusBarNotification;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;

import androidx.annotation.NonNull;
import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationRemoteInputManager.RemoteInputActiveExtender;
import com.android.systemui.statusbar.NotificationRemoteInputManager.RemoteInputHistoryExtender;
import com.android.systemui.statusbar.NotificationRemoteInputManager.SmartReplyHistoryExtender;
import com.android.systemui.statusbar.NotificationRemoteInputManager.LegacyRemoteInputLifetimeExtender.RemoteInputActiveExtender;
import com.android.systemui.statusbar.NotificationRemoteInputManager.LegacyRemoteInputLifetimeExtender.RemoteInputHistoryExtender;
import com.android.systemui.statusbar.NotificationRemoteInputManager.LegacyRemoteInputLifetimeExtender.SmartReplyHistoryExtender;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
@@ -76,12 +78,15 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
    private RemoteInputHistoryExtender mRemoteInputHistoryExtender;
    private SmartReplyHistoryExtender mSmartReplyHistoryExtender;
    private RemoteInputActiveExtender mRemoteInputActiveExtender;
    private TestableNotificationRemoteInputManager.FakeLegacyRemoteInputLifetimeExtender
            mLegacyRemoteInputLifetimeExtender;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);

        mRemoteInputManager = new TestableNotificationRemoteInputManager(mContext,
                mock(FeatureFlags.class),
                mLockscreenUserManager, mSmartReplyController, mEntryManager,
                () -> Optional.of(mock(StatusBar.class)),
                mStateController,
@@ -151,12 +156,13 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
    public void testNotificationWithRemoteInputActiveIsRemovedOnCollapse() {
        mRemoteInputActiveExtender.setShouldManageLifetime(mEntry, true /* shouldManage */);

        assertEquals(mRemoteInputManager.getEntriesKeptForRemoteInputActive(),
        assertEquals(mLegacyRemoteInputLifetimeExtender.getEntriesKeptForRemoteInputActive(),
                Sets.newArraySet(mEntry));

        mRemoteInputManager.onPanelCollapsed();

        assertTrue(mRemoteInputManager.getEntriesKeptForRemoteInputActive().isEmpty());
        assertTrue(
                mLegacyRemoteInputLifetimeExtender.getEntriesKeptForRemoteInputActive().isEmpty());
    }

    @Test
@@ -266,6 +272,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {

        TestableNotificationRemoteInputManager(
                Context context,
                FeatureFlags featureFlags,
                NotificationLockscreenUserManager lockscreenUserManager,
                SmartReplyController smartReplyController,
                NotificationEntryManager notificationEntryManager,
@@ -278,6 +285,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
                DumpManager dumpManager) {
            super(
                    context,
                    featureFlags,
                    lockscreenUserManager,
                    smartReplyController,
                    notificationEntryManager,
@@ -297,6 +305,18 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
            mRemoteInputController = controller;
        }

        @NonNull
        @Override
        protected LegacyRemoteInputLifetimeExtender createLegacyRemoteInputLifetimeExtender(
                Handler mainHandler,
                NotificationEntryManager notificationEntryManager,
                SmartReplyController smartReplyController) {
            mLegacyRemoteInputLifetimeExtender = new FakeLegacyRemoteInputLifetimeExtender();
            return mLegacyRemoteInputLifetimeExtender;
        }

        class FakeLegacyRemoteInputLifetimeExtender extends LegacyRemoteInputLifetimeExtender {

            @Override
            protected void addLifetimeExtenders() {
                mRemoteInputActiveExtender = new RemoteInputActiveExtender();
@@ -307,4 +327,6 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
                mLifetimeExtenders.add(mRemoteInputActiveExtender);
            }
        }

    }
}
+6 −1
Original line number Diff line number Diff line
@@ -39,8 +39,10 @@ import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -95,8 +97,11 @@ public class SmartReplyControllerTest extends SysuiTestCase {
                mSmartReplyController);

        mRemoteInputManager = new NotificationRemoteInputManager(mContext,
                mock(FeatureFlags.class),
                mock(NotificationLockscreenUserManager.class), mSmartReplyController,
                mNotificationEntryManager, () -> Optional.of(mock(StatusBar.class)),
                mNotificationEntryManager,
                mock(NotifPipeline.class),
                () -> Optional.of(mock(StatusBar.class)),
                mStatusBarStateController,
                Handler.createAsync(Looper.myLooper()),
                mRemoteInputUriController,