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

Commit b1c3b17e authored by Bryce Lee's avatar Bryce Lee
Browse files

Address communal callbacks in NotificationPanelViewController.

This change ensures communal callbacks in
NotificationPanelViewController happen on the
proper thread.

Test: atest NotificationPanelViewControllerTest
Bug: 206500528
Change-Id: I82bb443cdd1945d02c6fd0ecbbc7fc9f9857f783
parent be7e4f4d
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -506,23 +506,11 @@ public class NotificationPanelViewController extends PanelViewController {
                    mPanelAlphaAnimator.getProperty(), Interpolators.ALPHA_IN);
    private final NotificationEntryManager mEntryManager;

    private final CommunalSourceMonitor.Callback mCommunalSourceMonitorCallback =
            new CommunalSourceMonitor.Callback() {
                @Override
                public void onSourceAvailable(WeakReference<CommunalSource> source) {
                    setCommunalSource(source);
                }
            };
    private final CommunalSourceMonitor.Callback mCommunalSourceMonitorCallback;

    private WeakReference<CommunalSource> mCommunalSource;

    private final CommunalSource.Callback mCommunalSourceCallback =
            new CommunalSource.Callback() {
                @Override
                public void onDisconnected() {
                    setCommunalSource(null /*source*/);
                }
            };
    private final CommunalSource.Callback mCommunalSourceCallback;

    private final CommandQueue mCommandQueue;
    private final NotificationLockscreenUserManager mLockscreenUserManager;
@@ -904,6 +892,15 @@ public class NotificationPanelViewController extends PanelViewController {

        mMaxKeyguardNotifications = resources.getInteger(R.integer.keyguard_max_notification_count);
        mKeyguardUnfoldTransition = unfoldComponent.map(c -> c.getKeyguardUnfoldTransition());

        mCommunalSourceCallback = () -> {
            mUiExecutor.execute(() -> setCommunalSource(null /*source*/));
        };

        mCommunalSourceMonitorCallback = (source) -> {
            mUiExecutor.execute(() -> setCommunalSource(source));
        };

        updateUserSwitcherFlags();
        onFinishInflate();
    }
+3 −1
Original line number Diff line number Diff line
@@ -358,6 +358,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
    private NotificationsQuickSettingsContainer mNotificationContainerParent;
    private List<View.OnAttachStateChangeListener> mOnAttachStateChangeListeners;
    private FalsingManagerFake mFalsingManager = new FalsingManagerFake();
    private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());

    @Before
    public void setup() {
@@ -511,7 +512,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
                mQuickAccessWalletController,
                mQrCodeScannerController,
                mRecordingController,
                new FakeExecutor(new FakeSystemClock()),
                mExecutor,
                mSecureSettings,
                mSplitShadeHeaderController,
                mUnlockedScreenOffAnimationController,
@@ -936,6 +937,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
                ArgumentCaptor.forClass(WeakReference.class);

        monitorCallback.getValue().onSourceAvailable(new WeakReference<>(mCommunalSource));
        mExecutor.runAllReady();
        verify(mCommunalHostViewController).show(sourceCapture.capture());
        assertThat(sourceCapture.getValue().get()).isEqualTo(mCommunalSource);