summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java17
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java105
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationDataTest.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java12
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java9
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java9
11 files changed, 161 insertions, 28 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
index cd40f0c0ab4e..6f5fe8b629fb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
@@ -90,7 +90,6 @@ public final class NotificationEntry {
public StatusBarNotification notification;
private Ranking mRanking;
- public NotificationChannel channel;
public long lastAudiblyAlertedMs;
public boolean noisy;
public boolean ambient;
@@ -244,7 +243,6 @@ public final class NotificationEntry {
public void setRanking(@NonNull Ranking ranking) {
mRanking = ranking;
- channel = ranking.getChannel();
lastAudiblyAlertedMs = ranking.getLastAudiblyAlertedMillis();
importance = ranking.getImportance();
ambient = ranking.isAmbient();
@@ -260,6 +258,10 @@ public final class NotificationEntry {
canBubble = ranking.canBubble();
}
+ public NotificationChannel getChannel() {
+ return mRanking.getChannel();
+ }
+
public void setInterruption() {
interruption = true;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
index 12d537d3c646..0f6ce2153488 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
@@ -520,7 +520,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
public boolean getIsNonblockable() {
boolean isNonblockable = Dependency.get(NotificationBlockingHelperManager.class)
.isNonblockable(mStatusBarNotification.getPackageName(),
- mEntry.channel.getId());
+ mEntry.getChannel().getId());
// If the SystemNotifAsyncTask hasn't finished running or retrieved a value, we'll try once
// again, but in-place on the main thread this time. This should rarely ever get called.
@@ -532,13 +532,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
mEntry.mIsSystemNotification = isSystemNotification(mContext, mStatusBarNotification);
}
- isNonblockable |= mEntry.channel.isImportanceLockedByOEM();
- isNonblockable |= mEntry.channel.isImportanceLockedByCriticalDeviceFunction();
+ isNonblockable |= mEntry.getChannel().isImportanceLockedByOEM();
+ isNonblockable |= mEntry.getChannel().isImportanceLockedByCriticalDeviceFunction();
if (!isNonblockable && mEntry != null && mEntry.mIsSystemNotification != null) {
if (mEntry.mIsSystemNotification) {
- if (mEntry.channel != null
- && !mEntry.channel.isBlockableSystem()) {
+ if (mEntry.getChannel() != null
+ && !mEntry.getChannel().isBlockableSystem()) {
isNonblockable = true;
}
}
@@ -2389,7 +2389,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
public ArraySet<NotificationChannel> getUniqueChannels() {
ArraySet<NotificationChannel> channels = new ArraySet<>();
- channels.add(mEntry.channel);
+ channels.add(mEntry.getChannel());
// If this is a summary, then add in the children notification channels for the
// same user and pkg.
@@ -2398,7 +2398,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
final int numChildren = childrenRows.size();
for (int i = 0; i < numChildren; i++) {
final ExpandableNotificationRow childRow = childrenRows.get(i);
- final NotificationChannel childChannel = childRow.getEntry().channel;
+ final NotificationChannel childChannel = childRow.getEntry().getChannel();
final StatusBarNotification childSbn = childRow.getStatusBarNotification();
if (childSbn.getUser().equals(mStatusBarNotification.getUser()) &&
childSbn.getPackageName().equals(mStatusBarNotification.getPackageName())) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
index 8f7671a5dd96..3e8825d735da 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
@@ -316,7 +316,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
iNotificationManager,
mVisualStabilityManager,
packageName,
- row.getEntry().channel,
+ row.getEntry().getChannel(),
row.getUniqueChannels(),
sbn,
mCheckSaveListener,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
index ba434d4fd0bd..448c80ef3c57 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
@@ -71,8 +71,8 @@ import com.android.systemui.statusbar.notification.collection.NotificationData;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.phone.DozeParameters;
-import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
+import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.StatusBarWindowController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.HeadsUpManager;
@@ -165,7 +165,8 @@ public class BubbleControllerTest extends SysuiTestCase {
// Return non-null notification data from the NEM
when(mNotificationEntryManager.getNotificationData()).thenReturn(mNotificationData);
when(mNotificationData.get(mRow.getEntry().key)).thenReturn(mRow.getEntry());
- when(mNotificationData.getChannel(mRow.getEntry().key)).thenReturn(mRow.getEntry().channel);
+ when(mNotificationData.getChannel(mRow.getEntry().key)).thenReturn(
+ mRow.getEntry().getChannel());
mZenModeConfig.suppressedVisualEffects = 0;
when(mZenModeController.getConfig()).thenReturn(mZenModeConfig);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
index 264a5400f1a5..7cd58193a3e7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
@@ -306,12 +306,21 @@ public class NotificationTestHelper {
userHandle,
null /* overrideGroupKey */,
System.currentTimeMillis());
- NotificationEntry entry = NotificationEntry.buildForTest(sbn);
+ final NotificationChannel channel =
+ new NotificationChannel(
+ notification.getChannelId(),
+ notification.getChannelId(),
+ importance);
+ channel.setBlockableSystem(true);
+
+ NotificationEntry entry = new NotificationEntry(
+ sbn,
+ new RankingBuilder()
+ .setKey(sbn.getKey())
+ .setChannel(channel)
+ .build());
entry.setRow(row);
entry.createIcons(mContext, sbn);
- entry.channel = new NotificationChannel(
- notification.getChannelId(), notification.getChannelId(), importance);
- entry.channel.setBlockableSystem(true);
row.setEntry(entry);
row.getNotificationInflater().addInflationFlags(extraInflationFlags);
NotificationContentInflaterTest.runThenWaitForInflation(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java
new file mode 100644
index 000000000000..bbdc4b7fc360
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java
@@ -0,0 +1,105 @@
+/*
+ * 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;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.service.notification.NotificationListenerService.Ranking;
+import android.service.notification.SnoozeCriterion;
+
+import java.util.ArrayList;
+
+/**
+ * Standard builder class for Ranking objects. For use in tests that need to craft the underlying
+ * Ranking object of a NotificationEntry.
+ */
+public class RankingBuilder {
+ private String mKey = "test_key";
+ private int mRank = 0;
+ private boolean mMatchesInterruptionFilter = false;
+ private int mVisibilityOverride = 0;
+ private int mSuppressedVisualEffects = 0;
+ private int mImportance = 0;
+ private CharSequence mExplanation = "test_explanation";
+ private String mOverrideGroupKey = null;
+ private NotificationChannel mChannel = null;
+ private ArrayList<String> mOverridePeople = null;
+ private ArrayList<SnoozeCriterion> mSnoozeCriteria = null;
+ private boolean mShowBadge = false;
+ private int mUserSentiment = 0;
+ private boolean mHidden = false;
+ private long mLastAudiblyAlertedMs = 0;
+ private boolean mNoisy = false;
+ private ArrayList<Notification.Action> mSmartActions = null;
+ private ArrayList<CharSequence> mSmartReplies = null;
+ private boolean mCanBubble = false;
+
+ public RankingBuilder setKey(String key) {
+ mKey = key;
+ return this;
+ }
+
+ public RankingBuilder setImportance(int importance) {
+ mImportance = importance;
+ return this;
+ }
+
+ public RankingBuilder setUserSentiment(int userSentiment) {
+ mUserSentiment = userSentiment;
+ return this;
+ }
+
+ public RankingBuilder setChannel(NotificationChannel channel) {
+ mChannel = channel;
+ return this;
+ }
+
+ public RankingBuilder setSmartActions(ArrayList<Notification.Action> smartActions) {
+ mSmartActions = smartActions;
+ return this;
+ }
+
+ public RankingBuilder setSmartReplies(ArrayList<CharSequence> smartReplies) {
+ mSmartReplies = smartReplies;
+ return this;
+ }
+
+ public Ranking build() {
+ final Ranking ranking = new Ranking();
+ ranking.populate(
+ mKey,
+ mRank,
+ mMatchesInterruptionFilter,
+ mVisibilityOverride,
+ mSuppressedVisualEffects,
+ mImportance,
+ mExplanation,
+ mOverrideGroupKey,
+ mChannel,
+ mOverridePeople,
+ mSnoozeCriteria,
+ mShowBadge,
+ mUserSentiment,
+ mHidden,
+ mLastAudiblyAlertedMs,
+ mNoisy,
+ mSmartActions,
+ mSmartReplies,
+ mCanBubble);
+ return ranking;
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationDataTest.java
index ed719d99a980..45173a2ef797 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationDataTest.java
@@ -145,7 +145,7 @@ public class NotificationDataTest extends SysuiTestCase {
override.putParcelable(OVERRIDE_CHANNEL, NOTIFICATION_CHANNEL);
mNotificationData.rankingOverrides.put(mRow.getEntry().key, override);
mNotificationData.add(mRow.getEntry());
- assertEquals(NOTIFICATION_CHANNEL, mRow.getEntry().channel);
+ assertEquals(NOTIFICATION_CHANNEL, mRow.getEntry().getChannel());
}
@Test
@@ -343,7 +343,7 @@ public class NotificationDataTest extends SysuiTestCase {
new NotificationEntry(mMockStatusBarNotification, ranking);
assertEquals(systemGeneratedSmartActions, entry.systemGeneratedSmartActions);
- assertEquals(NOTIFICATION_CHANNEL, entry.channel);
+ assertEquals(NOTIFICATION_CHANNEL, entry.getChannel());
assertEquals(Ranking.USER_SENTIMENT_NEGATIVE, entry.userSentiment);
assertEquals(snoozeCriterions, entry.snoozeCriteria);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
index d526d104630e..a14557bd9684 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
@@ -51,6 +51,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationTestHelper;
+import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.notification.AboveShelfChangedListener;
import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer;
@@ -327,8 +328,11 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
// Give each child a unique channel id/name.
int i = 0;
for (ExpandableNotificationRow childRow : childRows) {
- childRow.getEntry().channel =
- new NotificationChannel("id" + i, "dinnertime" + i, IMPORTANCE_DEFAULT);
+ childRow.getEntry().setRanking(new RankingBuilder()
+ .setChannel(
+ new NotificationChannel(
+ "id" + i, "dinnertime" + i, IMPORTANCE_DEFAULT))
+ .build());
i++;
}
@@ -364,7 +368,7 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
public void testGetIsNonblockable_oemLocked() throws Exception {
ExpandableNotificationRow row =
mNotificationTestHelper.createRow(mNotificationTestHelper.createNotification());
- row.getEntry().channel.setImportanceLockedByOEM(true);
+ row.getEntry().getChannel().setImportanceLockedByOEM(true);
assertTrue(row.getIsNonblockable());
}
@@ -373,7 +377,7 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
public void testGetIsNonblockable_criticalDeviceFunction() throws Exception {
ExpandableNotificationRow row =
mNotificationTestHelper.createRow(mNotificationTestHelper.createNotification());
- row.getEntry().channel.setImportanceLockedByCriticalDeviceFunction(true);
+ row.getEntry().getChannel().setImportanceLockedByCriticalDeviceFunction(true);
assertTrue(row.getIsNonblockable());
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java
index 3d77d7fd5647..a26cdbd30b47 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManagerTest.java
@@ -44,6 +44,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.NotificationTestHelper;
+import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.util.Assert;
@@ -84,6 +85,7 @@ public class NotificationBlockingHelperManagerTest extends SysuiTestCase {
when(mMenuRow.getLongpressMenuItem(any(Context.class))).thenReturn(mMenuItem);
mDependency.injectTestDependency(NotificationGutsManager.class, mGutsManager);
mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
+ mDependency.injectMockDependency(BubbleController.class);
mHelper = new NotificationTestHelper(mContext);
@@ -140,8 +142,11 @@ public class NotificationBlockingHelperManagerTest extends SysuiTestCase {
ExpandableNotificationRow groupRow = createBlockableGroupRowSpy(10);
int i = 0;
for (ExpandableNotificationRow childRow : groupRow.getNotificationChildren()) {
- childRow.getEntry().channel =
- new NotificationChannel(Integer.toString(i++), "", IMPORTANCE_DEFAULT);
+ childRow.getEntry().setRanking(new RankingBuilder()
+ .setChannel(
+ new NotificationChannel(
+ Integer.toString(i++), "", IMPORTANCE_DEFAULT))
+ .build());
}
groupRow.getEntry().userSentiment = USER_SENTIMENT_NEGATIVE;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
index 795948470295..09c4179185fc 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
@@ -62,6 +62,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.NotificationTestHelper;
+import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -498,7 +499,10 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
try {
ExpandableNotificationRow row = mHelper.createRow(nb.build());
- row.getEntry().channel = mTestNotificationChannel;
+ row.getEntry().setRanking(
+ new RankingBuilder()
+ .setChannel(mTestNotificationChannel)
+ .build());
return row;
} catch (Exception e) {
fail();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
index 98e1692c2368..096acf9d9ce4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
@@ -40,6 +40,7 @@ import android.view.ViewGroup;
import androidx.test.filters.SmallTest;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
+import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.utils.leaks.LeakCheckedTest;
@@ -60,9 +61,11 @@ public class NotificationMenuRowTest extends LeakCheckedTest {
public void setup() {
injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES);
mRow = mock(ExpandableNotificationRow.class);
- NotificationEntry entry = NotificationEntry.buildForTest(
- mock(StatusBarNotification.class));
- entry.channel = mock(NotificationChannel.class);
+ NotificationEntry entry = new NotificationEntry(
+ mock(StatusBarNotification.class),
+ new RankingBuilder()
+ .setChannel(mock(NotificationChannel.class))
+ .build());
when(mRow.getEntry()).thenReturn(entry);
}