Adding automatic option in long press menu
Automatic will be the default selected mode unless the user has overridden the channel with their preferred alert setting Test: manually on device Change-Id: Ia3202725699dcfc3f6bfeb94a91b48025a96c7e9
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<!--
|
||||
Copyright (C) 2020 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M15.6 0L4 13.88h8.75L10.04 24L21 10.35h-8.25z" />
|
||||
</vector>
|
||||
@@ -149,6 +149,58 @@ asked for it -->
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
<com.android.systemui.statusbar.notification.row.ButtonLinearLayout
|
||||
android:id="@+id/automatic"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/notification_importance_button_separation"
|
||||
android:padding="@dimen/notification_importance_button_padding"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="@drawable/notification_guts_priority_button_bg"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/automatic_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_notifications_automatic"
|
||||
android:background="@android:color/transparent"
|
||||
android:tint="@color/notification_guts_priority_contents"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
<TextView
|
||||
android:id="@+id/automatic_label"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/notification_importance_drawable_padding"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:textAppearance="@style/TextAppearance.NotificationImportanceButton"
|
||||
android:text="@string/notification_automatic_title"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/automatic_summary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/notification_importance_button_description_top_margin"
|
||||
android:visibility="gone"
|
||||
android:text="@string/notification_channel_summary_automatic"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
|
||||
</com.android.systemui.statusbar.notification.row.ButtonLinearLayout>
|
||||
|
||||
<com.android.systemui.statusbar.notification.row.ButtonLinearLayout
|
||||
android:id="@+id/alert"
|
||||
@@ -287,6 +339,5 @@ asked for it -->
|
||||
android:maxWidth="125dp"
|
||||
style="@style/TextAppearance.NotificationInfo.Button"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</com.android.systemui.statusbar.notification.row.NotificationInfo>
|
||||
|
||||
@@ -1838,6 +1838,9 @@
|
||||
<!-- [CHAR LIMIT=100] Notification Importance title -->
|
||||
<string name="notification_bubble_title">Bubble</string>
|
||||
|
||||
<!-- [CHAR LIMIT=100] Notification Importance title -->
|
||||
<string name="notification_automatic_title">Automatic</string>
|
||||
|
||||
<!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
|
||||
<string name="notification_channel_summary_low">No sound or vibration</string>
|
||||
|
||||
@@ -1853,6 +1856,9 @@
|
||||
<!-- [CHAR LIMIT=150] Notification Importance title: bubble level summary -->
|
||||
<string name="notification_channel_summary_bubble">Keeps your attention with a floating shortcut to this content.</string>
|
||||
|
||||
<!-- [CHAR LIMIT=150] Notification Importance title: automatic importance level summary -->
|
||||
<string name="notification_channel_summary_automatic">Have the system determine if this notification should make sound or vibration</string>
|
||||
|
||||
<!-- [CHAR LIMIT=150] Notification Importance title: important conversation level summary -->
|
||||
<string name="notification_channel_summary_priority">Shows at top of conversation section, appears as floating bubble, displays profile picture on lock screen</string>
|
||||
|
||||
|
||||
@@ -390,7 +390,8 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
|
||||
onAppSettingsClick,
|
||||
mDeviceProvisionedController.isDeviceProvisioned(),
|
||||
row.getIsNonblockable(),
|
||||
mHighPriorityProvider.isHighPriority(row.getEntry()));
|
||||
mHighPriorityProvider.isHighPriority(row.getEntry()),
|
||||
NotificationViewHierarchyManager.showFeedback(row.getEntry()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,6 +89,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
|
||||
private TextView mPriorityDescriptionView;
|
||||
private TextView mSilentDescriptionView;
|
||||
private TextView mAutomaticDescriptionView;
|
||||
|
||||
private INotificationManager mINotificationManager;
|
||||
private PackageManager mPm;
|
||||
@@ -107,12 +108,14 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
private boolean mWasShownHighPriority;
|
||||
private boolean mPressedApply;
|
||||
private boolean mPresentingChannelEditorDialog = false;
|
||||
private boolean mShowAutomaticSetting;
|
||||
|
||||
/**
|
||||
* The last importance level chosen by the user. Null if the user has not chosen an importance
|
||||
* level; non-null once the user takes an action which indicates an explicit preference.
|
||||
*/
|
||||
@Nullable private Integer mChosenImportance;
|
||||
private boolean mIsAutomaticChosen;
|
||||
private boolean mIsSingleDefaultChannel;
|
||||
private boolean mIsNonblockable;
|
||||
private StatusBarNotification mSbn;
|
||||
@@ -126,15 +129,23 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
@VisibleForTesting
|
||||
boolean mSkipPost = false;
|
||||
|
||||
// used by standard ui
|
||||
private OnClickListener mOnAutomatic = v -> {
|
||||
mIsAutomaticChosen = true;
|
||||
applyAlertingBehavior(BEHAVIOR_AUTOMATIC, true /* userTriggered */);
|
||||
};
|
||||
|
||||
// used by standard ui
|
||||
private OnClickListener mOnAlert = v -> {
|
||||
mChosenImportance = IMPORTANCE_DEFAULT;
|
||||
mIsAutomaticChosen = false;
|
||||
applyAlertingBehavior(BEHAVIOR_ALERTING, true /* userTriggered */);
|
||||
};
|
||||
|
||||
// used by standard ui
|
||||
private OnClickListener mOnSilent = v -> {
|
||||
mChosenImportance = IMPORTANCE_LOW;
|
||||
mIsAutomaticChosen = false;
|
||||
applyAlertingBehavior(BEHAVIOR_SILENT, true /* userTriggered */);
|
||||
};
|
||||
|
||||
@@ -154,6 +165,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
|
||||
mPriorityDescriptionView = findViewById(R.id.alert_summary);
|
||||
mSilentDescriptionView = findViewById(R.id.silence_summary);
|
||||
mAutomaticDescriptionView = findViewById(R.id.automatic_summary);
|
||||
}
|
||||
|
||||
// Specify a CheckSaveListener to override when/if the user's changes are committed.
|
||||
@@ -184,7 +196,8 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
OnAppSettingsClickListener onAppSettingsClick,
|
||||
boolean isDeviceProvisioned,
|
||||
boolean isNonblockable,
|
||||
boolean wasShownHighPriority)
|
||||
boolean wasShownHighPriority,
|
||||
boolean showAutomaticSetting)
|
||||
throws RemoteException {
|
||||
mINotificationManager = iNotificationManager;
|
||||
mMetricsLogger = Dependency.get(MetricsLogger.class);
|
||||
@@ -205,6 +218,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
mAppUid = mSbn.getUid();
|
||||
mDelegatePkg = mSbn.getOpPkg();
|
||||
mIsDeviceProvisioned = isDeviceProvisioned;
|
||||
mShowAutomaticSetting = showAutomaticSetting;
|
||||
|
||||
int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage(
|
||||
pkg, mAppUid, false /* includeDeleted */);
|
||||
@@ -257,9 +271,15 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
silent.setOnClickListener(mOnSilent);
|
||||
alert.setOnClickListener(mOnAlert);
|
||||
|
||||
int behavior = mWasShownHighPriority
|
||||
? BEHAVIOR_ALERTING
|
||||
: BEHAVIOR_SILENT;
|
||||
View automatic = findViewById(R.id.automatic);
|
||||
if (mShowAutomaticSetting) {
|
||||
automatic.setVisibility(VISIBLE);
|
||||
automatic.setOnClickListener(mOnAutomatic);
|
||||
} else {
|
||||
automatic.setVisibility(GONE);
|
||||
}
|
||||
|
||||
int behavior = getAlertingBehavior();
|
||||
applyAlertingBehavior(behavior, false /* userTriggered */);
|
||||
}
|
||||
|
||||
@@ -411,7 +431,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
bgHandler.post(
|
||||
new UpdateImportanceRunnable(mINotificationManager, mPackageName, mAppUid,
|
||||
mNumUniqueChannelsInRow == 1 ? mSingleNotificationChannel : null,
|
||||
mStartingChannelImportance, newImportance));
|
||||
mStartingChannelImportance, newImportance, mIsAutomaticChosen));
|
||||
mVisualStabilityManager.temporarilyAllowReordering();
|
||||
}
|
||||
}
|
||||
@@ -444,23 +464,39 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
|
||||
View alert = findViewById(R.id.alert);
|
||||
View silence = findViewById(R.id.silence);
|
||||
View automatic = findViewById(R.id.automatic);
|
||||
|
||||
switch (behavior) {
|
||||
case BEHAVIOR_ALERTING:
|
||||
mPriorityDescriptionView.setVisibility(VISIBLE);
|
||||
mSilentDescriptionView.setVisibility(GONE);
|
||||
mAutomaticDescriptionView.setVisibility(GONE);
|
||||
post(() -> {
|
||||
alert.setSelected(true);
|
||||
silence.setSelected(false);
|
||||
automatic.setSelected(false);
|
||||
});
|
||||
break;
|
||||
|
||||
case BEHAVIOR_SILENT:
|
||||
mSilentDescriptionView.setVisibility(VISIBLE);
|
||||
mPriorityDescriptionView.setVisibility(GONE);
|
||||
mAutomaticDescriptionView.setVisibility(GONE);
|
||||
post(() -> {
|
||||
alert.setSelected(false);
|
||||
silence.setSelected(true);
|
||||
automatic.setSelected(false);
|
||||
});
|
||||
break;
|
||||
|
||||
case BEHAVIOR_AUTOMATIC:
|
||||
mAutomaticDescriptionView.setVisibility(VISIBLE);
|
||||
mPriorityDescriptionView.setVisibility(GONE);
|
||||
mSilentDescriptionView.setVisibility(GONE);
|
||||
post(() -> {
|
||||
automatic.setSelected(true);
|
||||
alert.setSelected(false);
|
||||
silence.setSelected(false);
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -468,7 +504,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
throw new IllegalArgumentException("Unrecognized alerting behavior: " + behavior);
|
||||
}
|
||||
|
||||
boolean isAChange = mWasShownHighPriority != (behavior == BEHAVIOR_ALERTING);
|
||||
boolean isAChange = getAlertingBehavior() != behavior;
|
||||
TextView done = findViewById(R.id.done);
|
||||
done.setText(isAChange
|
||||
? R.string.inline_ok_button
|
||||
@@ -594,25 +630,31 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
private final @Nullable NotificationChannel mChannelToUpdate;
|
||||
private final int mCurrentImportance;
|
||||
private final int mNewImportance;
|
||||
private final boolean mUnlockImportance;
|
||||
|
||||
|
||||
public UpdateImportanceRunnable(INotificationManager notificationManager,
|
||||
String packageName, int appUid, @Nullable NotificationChannel channelToUpdate,
|
||||
int currentImportance, int newImportance) {
|
||||
int currentImportance, int newImportance, boolean unlockImportance) {
|
||||
mINotificationManager = notificationManager;
|
||||
mPackageName = packageName;
|
||||
mAppUid = appUid;
|
||||
mChannelToUpdate = channelToUpdate;
|
||||
mCurrentImportance = currentImportance;
|
||||
mNewImportance = newImportance;
|
||||
mUnlockImportance = unlockImportance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (mChannelToUpdate != null) {
|
||||
mChannelToUpdate.setImportance(mNewImportance);
|
||||
mChannelToUpdate.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||
if (mUnlockImportance) {
|
||||
mChannelToUpdate.unlockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||
} else {
|
||||
mChannelToUpdate.setImportance(mNewImportance);
|
||||
mChannelToUpdate.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||
}
|
||||
mINotificationManager.updateNotificationChannelForPackage(
|
||||
mPackageName, mAppUid, mChannelToUpdate);
|
||||
} else {
|
||||
@@ -662,9 +704,17 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
|
||||
.setSubtype(MetricsEvent.BLOCKING_HELPER_UNKNOWN);
|
||||
}
|
||||
|
||||
private @AlertingBehavior int getAlertingBehavior() {
|
||||
if (mShowAutomaticSetting && !mSingleNotificationChannel.hasUserSetImportance()) {
|
||||
return BEHAVIOR_AUTOMATIC;
|
||||
}
|
||||
return mWasShownHighPriority ? BEHAVIOR_ALERTING : BEHAVIOR_SILENT;
|
||||
}
|
||||
|
||||
@Retention(SOURCE)
|
||||
@IntDef({BEHAVIOR_ALERTING, BEHAVIOR_SILENT})
|
||||
@IntDef({BEHAVIOR_ALERTING, BEHAVIOR_SILENT, BEHAVIOR_AUTOMATIC})
|
||||
private @interface AlertingBehavior {}
|
||||
private static final int BEHAVIOR_ALERTING = 0;
|
||||
private static final int BEHAVIOR_SILENT = 1;
|
||||
private static final int BEHAVIOR_AUTOMATIC = 2;
|
||||
}
|
||||
|
||||
@@ -361,7 +361,8 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
|
||||
any(NotificationInfo.OnAppSettingsClickListener.class),
|
||||
eq(false),
|
||||
eq(false),
|
||||
eq(true) /* wasShownHighPriority */);
|
||||
eq(true), /* wasShownHighPriority */
|
||||
eq(false) /* showAutomaticSetting */);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -393,7 +394,8 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
|
||||
any(NotificationInfo.OnAppSettingsClickListener.class),
|
||||
eq(true),
|
||||
eq(false),
|
||||
eq(false) /* wasShownHighPriority */);
|
||||
eq(false), /* wasShownHighPriority */
|
||||
eq(false) /* showAutomaticSetting */);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -423,7 +425,8 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
|
||||
any(NotificationInfo.OnAppSettingsClickListener.class),
|
||||
eq(false),
|
||||
eq(false),
|
||||
eq(false) /* wasShownHighPriority */);
|
||||
eq(false), /* wasShownHighPriority */
|
||||
eq(false) /* showAutomaticSetting */);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -189,7 +189,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView textView = mNotificationInfo.findViewById(R.id.pkg_name);
|
||||
assertTrue(textView.getText().toString().contains("App Name"));
|
||||
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility());
|
||||
@@ -213,7 +214,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final ImageView iconView = mNotificationInfo.findViewById(R.id.pkg_icon);
|
||||
assertEquals(iconDrawable, iconView.getDrawable());
|
||||
}
|
||||
@@ -233,7 +235,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name);
|
||||
assertEquals(GONE, nameView.getVisibility());
|
||||
}
|
||||
@@ -262,7 +265,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name);
|
||||
assertEquals(VISIBLE, nameView.getVisibility());
|
||||
assertTrue(nameView.getText().toString().contains("Proxied"));
|
||||
@@ -283,7 +287,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name);
|
||||
assertEquals(GONE, groupNameView.getVisibility());
|
||||
}
|
||||
@@ -309,7 +314,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name);
|
||||
assertEquals(View.VISIBLE, groupNameView.getVisibility());
|
||||
assertEquals("Test Group Name", groupNameView.getText());
|
||||
@@ -330,7 +336,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
|
||||
assertEquals(TEST_CHANNEL_NAME, textView.getText());
|
||||
}
|
||||
@@ -350,7 +357,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
|
||||
assertEquals(GONE, textView.getVisibility());
|
||||
}
|
||||
@@ -374,7 +382,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
|
||||
assertEquals(VISIBLE, textView.getVisibility());
|
||||
}
|
||||
@@ -394,7 +403,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
|
||||
assertEquals(VISIBLE, textView.getVisibility());
|
||||
}
|
||||
@@ -418,7 +428,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
|
||||
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
|
||||
settingsButton.performClick();
|
||||
@@ -441,7 +452,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
|
||||
assertTrue(settingsButton.getVisibility() != View.VISIBLE);
|
||||
}
|
||||
@@ -464,7 +476,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
|
||||
assertTrue(settingsButton.getVisibility() != View.VISIBLE);
|
||||
}
|
||||
@@ -484,7 +497,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
mNotificationInfo.bindNotification(
|
||||
mMockPackageManager,
|
||||
mMockINotificationManager,
|
||||
@@ -498,7 +512,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
|
||||
assertEquals(View.VISIBLE, settingsButton.getVisibility());
|
||||
}
|
||||
@@ -521,7 +536,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.info).performClick();
|
||||
// Verify that listener was triggered.
|
||||
@@ -545,7 +561,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView channelNameView =
|
||||
mNotificationInfo.findViewById(R.id.channel_name);
|
||||
assertEquals(GONE, channelNameView.getVisibility());
|
||||
@@ -567,7 +584,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
assertEquals(GONE, mNotificationInfo.findViewById(
|
||||
R.id.interruptiveness_settings).getVisibility());
|
||||
assertEquals(VISIBLE, mNotificationInfo.findViewById(
|
||||
@@ -589,7 +607,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
final TextView view = mNotificationInfo.findViewById(R.id.non_configurable_text);
|
||||
assertEquals(View.VISIBLE, view.getVisibility());
|
||||
assertEquals(mContext.getString(R.string.notification_unblockable_desc),
|
||||
@@ -598,6 +617,69 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
mNotificationInfo.findViewById(R.id.interruptiveness_settings).getVisibility());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindNotification_automaticIsVisible() throws Exception {
|
||||
mNotificationInfo.bindNotification(
|
||||
mMockPackageManager,
|
||||
mMockINotificationManager,
|
||||
mVisualStabilityManager,
|
||||
mChannelEditorDialogController,
|
||||
TEST_PACKAGE_NAME,
|
||||
mNotificationChannel,
|
||||
mNotificationChannelSet,
|
||||
mEntry,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true);
|
||||
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic).getVisibility());
|
||||
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindNotification_automaticIsGone() throws Exception {
|
||||
mNotificationInfo.bindNotification(
|
||||
mMockPackageManager,
|
||||
mMockINotificationManager,
|
||||
mVisualStabilityManager,
|
||||
mChannelEditorDialogController,
|
||||
TEST_PACKAGE_NAME,
|
||||
mNotificationChannel,
|
||||
mNotificationChannelSet,
|
||||
mEntry,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false);
|
||||
assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic).getVisibility());
|
||||
assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindNotification_automaticIsSelected() throws Exception {
|
||||
mNotificationChannel.unlockFields(USER_LOCKED_IMPORTANCE);
|
||||
mNotificationInfo.bindNotification(
|
||||
mMockPackageManager,
|
||||
mMockINotificationManager,
|
||||
mVisualStabilityManager,
|
||||
mChannelEditorDialogController,
|
||||
TEST_PACKAGE_NAME,
|
||||
mNotificationChannel,
|
||||
mNotificationChannelSet,
|
||||
mEntry,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true);
|
||||
assertTrue(mNotificationInfo.findViewById(R.id.automatic).isSelected());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindNotification_alertIsSelected() throws Exception {
|
||||
mNotificationInfo.bindNotification(
|
||||
@@ -613,7 +695,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
assertTrue(mNotificationInfo.findViewById(R.id.alert).isSelected());
|
||||
}
|
||||
|
||||
@@ -632,6 +715,7 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
assertTrue(mNotificationInfo.findViewById(R.id.silence).isSelected());
|
||||
}
|
||||
@@ -651,7 +735,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
|
||||
anyString(), eq(TEST_UID), any());
|
||||
@@ -673,6 +758,7 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.alert).performClick();
|
||||
@@ -698,7 +784,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.silence).performClick();
|
||||
mTestableLooper.processAllMessages();
|
||||
@@ -706,6 +793,32 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
anyString(), eq(TEST_UID), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoesNotUpdateNotificationChannelAfterImportanceChangedAutomatic()
|
||||
throws Exception {
|
||||
mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
|
||||
mNotificationInfo.bindNotification(
|
||||
mMockPackageManager,
|
||||
mMockINotificationManager,
|
||||
mVisualStabilityManager,
|
||||
mChannelEditorDialogController,
|
||||
TEST_PACKAGE_NAME,
|
||||
mNotificationChannel,
|
||||
mNotificationChannelSet,
|
||||
mEntry,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.automatic).performClick();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
|
||||
anyString(), eq(TEST_UID), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleCloseControls_DoesNotUpdateNotificationChannelIfUnchanged()
|
||||
throws Exception {
|
||||
@@ -723,7 +836,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
|
||||
mNotificationInfo.handleCloseControls(true, false);
|
||||
mTestableLooper.processAllMessages();
|
||||
@@ -749,7 +863,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
|
||||
mNotificationInfo.handleCloseControls(true, false);
|
||||
|
||||
@@ -775,7 +890,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.silence).performClick();
|
||||
mNotificationInfo.findViewById(R.id.done).performClick();
|
||||
@@ -807,6 +923,7 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.alert).performClick();
|
||||
@@ -823,6 +940,35 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
assertEquals(IMPORTANCE_DEFAULT, updated.getValue().getImportance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutomaticUnlocksUserImportance() throws Exception {
|
||||
mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
|
||||
mNotificationChannel.lockFields(USER_LOCKED_IMPORTANCE);
|
||||
mNotificationInfo.bindNotification(
|
||||
mMockPackageManager,
|
||||
mMockINotificationManager,
|
||||
mVisualStabilityManager,
|
||||
mChannelEditorDialogController,
|
||||
TEST_PACKAGE_NAME,
|
||||
mNotificationChannel,
|
||||
mNotificationChannelSet,
|
||||
mEntry,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.automatic).performClick();
|
||||
mNotificationInfo.findViewById(R.id.done).performClick();
|
||||
mNotificationInfo.handleCloseControls(true, false);
|
||||
|
||||
mTestableLooper.processAllMessages();
|
||||
assertTrue(mNotificationChannel.hasUserSetImportance());
|
||||
assertEquals(mNotificationChannel.getImportance(), IMPORTANCE_DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSilenceCallsUpdateNotificationChannel_channelImportanceUnspecified()
|
||||
throws Exception {
|
||||
@@ -840,7 +986,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.silence).performClick();
|
||||
mNotificationInfo.findViewById(R.id.done).performClick();
|
||||
@@ -873,6 +1020,7 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
assertEquals(mContext.getString(R.string.inline_done_button),
|
||||
@@ -909,6 +1057,7 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
assertEquals(mContext.getString(R.string.inline_done_button),
|
||||
@@ -944,7 +1093,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
true,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.silence).performClick();
|
||||
mNotificationInfo.findViewById(R.id.done).performClick();
|
||||
@@ -970,6 +1120,7 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
assertEquals(mContext.getString(R.string.inline_done_button),
|
||||
@@ -999,6 +1150,7 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.alert).performClick();
|
||||
@@ -1031,6 +1183,7 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.alert).performClick();
|
||||
@@ -1058,8 +1211,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
false,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.alert).performClick();
|
||||
mNotificationInfo.findViewById(R.id.done).performClick();
|
||||
@@ -1090,8 +1243,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
false,
|
||||
false);
|
||||
|
||||
mNotificationInfo.findViewById(R.id.alert).performClick();
|
||||
|
||||
@@ -1115,8 +1268,8 @@ public class NotificationInfoTest extends SysuiTestCase {
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
false,
|
||||
false);
|
||||
|
||||
assertFalse(mNotificationInfo.willBeRemoved());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user