Updates NotificationInfo layout/buttons.

This change modifies the UI displayed when the new interruption model is
enabled after long pressing a notification or tapping the settings icon
in the notification side menu.  The text links for blocking the channel,
toggling its importance, or canceling out of the dialog are replaced
with buttons with icons and clearer text descriptions.

Test: atest NotificationInfoTest
Bug: 116622974
Change-Id: I06ead5c4da77319df3ebe4c48d863dede37bf2f4
This commit is contained in:
Gus Prevas
2018-11-28 14:27:40 -05:00
parent 188e91405a
commit 82ad059b13
8 changed files with 273 additions and 332 deletions

View File

@@ -20,6 +20,6 @@ Copyright (C) 2016 The Android Open Source Project
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:fillColor="#FF000000"
android:pathData="M12.0,2.0C6.48,2.0 2.0,6.48 2.0,12.0s4.48,10.0 10.0,10.0 10.0,-4.48 10.0,-10.0S17.52,2.0 12.0,2.0zM4.0,12.0c0.0,-4.42 3.58,-8.0 8.0,-8.0 1.85,0.0 3.5,0.63 4.9,1.69L5.69,16.9C4.63,15.55 4.0,13.85 4.0,12.0zm8.0,8.0c-1.85,0.0 -3.55,-0.63 -4.9,-1.69L18.31,7.1C19.37,8.45 20.0,10.15 20.0,12.0c0.0,4.42 -3.58,8.0 -8.0,8.0z"/>
</vector>

View File

@@ -144,6 +144,7 @@
<!-- Settings and Done buttons -->
<LinearLayout
android:id="@+id/block_or_minimize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/notification_guts_button_spacing"
@@ -177,13 +178,6 @@
android:layout_height="match_parent"
android:layout_marginStart="@dimen/notification_guts_button_horizontal_spacing"
style="@style/TextAppearance.NotificationInfo.Button" />
<TextView
android:id="@+id/toggle_silent"
android:text="@string/inline_silent_button_silent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/notification_guts_button_horizontal_spacing"
style="@style/TextAppearance.NotificationInfo.Button" />
<TextView
android:id="@+id/keep"
android:minWidth="48dp"
@@ -193,6 +187,44 @@
android:layout_marginStart="@dimen/notification_guts_button_horizontal_spacing"
style="@style/TextAppearance.NotificationInfo.Button"/>
</LinearLayout>
<LinearLayout
android:id="@+id/interruptiveness_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/notification_guts_button_spacing"
android:layout_marginStart="@dimen/notification_guts_button_side_margin"
android:layout_marginEnd="@dimen/notification_guts_button_side_margin"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="@+id/int_block"
android:text="@string/inline_block_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:drawableTop="@drawable/ic_notification_block"
android:drawableTint="?android:attr/colorAccent"
android:layout_weight="1"
style="@style/TextAppearance.NotificationInfo.Button"/>
<TextView
android:id="@+id/int_silent"
android:text="@string/inline_minimize_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:drawableTop="@drawable/ic_notifications_silence"
android:drawableTint="?android:attr/colorAccent"
android:layout_weight="1"
style="@style/TextAppearance.NotificationInfo.Button"/>
<TextView
android:id="@+id/int_alert"
android:text="@string/inline_keep_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:drawableTop="@drawable/ic_notifications_alert"
android:drawableTint="?android:attr/colorAccent"
android:layout_weight="1"
style="@style/TextAppearance.NotificationInfo.Button"/>
</LinearLayout>
</LinearLayout>
<com.android.systemui.statusbar.notification.row.NotificationUndoLayout
android:id="@+id/confirmation"

View File

@@ -1556,17 +1556,26 @@
<!-- Notification inline controls: block notifications button -->
<string name="inline_stop_button">Stop notifications</string>
<!-- Notification inline controls: button to block notifications from this channel [CHAR_LIMIT=35] -->
<string name="inline_block_button">Block</string>
<!-- Notification inline controls: keep getting notifications button -->
<string name="inline_keep_button">Keep showing</string>
<!-- Notification inline controls: minimize notifications button -->
<string name="inline_minimize_button">Minimize</string>
<!-- Notification inline controls: show notifications silently button [CHAR_LIMIT=25] -->
<!-- Notification inline controls: button to show notifications silently, without alerting the user [CHAR_LIMIT=35] -->
<string name="inline_silent_button_silent">Show silently</string>
<!-- Notification inline controls: show and alert button [CHAR_LIMIT=25] -->
<string name="inline_silent_button_alert">Show and alert</string>
<!-- Notification inline controls: button to continue showing notifications silently [CHAR_LIMIT=35] -->
<string name="inline_silent_button_stay_silent">Stay silent</string>
<!-- Notification inline controls: button to make notifications alert the user [CHAR_LIMIT=35] -->
<string name="inline_silent_button_alert">Alert me</string>
<!-- Notification inline controls: button to continue alerting the user when notifications arrive [CHAR_LIMIT=35] -->
<string name="inline_silent_button_keep_alerting">Keep alerting</string>
<!-- Notification Inline controls: continue receiving notifications prompt, app level -->
<string name="inline_keep_showing_app">Keep showing notifications from this app?</string>

View File

