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

Commit 1737d749 authored by William Leshner's avatar William Leshner Committed by Automerger Merge Worker
Browse files

Merge "Disable the notifications status icon in dream status bar." into...

Merge "Disable the notifications status icon in dream status bar." into tm-qpr-dev am: 653d715c am: 75dec477

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18896222



Change-Id: If01d5ed368705df6cbe63a7e5cc58a2af3c6dfe9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 640d052e 75dec477
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;

import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationListener.NotificationHandler;
@@ -33,13 +32,10 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;

import javax.inject.Inject;

/***
 * {@link DreamOverlayNotificationCountProvider} provides the current notification count to
 * registered callbacks. Ongoing notifications are not included in the count.
 */
@SysUISingleton
public class DreamOverlayNotificationCountProvider
        implements CallbackController<DreamOverlayNotificationCountProvider.Callback> {
    private final Set<String> mNotificationKeys = new HashSet<>();
@@ -82,7 +78,6 @@ public class DreamOverlayNotificationCountProvider
        }
    };

    @Inject
    public DreamOverlayNotificationCountProvider(
            NotificationListener notificationListener,
            @Background Executor bgExecutor) {
+9 −4
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.systemui.util.time.DateFormatUtil;

import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Executor;

import javax.inject.Inject;
@@ -65,7 +66,8 @@ public class DreamOverlayStatusBarViewController extends ViewController<DreamOve
    private final Resources mResources;
    private final DateFormatUtil mDateFormatUtil;
    private final IndividualSensorPrivacyController mSensorPrivacyController;
    private final DreamOverlayNotificationCountProvider mDreamOverlayNotificationCountProvider;
    private final Optional<DreamOverlayNotificationCountProvider>
            mDreamOverlayNotificationCountProvider;
    private final ZenModeController mZenModeController;
    private final Executor mMainExecutor;

@@ -125,7 +127,7 @@ public class DreamOverlayStatusBarViewController extends ViewController<DreamOve
            NextAlarmController nextAlarmController,
            DateFormatUtil dateFormatUtil,
            IndividualSensorPrivacyController sensorPrivacyController,
            DreamOverlayNotificationCountProvider dreamOverlayNotificationCountProvider,
            Optional<DreamOverlayNotificationCountProvider> dreamOverlayNotificationCountProvider,
            ZenModeController zenModeController,
            StatusBarWindowStateController statusBarWindowStateController) {
        super(view);
@@ -161,7 +163,9 @@ public class DreamOverlayStatusBarViewController extends ViewController<DreamOve
        mZenModeController.addCallback(mZenModeCallback);
        updatePriorityModeStatusIcon();

        mDreamOverlayNotificationCountProvider.addCallback(mNotificationCountCallback);
        mDreamOverlayNotificationCountProvider.ifPresent(
                provider -> provider.addCallback(mNotificationCountCallback));

        mTouchInsetSession.addViewToTracking(mView);
    }

@@ -171,7 +175,8 @@ public class DreamOverlayStatusBarViewController extends ViewController<DreamOve
        mSensorPrivacyController.removeCallback(mSensorCallback);
        mNextAlarmController.removeCallback(mNextAlarmCallback);
        mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
        mDreamOverlayNotificationCountProvider.removeCallback(mNotificationCountCallback);
        mDreamOverlayNotificationCountProvider.ifPresent(
                provider -> provider.removeCallback(mNotificationCountCallback));
        mTouchInsetSession.clear();

        mIsAttached = false;
+16 −0
Original line number Diff line number Diff line
@@ -20,9 +20,13 @@ import android.content.Context;
import android.content.res.Resources;

import com.android.settingslib.dream.DreamBackend;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dreams.DreamOverlayNotificationCountProvider;
import com.android.systemui.dreams.complication.dagger.RegisteredComplicationsModule;

import java.util.Optional;

import javax.inject.Named;

import dagger.Module;
@@ -50,6 +54,18 @@ public interface DreamModule {
        return DreamBackend.getInstance(context);
    }

    /**
     * Provides an instance of a {@link DreamOverlayNotificationCountProvider}.
     */
    @SysUISingleton
    @Provides
    static Optional<DreamOverlayNotificationCountProvider>
            providesDreamOverlayNotificationCountProvider() {
        // If we decide to bring this back, we should gate it on a config that can be changed in
        // an overlay.
        return Optional.empty();
    }

    /** */
    @Provides
    @Named(DREAM_ONLY_ENABLED_FOR_SYSTEM_USER)
+22 −1
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.Optional;
import java.util.concurrent.Executor;

@SmallTest
@@ -115,7 +116,7 @@ public class DreamOverlayStatusBarViewControllerTest extends SysuiTestCase {
                mNextAlarmController,
                mDateFormatUtil,
                mSensorPrivacyController,
                mDreamOverlayNotificationCountProvider,
                Optional.of(mDreamOverlayNotificationCountProvider),
                mZenModeController,
                mStatusBarWindowStateController);
    }
@@ -230,6 +231,26 @@ public class DreamOverlayStatusBarViewControllerTest extends SysuiTestCase {
                eq(DreamOverlayStatusBarView.STATUS_ICON_NOTIFICATIONS), eq(false), isNull());
    }

    @Test
    public void testNotificationsIconNotShownWhenCountProviderAbsent() {
        DreamOverlayStatusBarViewController controller = new DreamOverlayStatusBarViewController(
                mView,
                mResources,
                mMainExecutor,
                mConnectivityManager,
                mTouchSession,
                mAlarmManager,
                mNextAlarmController,
                mDateFormatUtil,
                mSensorPrivacyController,
                Optional.empty(),
                mZenModeController,
                mStatusBarWindowStateController);
        controller.onViewAttached();
        verify(mView, never()).showIcon(
                eq(DreamOverlayStatusBarView.STATUS_ICON_NOTIFICATIONS), eq(true), any());
    }

    @Test
    public void testOnViewAttachedShowsPriorityModeIconWhenEnabled() {
        when(mZenModeController.getZen()).thenReturn(