Note, this will only get called once the view is dismissing. This means that the
- * user does not have the ability to undo the action anymore. See
- * {@link #swapContent(boolean, boolean)} for where undo is handled.
+ * user does not have the ability to undo the action anymore.
*/
@VisibleForTesting
void closeControls(View v, boolean save) {
@@ -811,7 +577,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
if (save) {
saveImportance();
}
- logBlockingHelperCounter(mExitReason);
return false;
}
@@ -822,7 +587,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
@VisibleForTesting
public boolean isAnimating() {
- return mExpandAnimation != null && mExpandAnimation.isRunning();
+ return false;
}
/**
@@ -901,8 +666,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
private LogMaker notificationControlsLogMaker() {
return getLogMaker().setCategory(MetricsEvent.ACTION_NOTE_CONTROLS)
.setType(MetricsEvent.TYPE_OPEN)
- .setSubtype(mIsForBlockingHelper ? MetricsEvent.BLOCKING_HELPER_DISPLAY
- : MetricsEvent.BLOCKING_HELPER_UNKNOWN);
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_UNKNOWN);
}
@Retention(SOURCE)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationUndoLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationUndoLayout.java
deleted file mode 100644
index 3ea8195ff9171..0000000000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationUndoLayout.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2018 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.notification.row;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import com.android.systemui.R;
-
-/**
- * Custom view for the NotificationInfo confirmation views so that the confirmation text can
- * occupy the full width of the notification and push the undo button down to the next line if
- * necessary.
- *
- * @see NotificationInfo
- */
-public class NotificationUndoLayout extends FrameLayout {
- /**
- * View for the prompt/confirmation text to tell the user the previous action was successful.
- */
- private View mConfirmationTextView;
- /** Undo button (actionable text) view. */
- private View mUndoView;
-
- /**
- * Whether {@link #mConfirmationTextView} is multiline and will require the full width of the
- * parent (which causes the {@link #mUndoView} to push down).
- */
- private boolean mIsMultiline = false;
- private int mMultilineTopMargin;
-
- public NotificationUndoLayout(Context context) {
- this(context, null);
- }
-
- public NotificationUndoLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public NotificationUndoLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- mConfirmationTextView = findViewById(R.id.confirmation_text);
- mUndoView = findViewById(R.id.undo);
-
- mMultilineTopMargin = getResources().getDimensionPixelOffset(
- com.android.internal.R.dimen.notification_content_margin_start);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- LayoutParams confirmationLayoutParams =
- (LayoutParams) mConfirmationTextView.getLayoutParams();
- LayoutParams undoLayoutParams =(LayoutParams) mUndoView.getLayoutParams();
-
- int measuredWidth = getMeasuredWidth();
- // Ignore the left margin on the undo button - no need for additional extra space between
- // the text and the button.
- int requiredWidth = mConfirmationTextView.getMeasuredWidth()
- + confirmationLayoutParams.rightMargin
- + confirmationLayoutParams.leftMargin
- + mUndoView.getMeasuredWidth()
- + undoLayoutParams.rightMargin;
- // If the measured width isn't enough to accommodate both the undo button and the text in
- // the same line, we'll need to adjust the view to be multi-line. Otherwise, we're done.
- if (requiredWidth > measuredWidth) {
- mIsMultiline = true;
-
- // Update height requirement to the text height and the button's height (along with
- // additional spacing for the top of the text).
- int updatedHeight = mMultilineTopMargin
- + mConfirmationTextView.getMeasuredHeight()
- + mUndoView.getMeasuredHeight()
- + undoLayoutParams.topMargin
- + undoLayoutParams.bottomMargin;
-
- setMeasuredDimension(measuredWidth, updatedHeight);
- } else {
- mIsMultiline = false;
- }
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- // If the text view and undo view don't fit on the same line, we'll need to manually lay
- // out the content.
- if (mIsMultiline) {
- // Re-align parent right/bottom values. Left and top are considered to be 0.
- int parentBottom = getMeasuredHeight();
- int parentRight = getMeasuredWidth();
-
- LayoutParams confirmationLayoutParams =
- (LayoutParams) mConfirmationTextView.getLayoutParams();
- LayoutParams undoLayoutParams = (LayoutParams) mUndoView.getLayoutParams();
-
- // The confirmation text occupies the full width as computed earlier. Both side margins
- // are equivalent, so we only need to grab the left one here.
- mConfirmationTextView.layout(
- confirmationLayoutParams.leftMargin,
- mMultilineTopMargin,
- confirmationLayoutParams.leftMargin + mConfirmationTextView.getMeasuredWidth(),
- mMultilineTopMargin + mConfirmationTextView.getMeasuredHeight());
-
- // The undo button is aligned bottom|end with the parent in the case of multiline text.
- int undoViewLeft = getLayoutDirection() == View.LAYOUT_DIRECTION_RTL
- ? undoLayoutParams.rightMargin
- : parentRight - mUndoView.getMeasuredWidth() - undoLayoutParams.rightMargin;
- mUndoView.layout(
- undoViewLeft,
- parentBottom - mUndoView.getMeasuredHeight() - undoLayoutParams.bottomMargin,
- undoViewLeft + mUndoView.getMeasuredWidth(),
- parentBottom - undoLayoutParams.bottomMargin);
- } else {
- super.onLayout(changed, left, top, right, bottom);
- }
- }
-}
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 54c0bde134087..e9dca699917c9 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
@@ -315,75 +315,10 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
assertEquals(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, captor.getValue().getAction());
}
- @Test
- public void testInitializeNotificationInfoView_showBlockingHelper() throws Exception {
- NotificationInfo notificationInfoView = mock(NotificationInfo.class);
- ExpandableNotificationRow row = spy(mHelper.createRow());
- row.setBlockingHelperShowing(true);
- modifyRanking(row.getEntry())
- .setUserSentiment(USER_SENTIMENT_NEGATIVE)
- .build();
- when(row.getIsNonblockable()).thenReturn(false);
- StatusBarNotification statusBarNotification = row.getEntry().getSbn();
- NotificationEntry entry = row.getEntry();
-
- mGutsManager.initializeNotificationInfo(row, notificationInfoView);
-
- verify(notificationInfoView).bindNotification(
- any(PackageManager.class),
- any(INotificationManager.class),
- eq(mVisualStabilityManager),
- eq(statusBarNotification.getPackageName()),
- any(NotificationChannel.class),
- anySet(),
- eq(entry),
- any(NotificationInfo.CheckSaveListener.class),
- any(NotificationInfo.OnSettingsClickListener.class),
- any(NotificationInfo.OnAppSettingsClickListener.class),
- eq(false),
- eq(false),
- eq(true) /* isForBlockingHelper */,
- eq(0),
- eq(false) /* wasShownHighPriority */);
- }
-
- @Test
- public void testInitializeNotificationInfoView_dontShowBlockingHelper() throws Exception {
- NotificationInfo notificationInfoView = mock(NotificationInfo.class);
- ExpandableNotificationRow row = spy(mHelper.createRow());
- row.setBlockingHelperShowing(false);
- modifyRanking(row.getEntry())
- .setUserSentiment(USER_SENTIMENT_NEGATIVE)
- .build();
- when(row.getIsNonblockable()).thenReturn(false);
- StatusBarNotification statusBarNotification = row.getEntry().getSbn();
- NotificationEntry entry = row.getEntry();
-
- mGutsManager.initializeNotificationInfo(row, notificationInfoView);
-
- verify(notificationInfoView).bindNotification(
- any(PackageManager.class),
- any(INotificationManager.class),
- eq(mVisualStabilityManager),
- eq(statusBarNotification.getPackageName()),
- any(NotificationChannel.class),
- anySet(),
- eq(entry),
- any(NotificationInfo.CheckSaveListener.class),
- any(NotificationInfo.OnSettingsClickListener.class),
- any(NotificationInfo.OnAppSettingsClickListener.class),
- eq(false),
- eq(false),
- eq(false) /* isForBlockingHelper */,
- eq(0),
- eq(false) /* wasShownHighPriority */);
- }
-
@Test
public void testInitializeNotificationInfoView_highPriority() throws Exception {
NotificationInfo notificationInfoView = mock(NotificationInfo.class);
ExpandableNotificationRow row = spy(mHelper.createRow());
- row.setBlockingHelperShowing(true);
final NotificationEntry entry = row.getEntry();
modifyRanking(entry)
.setUserSentiment(USER_SENTIMENT_NEGATIVE)
@@ -403,13 +338,10 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
any(NotificationChannel.class),
anySet(),
eq(entry),
- any(NotificationInfo.CheckSaveListener.class),
any(NotificationInfo.OnSettingsClickListener.class),
any(NotificationInfo.OnAppSettingsClickListener.class),
eq(false),
eq(false),
- eq(true) /* isForBlockingHelper */,
- eq(IMPORTANCE_HIGH),
eq(true) /* wasShownHighPriority */);
}
@@ -437,13 +369,10 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
any(NotificationChannel.class),
anySet(),
eq(entry),
- any(NotificationInfo.CheckSaveListener.class),
any(NotificationInfo.OnSettingsClickListener.class),
any(NotificationInfo.OnAppSettingsClickListener.class),
eq(true),
eq(false),
- eq(false) /* isForBlockingHelper */,
- eq(0),
eq(false) /* wasShownHighPriority */);
}
@@ -469,13 +398,10 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
any(NotificationChannel.class),
anySet(),
eq(entry),
- any(NotificationInfo.CheckSaveListener.class),
any(NotificationInfo.OnSettingsClickListener.class),
any(NotificationInfo.OnAppSettingsClickListener.class),
eq(false),
eq(false),
- eq(true) /* isForBlockingHelper */,
- eq(0),
eq(false) /* wasShownHighPriority */);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java
index c62487a830fca..98ef691ee28c9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java
@@ -119,15 +119,10 @@ public class NotificationInfoTest extends SysuiTestCase {
@Mock
private PackageManager mMockPackageManager;
@Mock
- private NotificationBlockingHelperManager mBlockingHelperManager;
- @Mock
private VisualStabilityManager mVisualStabilityManager;
@Before
public void setUp() throws Exception {
- mDependency.injectTestDependency(
- NotificationBlockingHelperManager.class,
- mBlockingHelperManager);
mTestableLooper = TestableLooper.get(this);
mDependency.injectTestDependency(Dependency.BG_LOOPER, mTestableLooper.getLooper());
@@ -183,13 +178,6 @@ public class NotificationInfoTest extends SysuiTestCase {
NOTIFICATION_NEW_INTERRUPTION_MODEL, 0);
}
- // TODO: if tests are taking too long replace this with something that makes the animation
- // finish instantly.
- private void waitForUndoButton() {
- PollingCheck.waitFor(1000,
- () -> VISIBLE == mNotificationInfo.findViewById(R.id.confirmation).getVisibility());
- }
-
@Test
public void testBindNotification_SetsTextApplicationName() throws Exception {
when(mMockPackageManager.getApplicationLabel(any())).thenReturn("App Name");
@@ -203,12 +191,10 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
- final TextView textView = mNotificationInfo.findViewById(R.id.pkgname);
+ final TextView textView = mNotificationInfo.findViewById(R.id.pkg_name);
assertTrue(textView.getText().toString().contains("App Name"));
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility());
}
@@ -228,12 +214,10 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
- final ImageView iconView = mNotificationInfo.findViewById(R.id.pkgicon);
+ final ImageView iconView = mNotificationInfo.findViewById(R.id.pkg_icon);
assertEquals(iconDrawable, iconView.getDrawable());
}
@@ -249,14 +233,12 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name);
assertEquals(GONE, nameView.getVisibility());
- final TextView dividerView = mNotificationInfo.findViewById(R.id.pkg_divider);
+ final TextView dividerView = mNotificationInfo.findViewById(R.id.group_divider);
assertEquals(GONE, dividerView.getVisibility());
}
@@ -281,16 +263,12 @@ public class NotificationInfoTest extends SysuiTestCase {
entry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name);
assertEquals(VISIBLE, nameView.getVisibility());
assertTrue(nameView.getText().toString().contains("Proxied"));
- final TextView dividerView = mNotificationInfo.findViewById(R.id.pkg_divider);
- assertEquals(VISIBLE, dividerView.getVisibility());
}
@Test
@@ -305,13 +283,13 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name);
assertEquals(GONE, groupNameView.getVisibility());
+ final TextView dividerView = mNotificationInfo.findViewById(R.id.group_divider);
+ assertEquals(GONE, dividerView.getVisibility());
}
@Test
@@ -332,14 +310,14 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name);
assertEquals(View.VISIBLE, groupNameView.getVisibility());
assertEquals("Test Group Name", groupNameView.getText());
+ final TextView dividerView = mNotificationInfo.findViewById(R.id.group_divider);
+ assertEquals(View.VISIBLE, dividerView.getVisibility());
}
@Test
@@ -354,10 +332,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(TEST_CHANNEL_NAME, textView.getText());
@@ -375,10 +351,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(GONE, textView.getVisibility());
@@ -387,7 +361,7 @@ public class NotificationInfoTest extends SysuiTestCase {
@Test
public void testBindNotification_DefaultChannelUsesChannelNameIfMoreChannelsExist()
throws Exception {
- // Package has one channel by default.
+ // Package has more than one channel by default.
when(mMockINotificationManager.getNumNotificationChannelsForPackage(
eq(TEST_PACKAGE_NAME), eq(TEST_UID), anyBoolean())).thenReturn(10);
mNotificationInfo.bindNotification(
@@ -400,10 +374,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(VISIBLE, textView.getVisibility());
@@ -421,41 +393,13 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
true,
- IMPORTANCE_DEFAULT,
true);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(VISIBLE, textView.getVisibility());
}
- @Test
- public void testBindNotification_BlockLink_BlockingHelper() throws Exception {
- mNotificationInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mVisualStabilityManager,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet,
- mEntry,
- null,
- mock(NotificationInfo.OnSettingsClickListener.class),
- null,
- true,
- false,
- true /* isBlockingHelper */,
- IMPORTANCE_DEFAULT,
- true);
- final View block =
- mNotificationInfo.findViewById(R.id.blocking_helper_turn_off_notifications);
- final View interruptivenessSettings = mNotificationInfo.findViewById(
- R.id.inline_controls);
- assertEquals(VISIBLE, block.getVisibility());
- assertEquals(GONE, interruptivenessSettings.getVisibility());
- }
-
@Test
public void testBindNotification_SetsOnClickListenerForSettings() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
@@ -467,7 +411,6 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel,
mNotificationChannelSet,
mEntry,
- null,
(View v, NotificationChannel c, int appUid) -> {
assertEquals(mNotificationChannel, c);
latch.countDown();
@@ -475,7 +418,6 @@ public class NotificationInfoTest extends SysuiTestCase {
null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
@@ -496,10 +438,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
assertTrue(settingsButton.getVisibility() != View.VISIBLE);
@@ -516,14 +456,12 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel,
mNotificationChannelSet,
mEntry,
- null,
(View v, NotificationChannel c, int appUid) -> {
assertEquals(mNotificationChannel, c);
},
null,
false,
false,
- IMPORTANCE_DEFAULT,
true);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
assertTrue(settingsButton.getVisibility() != View.VISIBLE);
@@ -541,10 +479,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
mNotificationInfo.bindNotification(
mMockPackageManager,
@@ -554,88 +490,15 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel,
mNotificationChannelSet,
mEntry,
- null,
(View v, NotificationChannel c, int appUid) -> { },
null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
assertEquals(View.VISIBLE, settingsButton.getVisibility());
}
- @Test
- public void testBindNotificationLogging_notBlockingHelper() throws Exception {
- mNotificationInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mVisualStabilityManager,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet,
- mEntry,
- null,
- null,
- null,
- true,
- false,
- IMPORTANCE_DEFAULT,
- true);
- verify(mMetricsLogger).write(argThat(logMaker ->
- logMaker.getCategory() == MetricsEvent.ACTION_NOTE_CONTROLS
- && logMaker.getType() == MetricsEvent.TYPE_OPEN
- && logMaker.getSubtype() == MetricsEvent.BLOCKING_HELPER_UNKNOWN
- ));
- }
-
- @Test
- public void testBindNotificationLogging_BlockingHelper() throws Exception {
- mNotificationInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mVisualStabilityManager,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet,
- mEntry,
- null,
- null,
- null,
- false,
- true,
- true,
- IMPORTANCE_DEFAULT,
- true);
- verify(mMetricsLogger).write(argThat(logMaker ->
- logMaker.getCategory() == MetricsEvent.ACTION_NOTE_CONTROLS
- && logMaker.getType() == MetricsEvent.TYPE_OPEN
- && logMaker.getSubtype() == MetricsEvent.BLOCKING_HELPER_DISPLAY
- ));
- }
-
- @Test
- public void testLogBlockingHelperCounter_logsForBlockingHelper() throws Exception {
- mNotificationInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mVisualStabilityManager,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet,
- mEntry,
- null,
- null,
- null,
- false,
- true,
- true,
- IMPORTANCE_DEFAULT,
- true);
- mNotificationInfo.logBlockingHelperCounter("HowCanNotifsBeRealIfAppsArent");
- verify(mMetricsLogger).count(eq("HowCanNotifsBeRealIfAppsArent"), eq(1));
- }
-
@Test
public void testOnClickListenerPassesNullChannelForBundle() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
@@ -646,7 +509,6 @@ public class NotificationInfoTest extends SysuiTestCase {
TEST_PACKAGE_NAME, mNotificationChannel,
createMultipleChannelSet(MULTIPLE_CHANNEL_COUNT),
mEntry,
- null,
(View v, NotificationChannel c, int appUid) -> {
assertEquals(null, c);
latch.countDown();
@@ -654,7 +516,6 @@ public class NotificationInfoTest extends SysuiTestCase {
null,
true,
true,
- IMPORTANCE_DEFAULT,
true);
mNotificationInfo.findViewById(R.id.info).performClick();
@@ -676,10 +537,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
final TextView channelNameView =
mNotificationInfo.findViewById(R.id.channel_name);
@@ -699,10 +558,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
assertEquals(GONE, mNotificationInfo.findViewById(
R.id.interruptiveness_settings).getVisibility());
@@ -722,10 +579,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
true,
- IMPORTANCE_DEFAULT,
true);
final TextView view = mNotificationInfo.findViewById(R.id.non_configurable_text);
assertEquals(View.VISIBLE, view.getVisibility());
@@ -747,10 +602,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
assertTrue(mNotificationInfo.findViewById(R.id.alert).isSelected());
}
@@ -767,10 +620,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
false);
assertTrue(mNotificationInfo.findViewById(R.id.silence).isSelected());
}
@@ -787,10 +638,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
mTestableLooper.processAllMessages();
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
@@ -810,10 +659,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_LOW,
false);
mNotificationInfo.findViewById(R.id.alert).performClick();
@@ -836,10 +683,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
mNotificationInfo.findViewById(R.id.silence).performClick();
@@ -862,10 +707,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_DEFAULT,
true);
mNotificationInfo.handleCloseControls(true, false);
@@ -889,10 +732,8 @@ public class NotificationInfoTest extends SysuiTestCase {
mEntry,
null,
null,
- null,
true,
false,
- IMPORTANCE_UNSPECIFIED,
true);
mNotificationInfo.handleCloseControls(true, false);
@@ -903,225 +744,6 @@ public class NotificationInfoTest extends SysuiTestCase {
assertEquals(IMPORTANCE_UNSPECIFIED, mNotificationChannel.getImportance());
}
- @Test
- public void testCloseControls_nonNullCheckSaveListenerDoesntDelayKeepShowing_BlockingHelper()
- throws Exception {
- NotificationInfo.CheckSaveListener listener =
- mock(NotificationInfo.CheckSaveListener.class);
- mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
- mNotificationInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mVisualStabilityManager,
- TEST_PACKAGE_NAME,
- mNotificationChannel /* notificationChannel */,
- createMultipleChannelSet(10) /* numUniqueChannelsInRow */,
- mEntry,
- listener /* checkSaveListener */,
- null /* onSettingsClick */,
- null /* onAppSettingsClick */,
- true /* provisioned */,
- false /* isNonblockable */,
- true /* isForBlockingHelper */,
- IMPORTANCE_DEFAULT,
- true);
-
- NotificationGuts guts = spy(new NotificationGuts(mContext, null));
- when(guts.getWindowToken()).thenReturn(mock(IBinder.class));
- doNothing().when(guts).animateClose(anyInt(), anyInt(), anyBoolean());
- doNothing().when(guts).setExposed(anyBoolean(), anyBoolean());
- guts.setGutsContent(mNotificationInfo);
- mNotificationInfo.setGutsParent(guts);
-
- mNotificationInfo.findViewById(R.id.keep_showing).performClick();
-
- verify(mBlockingHelperManager).dismissCurrentBlockingHelper();
- mTestableLooper.processAllMessages();
- verify(mMockINotificationManager, times(1))
- .setNotificationsEnabledWithImportanceLockForPackage(
- anyString(), eq(TEST_UID), eq(true));
- }
-
- @Test
- public void testCloseControls_nonNullCheckSaveListenerDoesntDelayDismiss_BlockingHelper()
- throws Exception {
- NotificationInfo.CheckSaveListener listener =
- mock(NotificationInfo.CheckSaveListener.class);
- mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
- mNotificationInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mVisualStabilityManager,
- TEST_PACKAGE_NAME,
- mNotificationChannel /* notificationChannel */,
- createMultipleChannelSet(10) /* numUniqueChannelsInRow */,
- mEntry,
- listener /* checkSaveListener */,
- null /* onSettingsClick */,
- null /* onAppSettingsClick */,
- false /* isNonblockable */,
- true /* isForBlockingHelper */,
- true, IMPORTANCE_DEFAULT,
- true);
-
- mNotificationInfo.handleCloseControls(true /* save */, false /* force */);
-
- mTestableLooper.processAllMessages();
- verify(listener, times(0)).checkSave(any(Runnable.class), eq(mSbn));
- }
-
- @Test
- public void testCloseControls_checkSaveListenerDelaysStopNotifications_BlockingHelper()
- throws Exception {
- NotificationInfo.CheckSaveListener listener =
- mock(NotificationInfo.CheckSaveListener.class);
- mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
- mNotificationInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mVisualStabilityManager,
- TEST_PACKAGE_NAME,
- mNotificationChannel /* notificationChannel */,
- createMultipleChannelSet(10) /* numUniqueChannelsInRow */,
- mEntry,
- listener /* checkSaveListener */,
- null /* onSettingsClick */,
- null /* onAppSettingsClick */,
- true /* provisioned */,
- false /* isNonblockable */,
- true /* isForBlockingHelper */,
- IMPORTANCE_DEFAULT,
- true);
-
- mNotificationInfo.findViewById(R.id.deliver_silently).performClick();
- mTestableLooper.processAllMessages();
- verify(listener).checkSave(any(Runnable.class), eq(mSbn));
- }
-
- @Test
- public void testCloseControls_blockingHelperDismissedIfShown() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
- mNotificationInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mVisualStabilityManager,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet /* numChannels */,
- mEntry,
- null /* checkSaveListener */,
- null /* onSettingsClick */,
- null /* onAppSettingsClick */,
- false /* isNonblockable */,
- true /* isForBlockingHelper */,
- true,
- IMPORTANCE_DEFAULT,
- true);
- NotificationGuts guts = mock(NotificationGuts.class);
- doCallRealMethod().when(guts).closeControls(anyInt(), anyInt(), anyBoolean(), anyBoolean());
- mNotificationInfo.setGutsParent(guts);
-
- mNotificationInfo.closeControls(mNotificationInfo, true);
-
- verify(mBlockingHelperManager).dismissCurrentBlockingHelper();
- }
-
- @Test
- public void testSilentlyChangedCallsUpdateNotificationChannel_blockingHelper()
- throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
- mNotificationInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mVisualStabilityManager,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet /* numChannels */,
- mEntry,
- null /* checkSaveListener */,
- null /* onSettingsClick */,
- null /* onAppSettingsClick */,
- true /*provisioned */,
- false /* isNonblockable */,
- true /* isForBlockingHelper */,
- IMPORTANCE_DEFAULT,
- true);
-
- mNotificationInfo.findViewById(R.id.deliver_silently).performClick();
- waitForUndoButton();
- mNotificationInfo.handleCloseControls(true, false);
-
- mTestableLooper.processAllMessages();
- ArgumentCaptor