@@ -66,7 +66,6 @@ import com.android.systemui.statusbar.StatusBarIconView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationGuts;
import com.android.systemui.statusbar.notification.row.NotificationInflater.InflationFlag;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -174,7 +173,6 @@ public class NotificationData {
public void populateFromRanking(@NonNull Ranking ranking) {
channel = ranking.getChannel();
audiblyAlerted = ranking.audiblyAlerted();
noisy = ranking.isNoisy();
importance = ranking.getImportance();
snoozeCriteria = ranking.getSnoozeCriteria();
userSentiment = ranking.getUserSentiment();

View File

@@ -290,7 +290,6 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
row.getIsNonblockable(),
isForBlockingHelper,
row.getEntry().userSentiment == USER_SENTIMENT_NEGATIVE,
row.getEntry().noisy,
row.getEntry().importance);
}

View File

@@ -104,7 +104,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
private AnimatorSet mExpandAnimation;
private boolean mIsForeground;
private boolean mIsDeviceProvisioned;
private boolean mIsNoisy;
private CheckSaveListener mCheckSaveListener;
private OnSettingsClickListener mOnSettingsClickListener;
@@ -186,13 +185,12 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
final OnAppSettingsClickListener onAppSettingsClick,
boolean isDeviceProvisioned,
boolean isNonblockable,
boolean isNoisy,
int importance)
throws RemoteException {
bindNotification(pm, iNotificationManager, pkg, notificationChannel,
numUniqueChannelsInRow, sbn, checkSaveListener, onSettingsClick,
onAppSettingsClick, isDeviceProvisioned, isNonblockable,
false /* isBlockingHelper */, false /* isUserSentimentNegative */, isNoisy,
false /* isBlockingHelper */, false /* isUserSentimentNegative */,
importance);
}
@@ -210,7 +208,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
boolean isNonblockable,
boolean isForBlockingHelper,
boolean isUserSentimentNegative,
boolean isNoisy,
int importance)
throws RemoteException {
mINotificationManager = iNotificationManager;
@@ -236,7 +233,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
mAppUid = mSbn.getUid();
mDelegatePkg = mSbn.getOpPkg();
mIsDeviceProvisioned = isDeviceProvisioned;
mIsNoisy = isNoisy;
int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage(
pkg, mAppUid, false /* includeDeleted */);
@@ -411,54 +407,74 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
}
private void bindButtons() {
// Set up stay-in-notification actions
View block = findViewById(R.id.block);
TextView keep = findViewById(R.id.keep);
TextView silent = findViewById(R.id.toggle_silent);
View minimize = findViewById(R.id.minimize);
findViewById(R.id.undo).setOnClickListener(mOnUndo);
block.setOnClickListener(mOnStopOrMinimizeNotifications);
keep.setOnClickListener(mOnKeepShowing);
silent.setOnClickListener(mOnToggleSilent);
minimize.setOnClickListener(mOnStopOrMinimizeNotifications);
if (mIsNonblockable) {
keep.setText(android.R.string.ok);
block.setVisibility(GONE);
silent.setVisibility(GONE);
minimize.setVisibility(GONE);
} else if (mIsForeground) {
block.setVisibility(GONE);
silent.setVisibility(GONE);
minimize.setVisibility(VISIBLE);
} else {
block.setVisibility(VISIBLE);
boolean showToggleSilent = mIsNoisy
&& NotificationUtils.useNewInterruptionModel(mContext);
silent.setVisibility(showToggleSilent ? VISIBLE : GONE);
boolean showInterruptivenessSettings =
!mIsNonblockable
&& !mIsForeground
&& !mIsForBlockingHelper
&& NotificationUtils.useNewInterruptionModel(mContext);
if (showInterruptivenessSettings) {
findViewById(R.id.block_or_minimize).setVisibility(GONE);
findViewById(R.id.interruptiveness_settings).setVisibility(VISIBLE);
View block = findViewById(R.id.int_block);
TextView silent = findViewById(R.id.int_silent);
TextView alert = findViewById(R.id.int_alert);
boolean isCurrentlyAlerting =
mStartingChannelOrNotificationImportance >= IMPORTANCE_DEFAULT;
silent.setText(isCurrentlyAlerting
? R.string.inline_silent_button_silent
: R.string.inline_silent_button_alert);
minimize.setVisibility(GONE);
}
// Set up app settings link (i.e. Customize)
TextView settingsLinkView = findViewById(R.id.app_settings);
Intent settingsIntent = getAppSettingsIntent(mPm, mPackageName, mSingleNotificationChannel,
mSbn.getId(), mSbn.getTag());
if (!mIsForBlockingHelper
&& settingsIntent != null
&& !TextUtils.isEmpty(mSbn.getNotification().getSettingsText())) {
settingsLinkView.setVisibility(VISIBLE);
settingsLinkView.setText(mContext.getString(R.string.notification_app_settings));
settingsLinkView.setOnClickListener((View view) -> {
mAppSettingsClickListener.onClick(view, settingsIntent);
});
block.setOnClickListener(mOnStopOrMinimizeNotifications);
if (isCurrentlyAlerting) {
silent.setOnClickListener(mOnToggleSilent);
silent.setText(R.string.inline_silent_button_silent);
alert.setOnClickListener(mOnKeepShowing);
alert.setText(R.string.inline_silent_button_keep_alerting);
} else {
silent.setOnClickListener(mOnKeepShowing);
silent.setText(R.string.inline_silent_button_stay_silent);
alert.setOnClickListener(mOnToggleSilent);
alert.setText(R.string.inline_silent_button_alert);
}
} else {
settingsLinkView.setVisibility(View.GONE);
findViewById(R.id.block_or_minimize).setVisibility(VISIBLE);
findViewById(R.id.interruptiveness_settings).setVisibility(GONE);
View block = findViewById(R.id.block);
TextView keep = findViewById(R.id.keep);
View minimize = findViewById(R.id.minimize);
block.setOnClickListener(mOnStopOrMinimizeNotifications);
keep.setOnClickListener(mOnKeepShowing);
minimize.setOnClickListener(mOnStopOrMinimizeNotifications);
if (mIsNonblockable) {
keep.setText(android.R.string.ok);
block.setVisibility(GONE);
minimize.setVisibility(GONE);
} else if (mIsForeground) {
block.setVisibility(GONE);
minimize.setVisibility(VISIBLE);
} else {
block.setVisibility(VISIBLE);
minimize.setVisibility(GONE);
}
// Set up app settings link (i.e. Customize)
TextView settingsLinkView = findViewById(R.id.app_settings);
Intent settingsIntent = getAppSettingsIntent(mPm, mPackageName,
mSingleNotificationChannel,
mSbn.getId(), mSbn.getTag());
if (!mIsForBlockingHelper
&& settingsIntent != null
&& !TextUtils.isEmpty(mSbn.getNotification().getSettingsText())) {
settingsLinkView.setVisibility(VISIBLE);
settingsLinkView.setText(mContext.getString(R.string.notification_app_settings));
settingsLinkView.setOnClickListener((View view) -> {
mAppSettingsClickListener.onClick(view, settingsIntent);
});
} else {
settingsLinkView.setVisibility(View.GONE);
}
}
}

View File

@@ -311,7 +311,6 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
eq(false),
eq(true) /* isForBlockingHelper */,
eq(true) /* isUserSentimentNegative */,
eq(false) /*isNoisy */,
eq(0));
}
@@ -340,37 +339,6 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
eq(false),
eq(false) /* isForBlockingHelper */,
eq(true) /* isUserSentimentNegative */,
eq(false) /*isNoisy */,
eq(0));
}
@Test
public void testInitializeNotificationInfoView_noisy() throws Exception {
NotificationInfo notificationInfoView = mock(NotificationInfo.class);
ExpandableNotificationRow row = spy(mHelper.createRow());
row.setBlockingHelperShowing(true);
row.getEntry().userSentiment = USER_SENTIMENT_NEGATIVE;
row.getEntry().noisy = true;
when(row.getIsNonblockable()).thenReturn(false);
StatusBarNotification statusBarNotification = row.getStatusBarNotification();
mGutsManager.initializeNotificationInfo(row, notificationInfoView);
verify(notificationInfoView).bindNotification(
any(PackageManager.class),
any(INotificationManager.class),
eq(statusBarNotification.getPackageName()),
any(NotificationChannel.class),
anyInt(),
eq(statusBarNotification),
any(NotificationInfo.CheckSaveListener.class),
any(NotificationInfo.OnSettingsClickListener.class),
any(NotificationInfo.OnAppSettingsClickListener.class),
eq(false),
eq(false),
eq(true) /* isForBlockingHelper */,
eq(true) /* isUserSentimentNegative */,
eq(true) /*isNoisy */,
eq(0));
}
@@ -400,7 +368,6 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
eq(false),
eq(true) /* isForBlockingHelper */,
eq(true) /* isUserSentimentNegative */,
eq(false) /*isNoisy */,
eq(IMPORTANCE_DEFAULT));
}
@@ -430,7 +397,6 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
eq(false),
eq(false) /* isForBlockingHelper */,
eq(true) /* isUserSentimentNegative */,
eq(false) /*isNoisy */,
eq(0));
}
@@ -459,7 +425,6 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
eq(false),
eq(true) /* isForBlockingHelper */,
eq(true) /* isUserSentimentNegative */,
eq(false) /*isNoisy */,
eq(0));
}

