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

Commit 30aa4d3c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Flips default for new interruption model setting to on."

parents 873d88d2 9b2348b1
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -19,8 +19,7 @@ package android.ext.services.notification;
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.service.notification.Adjustment.KEY_IMPORTANCE;
import static android.service.notification.Adjustment.KEY_IMPORTANCE;
import static android.service.notification.NotificationListenerService.Ranking
import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE;
        .USER_SENTIMENT_NEGATIVE;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
@@ -241,7 +240,7 @@ public class Assistant extends NotificationAssistantService {
            signals.putCharSequenceArrayList(Adjustment.KEY_SMART_REPLIES, smartReplies);
            signals.putCharSequenceArrayList(Adjustment.KEY_SMART_REPLIES, smartReplies);
        }
        }
        if (Settings.Secure.getInt(getContentResolver(),
        if (Settings.Secure.getInt(getContentResolver(),
                Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL, 0) == 1) {
                Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL, 1) == 1) {
            if (mNotificationCategorizer.shouldSilence(entry)) {
            if (mNotificationCategorizer.shouldSilence(entry)) {
                final int importance = entry.getImportance() < IMPORTANCE_LOW
                final int importance = entry.getImportance() < IMPORTANCE_LOW
                        ? entry.getImportance() : IMPORTANCE_LOW;
                        ? entry.getImportance() : IMPORTANCE_LOW;
+1 −1
Original line number Original line Diff line number Diff line
@@ -75,6 +75,6 @@ public class NotificationUtils {
    /** Returns the value of the new interruption model setting. */
    /** Returns the value of the new interruption model setting. */
    public static boolean useNewInterruptionModel(Context context) {
    public static boolean useNewInterruptionModel(Context context) {
        return Settings.Secure.getInt(context.getContentResolver(),
        return Settings.Secure.getInt(context.getContentResolver(),
                NOTIFICATION_NEW_INTERRUPTION_MODEL, 0) != 0;
                NOTIFICATION_NEW_INTERRUPTION_MODEL, 1) != 0;
    }
    }
}
}
+14 −11
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;


import android.app.Notification;
import android.app.NotificationChannel;
import android.service.notification.StatusBarNotification;
import android.service.notification.StatusBarNotification;
import android.support.test.filters.SmallTest;
import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.AndroidTestingRunner;
@@ -35,6 +35,7 @@ import android.testing.ViewUtils;
import android.view.ViewGroup;
import android.view.ViewGroup;


import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.notification.NotificationData;
import com.android.systemui.utils.leaks.LeakCheckedTest;
import com.android.systemui.utils.leaks.LeakCheckedTest;


import org.junit.Before;
import org.junit.Before;
@@ -43,19 +44,26 @@ import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.Mockito;


@RunWith(AndroidTestingRunner.class)
@RunWith(AndroidTestingRunner.class)
@RunWithLooper()
@RunWithLooper(setAsMainLooper = true)
@SmallTest
@SmallTest
public class NotificationMenuRowTest extends LeakCheckedTest {
public class NotificationMenuRowTest extends LeakCheckedTest {


    private ExpandableNotificationRow mRow;

    @Before
    @Before
    public void setup() {
    public void setup() {
        injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES);
        injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES);
        mRow = mock(ExpandableNotificationRow.class);
        NotificationData.Entry entry = new NotificationData.Entry(
                mock(StatusBarNotification.class));
        entry.channel = mock(NotificationChannel.class);
        when(mRow.getEntry()).thenReturn(entry);
    }
    }


    @Test
    @Test
    public void testAttachDetach() {
    public void testAttachDetach() {
        NotificationMenuRowPlugin row = new NotificationMenuRow(mContext);
        NotificationMenuRowPlugin row = new NotificationMenuRow(mContext);
        row.createMenu(null, null);
        row.createMenu(mRow, null);
        ViewUtils.attachView(row.getMenuView());
        ViewUtils.attachView(row.getMenuView());
        TestableLooper.get(this).processAllMessages();
        TestableLooper.get(this).processAllMessages();
        ViewUtils.detachView(row.getMenuView());
        ViewUtils.detachView(row.getMenuView());
@@ -65,9 +73,9 @@ public class NotificationMenuRowTest extends LeakCheckedTest {
    @Test
    @Test
    public void testRecreateMenu() {
    public void testRecreateMenu() {
        NotificationMenuRowPlugin row = new NotificationMenuRow(mContext);
        NotificationMenuRowPlugin row = new NotificationMenuRow(mContext);
        row.createMenu(null, null);
        row.createMenu(mRow, null);
        assertTrue(row.getMenuView() != null);
        assertTrue(row.getMenuView() != null);
        row.createMenu(null, null);
        row.createMenu(mRow, null);
        assertTrue(row.getMenuView() != null);
        assertTrue(row.getMenuView() != null);
    }
    }


@@ -81,12 +89,7 @@ public class NotificationMenuRowTest extends LeakCheckedTest {
    @Test
    @Test
    public void testNoAppOpsInSlowSwipe() {
    public void testNoAppOpsInSlowSwipe() {
        NotificationMenuRow row = new NotificationMenuRow(mContext);
        NotificationMenuRow row = new NotificationMenuRow(mContext);
        Notification n = mock(Notification.class);
        row.createMenu(mRow, null);
        StatusBarNotification sbn = mock(StatusBarNotification.class);
        when(sbn.getNotification()).thenReturn(n);
        ExpandableNotificationRow parent = mock(ExpandableNotificationRow.class);
        when(parent.getStatusBarNotification()).thenReturn(sbn);
        row.createMenu(parent, null);


        ViewGroup container = (ViewGroup) row.getMenuView();
        ViewGroup container = (ViewGroup) row.getMenuView();
        // one for snooze and one for noti blocking
        // one for snooze and one for noti blocking