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

Commit 5dc581ae authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an issue about notification icons on AOD

Previously this was tied to the removed statusbar setting.
We're making them consistent with the setting of the appearnace
on the lockscreen.

Bug: 135627468
Test: atest SystemUITests
Change-Id: Ia64238f30620d9906aa50c2469121c2653875e8d
parent 999230c3
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -150,10 +150,9 @@ public class SystemUIFactory {
            StatusBar statusBar,
            NotificationWakeUpCoordinator wakeUpCoordinator,
            KeyguardBypassController keyguardBypassController,
            StatusBarStateController statusBarStateController,
            NotificationListener listener) {
            StatusBarStateController statusBarStateController) {
        return new NotificationIconAreaController(context, statusBar, statusBarStateController,
                wakeUpCoordinator, keyguardBypassController, listener,
                wakeUpCoordinator, keyguardBypassController,
                Dependency.get(NotificationMediaManager.class));
    }

+10 −23
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -33,6 +34,7 @@ import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.tuner.TunerService;

import java.util.ArrayList;
import java.util.Objects;
@@ -57,20 +59,8 @@ public class NotificationIconAreaController implements DarkReceiver,
    private final NotificationWakeUpCoordinator mWakeUpCoordinator;
    private final KeyguardBypassController mBypassController;
    private final DozeParameters mDozeParameters;
    @VisibleForTesting
    final NotificationListener.NotificationSettingsListener mSettingsListener =
            new NotificationListener.NotificationSettingsListener() {
                @Override
                public void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) {
                    if (NotificationUtils.useNewInterruptionModel(mContext)) {
                        mShowLowPriority = !hideSilentStatusIcons;
                        if (mNotificationScrollLayout != null) {
                            updateStatusBarIcons();
                        }
                    }
                }
            };

    private boolean mShowSilentOnLockscreen = true;
    private int mIconSize;
    private int mIconHPadding;
    private int mIconTint = Color.WHITE;
@@ -87,7 +77,6 @@ public class NotificationIconAreaController implements DarkReceiver,
    private final Rect mTintArea = new Rect();
    private ViewGroup mNotificationScrollLayout;
    private Context mContext;
    private boolean mShowLowPriority = true;
    private int mAodIconAppearTranslation;

    private boolean mAnimationsEnabled;
@@ -99,7 +88,6 @@ public class NotificationIconAreaController implements DarkReceiver,
            StatusBarStateController statusBarStateController,
            NotificationWakeUpCoordinator wakeUpCoordinator,
            KeyguardBypassController keyguardBypassController,
            NotificationListener notificationListener,
            NotificationMediaManager notificationMediaManager) {
        mStatusBar = statusBar;
        mContrastColorUtil = ContrastColorUtil.getInstance(context);
@@ -108,7 +96,6 @@ public class NotificationIconAreaController implements DarkReceiver,
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController.addCallback(this);
        mMediaManager = notificationMediaManager;
        notificationListener.addNotificationSettingsListener(mSettingsListener);
        mDozeParameters = DozeParameters.getInstance(mContext);
        mWakeUpCoordinator = wakeUpCoordinator;
        wakeUpCoordinator.addListener(this);
@@ -116,6 +103,11 @@ public class NotificationIconAreaController implements DarkReceiver,

        initializeNotificationAreaViews(context);
        reloadAodColor();

        TunerService tunerService = Dependency.get(TunerService.class);
        tunerService.addTunable((key, newValue) -> {
            mShowSilentOnLockscreen = "1".equals(newValue);
        }, Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS);
    }

    protected View inflateIconArea(LayoutInflater inflater) {
@@ -314,7 +306,7 @@ public class NotificationIconAreaController implements DarkReceiver,
    public void updateStatusBarIcons() {
        updateIconsForLayout(entry -> entry.icon, mNotificationIcons,
                false /* showAmbient */,
                mShowLowPriority /* showLowPriority */,
                true /* showLowPriority */,
                true /* hideDismissed */,
                true /* hideRepliedMessages */,
                false /* hideCurrentMedia */,
@@ -336,7 +328,7 @@ public class NotificationIconAreaController implements DarkReceiver,
    public void updateAodNotificationIcons() {
        updateIconsForLayout(entry -> entry.aodIcon, mAodIcons,
                false /* showAmbient */,
                mShowLowPriority /* showLowPriority */,
                mShowSilentOnLockscreen /* showLowPriority */,
                true /* hideDismissed */,
                true /* hideRepliedMessages */,
                true /* hideCurrentMedia */,
@@ -344,11 +336,6 @@ public class NotificationIconAreaController implements DarkReceiver,
                mBypassController.getBypassEnabled() /* hidePulsing */);
    }

    @VisibleForTesting
    boolean shouldShouldLowPriorityIcons() {
        return mShowLowPriority;
    }

    /**
     * Updates the notification icons for a host layout. This will ensure that the notification
     * host layout will have the same icons like the ones in here.
+1 −1
Original line number Diff line number Diff line
@@ -800,7 +800,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        mNotificationIconAreaController = SystemUIFactory.getInstance()
                .createNotificationIconAreaController(context, this,
                        mWakeUpCoordinator, mKeyguardBypassController,
                        mStatusBarStateController, mNotificationListener);
                        mStatusBarStateController);
        mWakeUpCoordinator.setIconAreaController(mNotificationIconAreaController);
        inflateShelf();
        mNotificationIconAreaController.setupShelf(mNotificationShelf);
+0 −102
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.phone;

import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

import android.provider.Settings;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;

import androidx.test.filters.SmallTest;

import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class NotificationIconAreaControllerTest extends SysuiTestCase {

    @Mock
    private NotificationListener mListener;
    @Mock
    StatusBar mStatusBar;
    @Mock
    StatusBarWindowView mStatusBarWindowView;
    @Mock
    NotificationIconContainer mIconContainer;
    @Mock
    StatusBarStateController mStatusBarStateController;
    @Mock
    NotificationWakeUpCoordinator mNotificationWakeUpCoordinator;
    @Mock
    KeyguardBypassController mBypassController;
    @Mock
    private NotificationMediaManager mMediaManager;
    private NotificationIconAreaController mController;

    @Before
    public void setup() {
        MockitoAnnotations.initMocks(this);
        when(mStatusBar.getStatusBarWindow()).thenReturn(mStatusBarWindowView);
        when(mStatusBarWindowView.findViewById(R.id.clock_notification_icon_container)).thenReturn(
                mIconContainer);
        mController = new NotificationIconAreaController(mContext, mStatusBar,
                mStatusBarStateController, mNotificationWakeUpCoordinator, mBypassController,
                mListener, mMediaManager);
    }

    @Test
    public void testNotificationIcons_featureOff() {
        Settings.Secure.putInt(
                mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 0);
        assertTrue(mController.shouldShouldLowPriorityIcons());
    }

    @Test
    public void testNotificationIcons_featureOn_settingHideIcons() {
        Settings.Secure.putInt(
                mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
        mController.mSettingsListener.onStatusBarIconsBehaviorChanged(true);

        assertFalse(mController.shouldShouldLowPriorityIcons());
    }

    @Test
    public void testNotificationIcons_featureOn_settingShowIcons() {
        Settings.Secure.putInt(
                mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
        mController.mSettingsListener.onStatusBarIconsBehaviorChanged(false);

        assertTrue(mController.shouldShouldLowPriorityIcons());
    }
}