View File

@@ -50,12 +50,9 @@ import android.app.INotificationManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.IBinder;
import android.os.UserHandle;
@@ -86,8 +83,6 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@SmallTest
@@ -187,7 +182,7 @@ public class NotificationInfoTest extends SysuiTestCase {
when(mMockPackageManager.getApplicationLabel(any())).thenReturn("App Name");
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final TextView textView = mNotificationInfo.findViewById(R.id.pkgname);
assertTrue(textView.getText().toString().contains("App Name"));
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility());
@@ -200,7 +195,7 @@ public class NotificationInfoTest extends SysuiTestCase {
.thenReturn(iconDrawable);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final ImageView iconView = mNotificationInfo.findViewById(R.id.pkgicon);
assertEquals(iconDrawable, iconView.getDrawable());
}
@@ -209,7 +204,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testBindNotification_noDelegate() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name);
assertEquals(GONE, nameView.getVisibility());
final TextView dividerView = mNotificationInfo.findViewById(R.id.pkg_divider);
@@ -228,7 +223,7 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name);
assertEquals(VISIBLE, nameView.getVisibility());
assertTrue(nameView.getText().toString().contains("Other"));
@@ -240,7 +235,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testBindNotification_GroupNameHiddenIfNoGroup() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name);
assertEquals(GONE, groupNameView.getVisibility());
final TextView groupDividerView = mNotificationInfo.findViewById(R.id.pkg_group_divider);
@@ -257,7 +252,7 @@ public class NotificationInfoTest extends SysuiTestCase {
.thenReturn(notificationChannelGroup);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name);
assertEquals(View.VISIBLE, groupNameView.getVisibility());
assertEquals("Test Group Name", groupNameView.getText());
@@ -269,7 +264,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testBindNotification_SetsTextChannelName() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(TEST_CHANNEL_NAME, textView.getText());
}
@@ -278,7 +273,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testBindNotification_DefaultChannelDoesNotUseChannelName() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mDefaultNotificationChannel, 1, mSbn, null, null, null, true,
false, false, IMPORTANCE_DEFAULT);
false, IMPORTANCE_DEFAULT);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(GONE, textView.getVisibility());
}
@@ -291,7 +286,7 @@ public class NotificationInfoTest extends SysuiTestCase {
eq(TEST_PACKAGE_NAME), eq(TEST_UID), anyBoolean())).thenReturn(10);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mDefaultNotificationChannel, 1, mSbn, null, null, null, true,
false, false, IMPORTANCE_DEFAULT);
false, IMPORTANCE_DEFAULT);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(VISIBLE, textView.getVisibility());
}
@@ -300,7 +295,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testBindNotification_UnblockablePackageUsesChannelName() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(VISIBLE, textView.getVisibility());
}
@@ -309,62 +304,104 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testBindNotification_BlockButton() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
final View block = mNotificationInfo.findViewById(R.id.block);
final View toggleSilent = mNotificationInfo.findViewById(R.id.toggle_silent);
final View minimize = mNotificationInfo.findViewById(R.id.minimize);
IMPORTANCE_DEFAULT);
final View block = mNotificationInfo.findViewById(R.id.int_block);
final View minimize = mNotificationInfo.findViewById(R.id.block_or_minimize);
assertEquals(VISIBLE, block.getVisibility());
assertEquals(GONE, toggleSilent.getVisibility());
assertEquals(GONE, minimize.getVisibility());
}
@Test
public void testBindNotification_SilenceButton() throws Exception {
public void testBindNotification_BlockButton_BlockHelper() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true /* isBlockingHelper */, false, IMPORTANCE_DEFAULT);
final View block = mNotificationInfo.findViewById(R.id.block);
final View interruptivenessSettings = mNotificationInfo.findViewById(
R.id.interruptiveness_settings);
assertEquals(VISIBLE, block.getVisibility());
assertEquals(GONE, interruptivenessSettings.getVisibility());
}
@Test
public void testBindNotification_SilenceButton_CurrentlyAlerting() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true, IMPORTANCE_DEFAULT);
final TextView toggleSilent = mNotificationInfo.findViewById(R.id.toggle_silent);
assertEquals(VISIBLE, toggleSilent.getVisibility());
IMPORTANCE_DEFAULT);
final TextView silent = mNotificationInfo.findViewById(R.id.int_silent);
assertEquals(VISIBLE, silent.getVisibility());
assertEquals(
mContext.getString(R.string.inline_silent_button_silent), toggleSilent.getText());
mContext.getString(R.string.inline_silent_button_silent), silent.getText());
}
@Test
public void testBindNotification_UnSilenceButton() throws Exception {
public void testBindNotification_SilenceButton_CurrentlySilent() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true, IMPORTANCE_LOW);
final TextView toggleSilent = mNotificationInfo.findViewById(R.id.toggle_silent);
assertEquals(VISIBLE, toggleSilent.getVisibility());
IMPORTANCE_LOW);
final TextView silent = mNotificationInfo.findViewById(R.id.int_silent);
assertEquals(VISIBLE, silent.getVisibility());
assertEquals(
mContext.getString(R.string.inline_silent_button_alert), toggleSilent.getText());
mContext.getString(R.string.inline_silent_button_stay_silent),
silent.getText());
}
@Test
public void testBindNotification_SilenceButton_ChannelImportanceUnspecified() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_UNSPECIFIED);
public void testBindNotification_AlertButton_CurrentlySilent() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true, IMPORTANCE_DEFAULT);
final TextView toggleSilent = mNotificationInfo.findViewById(R.id.toggle_silent);
assertEquals(VISIBLE, toggleSilent.getVisibility());
IMPORTANCE_LOW);
final TextView alert = mNotificationInfo.findViewById(R.id.int_alert);
assertEquals(VISIBLE, alert.getVisibility());
assertEquals(
mContext.getString(R.string.inline_silent_button_silent), toggleSilent.getText());
mContext.getString(R.string.inline_silent_button_alert), alert.getText());
}
@Test
public void testBindNotification_UnSilenceButton_ChannelImportanceUnspecified()
throws Exception {
public void testBindNotification_UnSilenceButton_currentlyAlerting() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT);
final TextView alert = mNotificationInfo.findViewById(R.id.int_alert);
assertEquals(VISIBLE, alert.getVisibility());
assertEquals(
mContext.getString(R.string.inline_silent_button_keep_alerting), alert.getText());
}
@Test
public void testBindNotification_ChannelImportanceUnspecified_NotifAlerting() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_UNSPECIFIED);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true, IMPORTANCE_LOW);
final TextView toggleSilent = mNotificationInfo.findViewById(R.id.toggle_silent);
assertEquals(VISIBLE, toggleSilent.getVisibility());
IMPORTANCE_DEFAULT);
final TextView silent = mNotificationInfo.findViewById(R.id.int_silent);
final TextView alert = mNotificationInfo.findViewById(R.id.int_alert);
assertEquals(VISIBLE, silent.getVisibility());
assertEquals(VISIBLE, alert.getVisibility());
assertEquals(
mContext.getString(R.string.inline_silent_button_alert), toggleSilent.getText());
mContext.getString(R.string.inline_silent_button_silent), silent.getText());
assertEquals(
mContext.getString(R.string.inline_silent_button_keep_alerting), alert.getText());
}
@Test
public void testBindNotification_ChannelImportanceUnspecified_NotifSilent() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_UNSPECIFIED);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_LOW);
final TextView silent = mNotificationInfo.findViewById(R.id.int_silent);
final TextView alert = mNotificationInfo.findViewById(R.id.int_alert);
assertEquals(VISIBLE, silent.getVisibility());
assertEquals(VISIBLE, alert.getVisibility());
assertEquals(
mContext.getString(R.string.inline_silent_button_stay_silent), silent.getText());
assertEquals(
mContext.getString(R.string.inline_silent_button_alert), alert.getText());
}
@Test
@@ -372,10 +409,13 @@ public class NotificationInfoTest extends SysuiTestCase {
mSbn.getNotification().flags = Notification.FLAG_FOREGROUND_SERVICE;
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final View block = mNotificationInfo.findViewById(R.id.block);
final View interruptivenessSettings = mNotificationInfo.findViewById(
R.id.interruptiveness_settings);
final View minimize = mNotificationInfo.findViewById(R.id.minimize);
assertEquals(GONE, block.getVisibility());
assertEquals(GONE, interruptivenessSettings.getVisibility());
assertEquals(VISIBLE, minimize.getVisibility());
}
@@ -387,7 +427,7 @@ public class NotificationInfoTest extends SysuiTestCase {
(View v, NotificationChannel c, int appUid) -> {
assertEquals(mNotificationChannel, c);
latch.countDown();
}, null, true, false, false, IMPORTANCE_DEFAULT);
}, null, true, false, IMPORTANCE_DEFAULT);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
settingsButton.performClick();
@@ -399,7 +439,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testBindNotification_SettingsButtonInvisibleWhenNoClickListener() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
assertTrue(settingsButton.getVisibility() != View.VISIBLE);
}
@@ -411,7 +451,7 @@ public class NotificationInfoTest extends SysuiTestCase {
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null,
(View v, NotificationChannel c, int appUid) -> {
assertEquals(mNotificationChannel, c);
}, null, false, false, false, IMPORTANCE_DEFAULT);
}, null, false, false, IMPORTANCE_DEFAULT);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
assertTrue(settingsButton.getVisibility() != View.VISIBLE);
}
@@ -420,11 +460,11 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testBindNotification_SettingsButtonReappearsAfterSecondBind() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null,
(View v, NotificationChannel c, int appUid) -> {
}, null, true, false, false, IMPORTANCE_DEFAULT);
}, null, true, false, IMPORTANCE_DEFAULT);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
assertEquals(View.VISIBLE, settingsButton.getVisibility());
}
@@ -433,7 +473,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testLogBlockingHelperCounter_doesntLogForNormalGutsView() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.logBlockingHelperCounter("HowCanNotifsBeRealIfAppsArent");
verify(mMetricsLogger, times(0)).count(anyString(), anyInt());
}
@@ -442,7 +482,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testLogBlockingHelperCounter_logsForBlockingHelper() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, false, true,
true, true, false, IMPORTANCE_DEFAULT);
true, true, IMPORTANCE_DEFAULT);
mNotificationInfo.logBlockingHelperCounter("HowCanNotifsBeRealIfAppsArent");
verify(mMetricsLogger, times(1)).count(anyString(), anyInt());
}
@@ -455,7 +495,7 @@ public class NotificationInfoTest extends SysuiTestCase {
(View v, NotificationChannel c, int appUid) -> {
assertEquals(null, c);
latch.countDown();
}, null, true, true, false, IMPORTANCE_DEFAULT);
}, null, true, true, IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.info).performClick();
// Verify that listener was triggered.
@@ -468,7 +508,7 @@ public class NotificationInfoTest extends SysuiTestCase {
throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, MULTIPLE_CHANNEL_COUNT, mSbn, null, null,
null, true, true, false, IMPORTANCE_DEFAULT);
null, true, true, IMPORTANCE_DEFAULT);
final TextView channelNameView =
mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(GONE, channelNameView.getVisibility());
@@ -479,7 +519,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testStopInvisibleIfBundleFromDifferentChannels() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, MULTIPLE_CHANNEL_COUNT, mSbn, null, null,
null, true, true, false, IMPORTANCE_DEFAULT);
null, true, true, IMPORTANCE_DEFAULT);
final TextView blockView = mNotificationInfo.findViewById(R.id.block);
assertEquals(GONE, blockView.getVisibility());
}
@@ -488,7 +528,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testbindNotification_BlockingHelper() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, false, false,
true, true, false, IMPORTANCE_DEFAULT);
true, true, IMPORTANCE_DEFAULT);
final TextView view = mNotificationInfo.findViewById(R.id.block_prompt);
assertEquals(View.VISIBLE, view.getVisibility());
assertEquals(mContext.getString(R.string.inline_blocking_helper), view.getText());
@@ -498,7 +538,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testbindNotification_UnblockableTextVisibleWhenAppUnblockable() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
final TextView view = mNotificationInfo.findViewById(R.id.block_prompt);
assertEquals(View.VISIBLE, view.getVisibility());
assertEquals(mContext.getString(R.string.notification_unblockable_desc),
@@ -509,7 +549,7 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testBindNotification_DoesNotUpdateNotificationChannel() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mTestableLooper.processAllMessages();
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
anyString(), eq(TEST_UID), any());
@@ -520,9 +560,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
mTestableLooper.processAllMessages();
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
anyString(), eq(TEST_UID), any());
@@ -534,7 +574,7 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.minimize).performClick();
mTestableLooper.processAllMessages();
@@ -548,9 +588,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.toggle_silent).performClick();
mNotificationInfo.findViewById(R.id.int_silent).performClick();
mTestableLooper.processAllMessages();
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
anyString(), eq(TEST_UID), any());
@@ -562,9 +602,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.toggle_silent).performClick();
mNotificationInfo.findViewById(R.id.int_alert).performClick();
mTestableLooper.processAllMessages();
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
anyString(), eq(TEST_UID), any());
@@ -576,7 +616,7 @@ public class NotificationInfoTest extends SysuiTestCase {
int originalImportance = mNotificationChannel.getImportance();
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -591,7 +631,7 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_UNSPECIFIED);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.handleCloseControls(true, false);
@@ -609,10 +649,10 @@ public class NotificationInfoTest extends SysuiTestCase {
TEST_PACKAGE_NAME, mNotificationChannel /* notificationChannel */,
10 /* numUniqueChannelsInRow */, mSbn, null /* checkSaveListener */,
null /* onSettingsClick */, null /* onAppSettingsClick */ ,
true, false /* isNonblockable */, false /* isNoisy */, IMPORTANCE_DEFAULT
true, false /* isNonblockable */, IMPORTANCE_DEFAULT
);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
@@ -631,10 +671,10 @@ public class NotificationInfoTest extends SysuiTestCase {
TEST_PACKAGE_NAME, mNotificationChannel /* notificationChannel */,
10 /* numUniqueChannelsInRow */, mSbn, null /* checkSaveListener */,
null /* onSettingsClick */, null /* onAppSettingsClick */,
true, false /* isNonblockable */, false /* isNoisy */, IMPORTANCE_DEFAULT
true, false /* isNonblockable */, IMPORTANCE_DEFAULT
);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
@@ -653,7 +693,7 @@ public class NotificationInfoTest extends SysuiTestCase {
null /* onSettingsClick */, null /* onAppSettingsClick */ ,
true /* provisioned */,
false /* isNonblockable */, true /* isForBlockingHelper */,
true /* isUserSentimentNegative */, false /* isNoisy */, IMPORTANCE_DEFAULT);
true /* isUserSentimentNegative */, IMPORTANCE_DEFAULT);
NotificationGuts guts = spy(new NotificationGuts(mContext, null));
when(guts.getWindowToken()).thenReturn(mock(IBinder.class));
@@ -681,7 +721,7 @@ public class NotificationInfoTest extends SysuiTestCase {
10 /* numUniqueChannelsInRow */, mSbn, listener /* checkSaveListener */,
null /* onSettingsClick */, null /* onAppSettingsClick */ , true /* provisioned */,
false /* isNonblockable */, true /* isForBlockingHelper */,
true /* isUserSentimentNegative */, false /* isNoisy */, IMPORTANCE_DEFAULT);
true /* isUserSentimentNegative */, IMPORTANCE_DEFAULT);
NotificationGuts guts = spy(new NotificationGuts(mContext, null));
when(guts.getWindowToken()).thenReturn(mock(IBinder.class));
@@ -709,7 +749,7 @@ public class NotificationInfoTest extends SysuiTestCase {
10 /* numUniqueChannelsInRow */, mSbn, listener /* checkSaveListener */,
null /* onSettingsClick */, null /* onAppSettingsClick */ ,
false /* isNonblockable */, true /* isForBlockingHelper */,
true, true /* isUserSentimentNegative */, false /* isNoisy */,
true, true /* isUserSentimentNegative */, /* isNoisy */
IMPORTANCE_DEFAULT);
mNotificationInfo.handleCloseControls(true /* save */, false /* force */);
@@ -729,7 +769,7 @@ public class NotificationInfoTest extends SysuiTestCase {
null /* onSettingsClick */, null /* onAppSettingsClick */,
true /* provisioned */,
false /* isNonblockable */, true /* isForBlockingHelper */,
true /* isUserSentimentNegative */, false /* isNoisy */, IMPORTANCE_DEFAULT);
true /* isUserSentimentNegative */, IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
mTestableLooper.processAllMessages();
@@ -752,7 +792,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true /* isForBlockingHelper */,
true,
false /* isUserSentimentNegative */,
false /* isNoisy */, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
NotificationGuts guts = mock(NotificationGuts.class);
doCallRealMethod().when(guts).closeControls(anyInt(), anyInt(), anyBoolean(), anyBoolean());
mNotificationInfo.setGutsParent(guts);
@@ -767,7 +807,7 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
waitForUndoButton();
@@ -781,9 +821,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
@@ -814,7 +854,7 @@ public class NotificationInfoTest extends SysuiTestCase {
false /* isNonblockable */,
true /* isForBlockingHelper */,
true /* isUserSentimentNegative */,
false/* isNoisy */, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
waitForUndoButton();
@@ -836,7 +876,7 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
@@ -851,7 +891,7 @@ public class NotificationInfoTest extends SysuiTestCase {
mSbn.getNotification().flags = Notification.FLAG_FOREGROUND_SERVICE;
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
@@ -872,7 +912,7 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.handleCloseControls(true, false);
@@ -890,9 +930,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
waitForUndoButton();
mNotificationInfo.findViewById(R.id.undo).performClick();
waitForStopButton();
@@ -911,8 +951,8 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testMinUndoDoesNotMinNotificationChannel() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
@@ -934,9 +974,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.toggle_silent).performClick();
mNotificationInfo.findViewById(R.id.int_silent).performClick();
waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
@@ -955,9 +995,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.toggle_silent).performClick();
mNotificationInfo.findViewById(R.id.int_alert).performClick();
waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
@@ -977,9 +1017,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_UNSPECIFIED);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
true, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.toggle_silent).performClick();
mNotificationInfo.findViewById(R.id.int_silent).performClick();
waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
@@ -999,9 +1039,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_UNSPECIFIED);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
false, IMPORTANCE_LOW);
IMPORTANCE_LOW);
mNotificationInfo.findViewById(R.id.toggle_silent).performClick();
mNotificationInfo.findViewById(R.id.int_alert).performClick();
waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
@@ -1016,11 +1056,11 @@ public class NotificationInfoTest extends SysuiTestCase {
}
@Test
public void testCloseControlsDoesNotUpdateiMinIfSaveIsFalse() throws Exception {
public void testCloseControlsDoesNotUpdateMinIfSaveIsFalse() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
@@ -1035,10 +1075,10 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testCloseControlsDoesNotUpdateIfSaveIsFalse() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
waitForUndoButton();
mNotificationInfo.handleCloseControls(false, false);
@@ -1053,9 +1093,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
(Runnable saveImportance, StatusBarNotification sbn) -> {
}, null, null, true, true, false, IMPORTANCE_DEFAULT);
}, null, null, true, true, IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
mTestableLooper.processAllMessages();
ensureNoUndoButton();
mNotificationInfo.handleCloseControls(true, false);
@@ -1071,10 +1111,10 @@ public class NotificationInfoTest extends SysuiTestCase {
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
(Runnable saveImportance, StatusBarNotification sbn) -> {
saveImportance.run();
}, null, null, true, false, false, IMPORTANCE_DEFAULT
}, null, null, true, false, IMPORTANCE_DEFAULT
);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
mTestableLooper.processAllMessages();
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
eq(TEST_PACKAGE_NAME), eq(TEST_UID), eq(mNotificationChannel));
@@ -1087,124 +1127,6 @@ public class NotificationInfoTest extends SysuiTestCase {
eq(TEST_PACKAGE_NAME), eq(TEST_UID), eq(mNotificationChannel));
}
@Test
public void testDisplaySettingsLink() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final String settingsText = "work chats";
final ResolveInfo ri = new ResolveInfo();
ri.activityInfo = new ActivityInfo();
ri.activityInfo.packageName = TEST_PACKAGE_NAME;
ri.activityInfo.name = "something";
List<ResolveInfo> ris = new ArrayList<>();
ris.add(ri);
when(mMockPackageManager.queryIntentActivities(any(), anyInt())).thenReturn(ris);
mNotificationChannel.setImportance(IMPORTANCE_LOW);
Notification n = new Notification.Builder(mContext, mNotificationChannel.getId())
.setSettingsText(settingsText).build();
StatusBarNotification sbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME,
0, null, 0, 0, n, UserHandle.CURRENT, null, 0);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, sbn, null, null,
(View v, Intent intent) -> {
latch.countDown();
}, true, false, false, IMPORTANCE_DEFAULT);
final TextView settingsLink = mNotificationInfo.findViewById(R.id.app_settings);
assertEquals(View.VISIBLE, settingsLink.getVisibility());
settingsLink.performClick();
assertEquals(0, latch.getCount());
}
@Test
public void testDisplaySettingsLink_multipleChannels() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final String settingsText = "work chats";
final ResolveInfo ri = new ResolveInfo();
ri.activityInfo = new ActivityInfo();
ri.activityInfo.packageName = TEST_PACKAGE_NAME;
ri.activityInfo.name = "something";
List<ResolveInfo> ris = new ArrayList<>();
ris.add(ri);
when(mMockPackageManager.queryIntentActivities(any(), anyInt())).thenReturn(ris);
mNotificationChannel.setImportance(IMPORTANCE_LOW);
Notification n = new Notification.Builder(mContext, mNotificationChannel.getId())
.setSettingsText(settingsText).build();
StatusBarNotification sbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME,
0, null, 0, 0, n, UserHandle.CURRENT, null, 0);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, MULTIPLE_CHANNEL_COUNT, sbn, null, null,
(View v, Intent intent) -> {
latch.countDown();
}, true, false, false, IMPORTANCE_DEFAULT);
final TextView settingsLink = mNotificationInfo.findViewById(R.id.app_settings);
assertEquals(View.VISIBLE, settingsLink.getVisibility());
settingsLink.performClick();
assertEquals(0, latch.getCount());
}
@Test
public void testNoSettingsLink_noHandlingActivity() throws Exception {
final String settingsText = "work chats";
when(mMockPackageManager.queryIntentActivities(any(), anyInt())).thenReturn(null);
mNotificationChannel.setImportance(IMPORTANCE_LOW);
Notification n = new Notification.Builder(mContext, mNotificationChannel.getId())
.setSettingsText(settingsText).build();
StatusBarNotification sbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME,
0, null, 0, 0, n, UserHandle.CURRENT, null, 0);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, MULTIPLE_CHANNEL_COUNT, sbn, null, null,
null, true, false, false, IMPORTANCE_DEFAULT);
final TextView settingsLink = mNotificationInfo.findViewById(R.id.app_settings);
assertEquals(GONE, settingsLink.getVisibility());
}
@Test
public void testNoSettingsLink_noLinkText() throws Exception {
final ResolveInfo ri = new ResolveInfo();
ri.activityInfo = new ActivityInfo();
ri.activityInfo.packageName = TEST_PACKAGE_NAME;
ri.activityInfo.name = "something";
List<ResolveInfo> ris = new ArrayList<>();
ris.add(ri);
when(mMockPackageManager.queryIntentActivities(any(), anyInt())).thenReturn(ris);
mNotificationChannel.setImportance(IMPORTANCE_LOW);
Notification n = new Notification.Builder(mContext, mNotificationChannel.getId()).build();
StatusBarNotification sbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME,
0, null, 0, 0, n, UserHandle.CURRENT, null, 0);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, sbn, null, null, null, true, false,
false, IMPORTANCE_DEFAULT);
final TextView settingsLink = mNotificationInfo.findViewById(R.id.app_settings);
assertEquals(GONE, settingsLink.getVisibility());
}
@Test
public void testBindHeader_noSettingsLinkWhenIsForBlockingHelper() throws Exception {
final String settingsText = "work chats";
final ResolveInfo ri = new ResolveInfo();
ri.activityInfo = new ActivityInfo();
ri.activityInfo.packageName = TEST_PACKAGE_NAME;
ri.activityInfo.name = "something";
List<ResolveInfo> ris = new ArrayList<>();
ris.add(ri);
when(mMockPackageManager.queryIntentActivities(any(), anyInt())).thenReturn(ris);
mNotificationChannel.setImportance(IMPORTANCE_LOW);
Notification n = new Notification.Builder(mContext, mNotificationChannel.getId())
.setSettingsText(settingsText).build();
StatusBarNotification sbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME,
0, null, 0, 0, n, UserHandle.CURRENT, null, 0);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, sbn, null, null, null, false, true,
true, true, false, IMPORTANCE_DEFAULT);
final TextView settingsLink = mNotificationInfo.findViewById(R.id.app_settings);
assertEquals(GONE, settingsLink.getVisibility());
}
@Test
public void testWillBeRemovedReturnsFalseBeforeBind() throws Exception {
assertFalse(mNotificationInfo.willBeRemoved());
@@ -1216,7 +1138,7 @@ public class NotificationInfoTest extends SysuiTestCase {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
@@ -1228,10 +1150,10 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testUndoText_block() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
waitForUndoButton();
TextView confirmationText = mNotificationInfo.findViewById(R.id.confirmation_text);
assertTrue(confirmationText.getText().toString().contains("won't see"));
@@ -1241,10 +1163,10 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testUndoText_silence() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
true, IMPORTANCE_DEFAULT);
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.toggle_silent).performClick();
mNotificationInfo.findViewById(R.id.int_silent).performClick();
waitForUndoButton();
TextView confirmationText = mNotificationInfo.findViewById(R.id.confirmation_text);
assertEquals(mContext.getString(R.string.notification_channel_silenced),
@@ -1255,10 +1177,10 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testUndoText_unsilence() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
true, IMPORTANCE_DEFAULT);
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.toggle_silent).performClick();
mNotificationInfo.findViewById(R.id.int_alert).performClick();
waitForUndoButton();
TextView confirmationText = mNotificationInfo.findViewById(R.id.confirmation_text);
assertEquals(mContext.getString(R.string.notification_channel_unsilenced),
@@ -1269,10 +1191,10 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testNoHeaderOnConfirmation() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
waitForUndoButton();
assertEquals(GONE, mNotificationInfo.findViewById(R.id.header).getVisibility());
}
@@ -1281,10 +1203,10 @@ public class NotificationInfoTest extends SysuiTestCase {
public void testHeaderOnUndo() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
false, IMPORTANCE_DEFAULT);
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT);
mNotificationInfo.findViewById(R.id.block).performClick();
mNotificationInfo.findViewById(R.id.int_block).performClick();
waitForUndoButton();
mNotificationInfo.findViewById(R.id.undo).performClick();
waitForStopButton();