diff --git a/res/drawable/ic_add_to_home.xml b/res/drawable/ic_add_to_home.xml
new file mode 100644
index 00000000000..1f55b7194cb
--- /dev/null
+++ b/res/drawable/ic_add_to_home.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
diff --git a/res/drawable/ic_create_bubble.xml b/res/drawable/ic_create_bubble.xml
new file mode 100644
index 00000000000..e9433553163
--- /dev/null
+++ b/res/drawable/ic_create_bubble.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/res/drawable/ic_demote_conversation.xml b/res/drawable/ic_demote_conversation.xml
new file mode 100644
index 00000000000..ef25bad859a
--- /dev/null
+++ b/res/drawable/ic_demote_conversation.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/ic_important_outline.xml b/res/drawable/ic_important_outline.xml
new file mode 100644
index 00000000000..7a628bb6543
--- /dev/null
+++ b/res/drawable/ic_important_outline.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/ic_notification_alert.xml b/res/drawable/ic_notification_alert.xml
index 927f7ccfc3c..c8efc7f4f16 100644
--- a/res/drawable/ic_notification_alert.xml
+++ b/res/drawable/ic_notification_alert.xml
@@ -14,28 +14,13 @@ Copyright (C) 2019 The Android Open Source Project
See the License for the specific language governing permissions and
limitations under the License.
-->
-
- -
-
-
-
-
-
- -
-
-
-
-
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/res/drawable/ic_notifications_alert.xml b/res/drawable/ic_notifications_alert.xml
index 5a25459e353..5df6b4fcae5 100644
--- a/res/drawable/ic_notifications_alert.xml
+++ b/res/drawable/ic_notifications_alert.xml
@@ -14,10 +14,10 @@ Copyright (C) 2019 The Android Open Source Project
limitations under the License.
-->
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
diff --git a/res/drawable/ic_promote_conversation.xml b/res/drawable/ic_promote_conversation.xml
new file mode 100644
index 00000000000..39f7658b700
--- /dev/null
+++ b/res/drawable/ic_promote_conversation.xml
@@ -0,0 +1,25 @@
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e8cff1f1008..f0b4daaa2a6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8051,6 +8051,8 @@
Some notifications and other content can appear as bubbles on the screen. To open a bubble, tap it. To dismiss it, drag it down the screen.
Bubbles
+
+ New messages will appear on screen
Allow %1$s to show some notifications as bubbles
@@ -8205,6 +8207,27 @@
%1$s: %2$s
+
+ Conversations
+
+
+ Conversation
+
+
+ "%1$s • %2$s"
+
+
+ Not a conversation
+
+
+ Remove from the conversation section
+
+
+ This is a conversation
+
+
+ Add to the conversation section
+
@@ -8526,11 +8549,17 @@
Blink light
- Vibrate
+ Vibration
Sound
+
+ Important
+
+
+ Add to home
+
Delete
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index d6122af9573..ceb08a26e32 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -29,6 +29,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index f749764a162..c8fb7e3aa6c 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -17,6 +17,8 @@ package com.android.settings.notification;
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
+import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC;
+import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED;
import android.app.INotificationManager;
import android.app.NotificationChannel;
@@ -29,13 +31,17 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
+import android.content.pm.LauncherApps;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
+import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutManager;
import android.graphics.drawable.Drawable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
+import android.service.notification.ConversationChannelWrapper;
import android.service.notification.NotifyingApp;
import android.text.format.DateUtils;
import android.util.IconDrawableFactory;
@@ -48,6 +54,7 @@ import com.android.settingslib.Utils;
import com.android.settingslib.utils.StringUtil;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -154,7 +161,7 @@ public class NotificationBackend {
try {
if (onlyHasDefaultChannel(pkg, uid)) {
NotificationChannel defaultChannel =
- getChannel(pkg, uid, NotificationChannel.DEFAULT_CHANNEL_ID);
+ getChannel(pkg, uid, NotificationChannel.DEFAULT_CHANNEL_ID, null);
defaultChannel.setImportance(enabled ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_NONE);
updateChannel(pkg, uid, defaultChannel);
}
@@ -204,13 +211,17 @@ public class NotificationBackend {
}
}
-
public NotificationChannel getChannel(String pkg, int uid, String channelId) {
+ return getChannel(pkg, uid, channelId, null);
+ }
+
+ public NotificationChannel getChannel(String pkg, int uid, String channelId,
+ String conversationId) {
if (channelId == null) {
return null;
}
try {
- return sINM.getNotificationChannelForPackage(pkg, uid, channelId, true);
+ return sINM.getNotificationChannelForPackage(pkg, uid, channelId, conversationId, true);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
return null;
@@ -238,6 +249,15 @@ public class NotificationBackend {
}
}
+ public ParceledListSlice getConversations(String pkg, int uid) {
+ try {
+ return sINM.getConversationsForPackage(pkg, uid);
+ } catch (Exception e) {
+ Log.w(TAG, "Error calling NoMan", e);
+ return ParceledListSlice.emptyList();
+ }
+ }
+
/**
* Returns all notification channels associated with the package and uid that will bypass DND
*/
@@ -474,6 +494,32 @@ public class NotificationBackend {
}
}
+ public ShortcutInfo getConversationInfo(Context context, String pkg, int uid, String id) {
+ LauncherApps la = context.getSystemService(LauncherApps.class);
+
+ LauncherApps.ShortcutQuery query = new LauncherApps.ShortcutQuery()
+ .setPackage(pkg)
+ .setQueryFlags(FLAG_MATCH_DYNAMIC | FLAG_MATCH_PINNED)
+ .setShortcutIds(Arrays.asList(id));
+ List shortcuts = la.getShortcuts(
+ query, UserHandle.of(UserHandle.getUserId(uid)));
+ if (shortcuts != null && !shortcuts.isEmpty()) {
+ return shortcuts.get(0);
+ }
+ return null;
+ }
+
+ public Drawable getConversationDrawable(Context context, ShortcutInfo info) {
+ LauncherApps la = context.getSystemService(LauncherApps.class);
+ return la.getShortcutBadgedIconDrawable(info,
+ context.getResources().getDisplayMetrics().densityDpi);
+ }
+
+ public void requestPinShortcut(Context context, ShortcutInfo shortcutInfo) {
+ ShortcutManager sm = context.getSystemService(ShortcutManager.class);
+ sm.requestPinShortcut(shortcutInfo, null);
+ }
+
/**
* NotificationsSentState contains how often an app sends notifications and how recently it sent
* one.
diff --git a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
new file mode 100644
index 00000000000..15b838843a7
--- /dev/null
+++ b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import android.content.Context;
+import android.util.Slog;
+
+import androidx.preference.Preference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+
+public class AddToHomeScreenPreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin {
+
+ private static final String TAG = "HomeScreenPref";
+ private static final String KEY = "add_to_home";
+
+ public AddToHomeScreenPreferenceController(Context context, NotificationBackend backend) {
+ super(context, backend);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ return mConversationInfo != null;
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (KEY.equals(preference.getKey())) {
+ try {
+ mBackend.requestPinShortcut(mContext, mConversationInfo);
+ return true;
+ } catch (SecurityException e) {
+ Slog.e(TAG, "Cannot add to home screen", e);
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
index fdb257e130c..0ed1b84bdc5 100644
--- a/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
+++ b/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
@@ -84,7 +84,7 @@ public class AppBubbleNotificationSettings extends NotificationSettings implemen
}
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
diff --git a/src/com/android/settings/notification/app/AppNotificationSettings.java b/src/com/android/settings/notification/app/AppNotificationSettings.java
index 7f6c4ab9fa8..e6ccd8915d8 100644
--- a/src/com/android/settings/notification/app/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/app/AppNotificationSettings.java
@@ -80,7 +80,7 @@ public class AppNotificationSettings extends NotificationSettings {
}
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
@@ -123,6 +123,7 @@ public class AppNotificationSettings extends NotificationSettings {
mControllers.add(new DeletedChannelsPreferenceController(context, mBackend));
mControllers.add(new BubbleSummaryPreferenceController(context, mBackend));
mControllers.add(new ChannelListPreferenceController(context, mBackend));
+ mControllers.add(new ConversationListPreferenceController(context, mBackend));
return new ArrayList<>(mControllers);
}
}
diff --git a/src/com/android/settings/notification/app/BubblePreferenceController.java b/src/com/android/settings/notification/app/BubblePreferenceController.java
index 930bab3ab5b..879f17af9e7 100644
--- a/src/com/android/settings/notification/app/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/app/BubblePreferenceController.java
@@ -22,15 +22,15 @@ import android.annotation.Nullable;
import android.content.Context;
import android.provider.Settings;
+import androidx.annotation.VisibleForTesting;
+import androidx.fragment.app.FragmentManager;
+import androidx.preference.Preference;
+
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedSwitchPreference;
-import androidx.annotation.VisibleForTesting;
-import androidx.fragment.app.FragmentManager;
-import androidx.preference.Preference;
-
public class BubblePreferenceController extends NotificationPreferenceController
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
diff --git a/src/com/android/settings/notification/app/ChannelListPreferenceController.java b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
index 7cf836ab0c5..187e7e1ea5c 100644
--- a/src/com/android/settings/notification/app/ChannelListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
@@ -31,6 +31,7 @@ import android.graphics.drawable.LayerDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Settings;
+import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -132,9 +133,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
groupCategory.setOrderingAsAdded(true);
mPreference.addPreference(groupCategory);
if (group.getId() == null) {
- if (mChannelGroupList.size() > 1) {
- groupCategory.setTitle(R.string.notification_channels_other);
- }
+ groupCategory.setTitle(R.string.notification_channels_other);
groupCategory.setKey(KEY_GENERAL_CATEGORY);
} else {
groupCategory.setTitle(group.getName());
@@ -147,7 +146,10 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
int N = channels.size();
for (int i = 0; i < N; i++) {
final NotificationChannel channel = channels.get(i);
- populateSingleChannelPrefs(groupCategory, channel, group.isBlocked());
+ // conversations get their own section
+ if (TextUtils.isEmpty(channel.getConversationId()) || channel.isDemoted()) {
+ populateSingleChannelPrefs(groupCategory, channel, group.isBlocked());
+ }
}
}
}
diff --git a/src/com/android/settings/notification/app/ChannelNotificationSettings.java b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
index b4d67b97dcb..b5212c94c8c 100644
--- a/src/com/android/settings/notification/app/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
@@ -30,6 +30,7 @@ import androidx.preference.PreferenceScreen;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
+import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.ArrayList;
@@ -65,8 +66,20 @@ public class ChannelNotificationSettings extends NotificationSettings {
return;
}
+ if (mChannel != null && !TextUtils.isEmpty(mChannel.getConversationId())
+ && !mChannel.isDemoted()) {
+ startActivity(new SubSettingLauncher(mContext)
+ .setDestination(ConversationNotificationSettings.class.getName())
+ .setArguments(getArguments())
+ .setExtras(getIntent() != null ? getIntent().getExtras(): null)
+ .setSourceMetricsCategory(SettingsEnums.NOTIFICATION_TOPIC_NOTIFICATION)
+ .toIntent());
+ finish();
+ return;
+ }
+
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
@@ -118,6 +131,7 @@ public class ChannelNotificationSettings extends NotificationSettings {
mControllers.add(new NotificationsOffPreferenceController(context));
mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
mBackend, false /* isAppPage */));
+ mControllers.add(new ConversationPromotePreferenceController(context, this, mBackend));
return new ArrayList<>(mControllers);
}
}
diff --git a/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
new file mode 100644
index 00000000000..6583a23b151
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import android.content.Context;
+import android.text.TextUtils;
+
+import androidx.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+public class ConversationDemotePreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin {
+
+ private static final String KEY = "demote";
+
+ SettingsPreferenceFragment mHostFragment;
+
+ public ConversationDemotePreferenceController(Context context,
+ SettingsPreferenceFragment hostFragment,
+ NotificationBackend backend) {
+ super(context, backend);
+ mHostFragment = hostFragment;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ if (mAppRow == null || mChannel == null) {
+ return false;
+ }
+ return !TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted();
+ }
+
+ public void updateState(Preference preference) {
+ preference.setEnabled(mAdmin == null);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (KEY.equals(preference.getKey())) {
+ mChannel.setDemoted(true);
+ saveChannel();
+
+ mHostFragment.getActivity().finish();
+
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
new file mode 100644
index 00000000000..369f3af92e7
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
@@ -0,0 +1,129 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import static com.android.settings.widget.EntityHeaderController.PREF_KEY_APP_HEADER;
+
+import android.app.Activity;
+import android.content.Context;
+import android.text.BidiFormatter;
+import android.text.SpannableStringBuilder;
+import android.text.TextUtils;
+import android.view.View;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.widget.EntityHeaderController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.widget.LayoutPreference;
+
+public class ConversationHeaderPreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin, LifecycleObserver {
+
+ private final DashboardFragment mFragment;
+ private EntityHeaderController mHeaderController;
+ private boolean mStarted = false;
+
+ public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment) {
+ super(context, null);
+ mFragment = fragment;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return PREF_KEY_APP_HEADER;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return mAppRow != null;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ if (mAppRow != null && mFragment != null) {
+
+ Activity activity = null;
+ if (mStarted) {
+ // don't call done on an activity if it hasn't started yet
+ activity = mFragment.getActivity();
+ }
+
+ if (activity == null) {
+ return;
+ }
+
+ LayoutPreference pref = (LayoutPreference) preference;
+ mHeaderController = EntityHeaderController.newInstance(
+ activity, mFragment, pref.findViewById(R.id.entity_header));
+ pref = mHeaderController.setIcon(mConversationDrawable)
+ .setLabel(getLabel())
+ .setSummary(getSummary())
+ .setPackageName(mAppRow.pkg)
+ .setUid(mAppRow.uid)
+ .setButtonActions(EntityHeaderController.ActionType.ACTION_NOTIF_PREFERENCE,
+ EntityHeaderController.ActionType.ACTION_NONE)
+ .setHasAppInfoLink(true)
+ .setRecyclerView(mFragment.getListView(), mFragment.getSettingsLifecycle())
+ .done(activity, mContext);
+ pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
+ }
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ if (mChannel != null && !isDefaultChannel()) {
+ if (mChannelGroup != null
+ && !TextUtils.isEmpty(mChannelGroup.getName())) {
+ final SpannableStringBuilder summary = new SpannableStringBuilder();
+ BidiFormatter bidi = BidiFormatter.getInstance();
+ summary.append(bidi.unicodeWrap(mAppRow.label.toString()));
+ summary.append(bidi.unicodeWrap(mContext.getText(
+ R.string.notification_header_divider_symbol_with_spaces)));
+ summary.append(bidi.unicodeWrap(mChannelGroup.getName().toString()));
+ return summary.toString();
+ } else {
+ return mAppRow.label.toString();
+ }
+ } else if (mChannelGroup != null) {
+ return mAppRow.label.toString();
+ } else {
+ return "";
+ }
+ }
+
+ @OnLifecycleEvent(Lifecycle.Event.ON_START)
+ public void onStart() {
+ mStarted = true;
+ if (mHeaderController != null) {
+ mHeaderController.styleActionBar(mFragment.getActivity());
+ }
+ }
+
+ @VisibleForTesting
+ CharSequence getLabel() {
+ return mConversationInfo != null
+ ? mConversationInfo.getShortLabel()
+ : mChannel.getName();
+ }
+}
diff --git a/src/com/android/settings/notification/app/ConversationImportantPreferenceController.java b/src/com/android/settings/notification/app/ConversationImportantPreferenceController.java
new file mode 100644
index 00000000000..71fa23158fe
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationImportantPreferenceController.java
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import android.content.Context;
+
+import androidx.preference.Preference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+public class ConversationImportantPreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+ private static final String TAG = "ConvoImpPC";
+ private static final String KEY = "important";
+
+ public ConversationImportantPreferenceController(Context context,
+ NotificationBackend backend) {
+ super(context, backend);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ if (mAppRow == null || mChannel == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public void updateState(Preference preference) {
+ if (mAppRow != null) {
+ RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
+ pref.setDisabledByAdmin(mAdmin);
+ pref.setChecked(mChannel.isImportantConversation());
+ pref.setEnabled(!pref.isDisabledByAdmin());
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mChannel == null) {
+ return false;
+ }
+ final boolean value = (Boolean) newValue;
+ mChannel.setImportantConversation(value);
+ saveChannel();
+
+ return true;
+ }
+}
diff --git a/src/com/android/settings/notification/app/ConversationListPreferenceController.java b/src/com/android/settings/notification/app/ConversationListPreferenceController.java
new file mode 100644
index 00000000000..fa1b0504c44
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationListPreferenceController.java
@@ -0,0 +1,163 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import android.app.NotificationChannel;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.pm.ShortcutInfo;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.service.notification.ConversationChannelWrapper;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+
+import com.android.settings.R;
+import com.android.settings.applications.AppInfoBase;
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.notification.NotificationBackend;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class ConversationListPreferenceController extends NotificationPreferenceController {
+
+ private static final String KEY = "conversations";
+ public static final String ARG_FROM_SETTINGS = "fromSettings";
+
+ private List mConversations;
+ private PreferenceCategory mPreference;
+
+ public ConversationListPreferenceController(Context context, NotificationBackend backend) {
+ super(context, backend);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (mAppRow == null) {
+ return false;
+ }
+ if (mAppRow.banned) {
+ return false;
+ }
+ if (mChannel != null) {
+ if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
+ || NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ mPreference = (PreferenceCategory) preference;
+ // Load channel settings
+ new AsyncTask() {
+ @Override
+ protected Void doInBackground(Void... unused) {
+ mConversations = mBackend.getConversations(mAppRow.pkg, mAppRow.uid).getList();
+ Collections.sort(mConversations, mConversationComparator);
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void unused) {
+ if (mContext == null) {
+ return;
+ }
+ populateList();
+ }
+ }.execute();
+ }
+
+ private void populateList() {
+ // TODO: if preference has children, compare with newly loaded list
+ mPreference.removeAll();
+ mPreference.setTitle(R.string.conversations_category_title);
+
+ if (mConversations.isEmpty()) {
+ mPreference.setVisible(false);
+ } else {
+ mPreference.setVisible(true);
+ populateConversations();
+ }
+ }
+
+ private void populateConversations() {
+ for (ConversationChannelWrapper conversation : mConversations) {
+ if (conversation.getNotificationChannel().isDemoted()) {
+ continue;
+ }
+ mPreference.addPreference(createConversationPref(conversation));
+ }
+ }
+
+ protected Preference createConversationPref(final ConversationChannelWrapper conversation) {
+ Preference pref = new Preference(mContext);
+ ShortcutInfo si = conversation.getShortcutInfo();
+
+ pref.setTitle(si != null
+ ? si.getShortLabel()
+ : conversation.getNotificationChannel().getName());
+ pref.setSummary(conversation.getNotificationChannel().getGroup() != null
+ ? mContext.getString(R.string.notification_conversation_summary,
+ conversation.getParentChannelLabel(), conversation.getGroupLabel())
+ : conversation.getParentChannelLabel());
+ if (si != null) {
+ pref.setIcon(mBackend.getConversationDrawable(mContext, si));
+ }
+ pref.setKey(conversation.getNotificationChannel().getId());
+
+ Bundle channelArgs = new Bundle();
+ channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mAppRow.uid);
+ channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mAppRow.pkg);
+ channelArgs.putString(Settings.EXTRA_CHANNEL_ID,
+ conversation.getNotificationChannel().getParentChannelId());
+ channelArgs.putString(Settings.EXTRA_CONVERSATION_ID,
+ conversation.getNotificationChannel().getConversationId());
+ channelArgs.putBoolean(ARG_FROM_SETTINGS, true);
+ pref.setIntent(new SubSettingLauncher(mContext)
+ .setDestination(ChannelNotificationSettings.class.getName())
+ .setArguments(channelArgs)
+ .setExtras(channelArgs)
+ .setTitleText(pref.getTitle())
+ .setSourceMetricsCategory(SettingsEnums.NOTIFICATION_APP_NOTIFICATION)
+ .toIntent());
+ return pref;
+ }
+
+ protected Comparator mConversationComparator =
+ (left, right) -> {
+ if (left.getNotificationChannel().isImportantConversation()
+ != right.getNotificationChannel().isImportantConversation()) {
+ // important first
+ return Boolean.compare(right.getNotificationChannel().isImportantConversation(),
+ left.getNotificationChannel().isImportantConversation());
+ }
+ return left.getNotificationChannel().getId().compareTo(
+ right.getNotificationChannel().getId());
+ };
+}
diff --git a/src/com/android/settings/notification/app/ConversationNotificationSettings.java b/src/com/android/settings/notification/app/ConversationNotificationSettings.java
new file mode 100644
index 00000000000..3f250378a1a
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationNotificationSettings.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.Intent;
+import android.preference.PreferenceManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.R;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ConversationNotificationSettings extends NotificationSettings {
+ private static final String TAG = "ConvoSettings";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.NOTIFICATION_CONVERSATION_SETTINGS;
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mChannel == null) {
+ Log.w(TAG, "Missing package or uid or packageinfo or channel");
+ finish();
+ return;
+ }
+
+ for (NotificationPreferenceController controller : mControllers) {
+ controller.onResume(mAppRow, mChannel, mChannelGroup, mConversationDrawable,
+ mConversationInfo, mSuspendedAppsAdmin);
+ controller.displayPreference(getPreferenceScreen());
+ }
+ updatePreferenceStates();
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ for (NotificationPreferenceController controller : mControllers) {
+ if (controller instanceof PreferenceManager.OnActivityResultListener) {
+ ((PreferenceManager.OnActivityResultListener) controller)
+ .onActivityResult(requestCode, resultCode, data);
+ }
+ }
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.conversation_notification_settings;
+ }
+
+ @Override
+ protected List createPreferenceControllers(Context context) {
+ mControllers = new ArrayList<>();
+ mControllers.add(new ConversationHeaderPreferenceController(context, this));
+ mControllers.add(new ConversationImportantPreferenceController(context, mBackend));
+ mControllers.add(new DefaultImportancePreferenceController(
+ context, mImportanceListener, mBackend));
+ mControllers.add(new AddToHomeScreenPreferenceController(context, mBackend));
+ mControllers.add(new HighImportancePreferenceController(
+ context, mImportanceListener, mBackend));
+ mControllers.add(new SoundPreferenceController(context, this,
+ mImportanceListener, mBackend));
+ mControllers.add(new VibrationPreferenceController(context, mBackend));
+ mControllers.add(new AppLinkPreferenceController(context));
+ mControllers.add(new DescriptionPreferenceController(context));
+ mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context),
+ mBackend));
+ mControllers.add(new LightsPreferenceController(context, mBackend));
+ mControllers.add(new BadgePreferenceController(context, mBackend));
+ mControllers.add(new NotificationsOffPreferenceController(context));
+ mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
+ mBackend, false /* isAppPage */));
+ mControllers.add(new ConversationDemotePreferenceController(context, this, mBackend));
+ return new ArrayList<>(mControllers);
+ }
+}
diff --git a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
new file mode 100644
index 00000000000..5ef92469625
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import android.content.Context;
+import android.text.TextUtils;
+
+import androidx.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+public class ConversationPromotePreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin {
+
+ private static final String KEY = "convo_promote";
+
+ SettingsPreferenceFragment mHostFragment;
+
+ public ConversationPromotePreferenceController(Context context,
+ SettingsPreferenceFragment hostFragment,
+ NotificationBackend backend) {
+ super(context, backend);
+ mHostFragment = hostFragment;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ if (mAppRow == null || mChannel == null) {
+ return false;
+ }
+ return !TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted();
+ }
+
+ public void updateState(Preference preference) {
+ preference.setEnabled(mAdmin == null);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (mChannel == null) {
+ return false;
+ }
+ mChannel.setDemoted(false);
+ saveChannel();
+
+ if (mHostFragment != null) {
+ mHostFragment.getActivity().finish();
+ }
+
+ return true;
+ }
+}
diff --git a/src/com/android/settings/notification/app/DefaultImportancePreferenceController.java b/src/com/android/settings/notification/app/DefaultImportancePreferenceController.java
new file mode 100644
index 00000000000..e6641019835
--- /dev/null
+++ b/src/com/android/settings/notification/app/DefaultImportancePreferenceController.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_LOW;
+
+import android.app.NotificationChannel;
+import android.content.Context;
+
+import androidx.preference.Preference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+public class DefaultImportancePreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+ private static final String KEY = "alerting";
+ private NotificationSettings.ImportanceListener mImportanceListener;
+
+ public DefaultImportancePreferenceController(Context context,
+ NotificationSettings.ImportanceListener importanceListener,
+ NotificationBackend backend) {
+ super(context, backend);
+ mImportanceListener = importanceListener;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ if (mChannel == null) {
+ return false;
+ }
+ if (isDefaultChannel()) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ if (mAppRow != null && mChannel != null) {
+ preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
+
+ RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
+ pref.setChecked(mChannel.getImportance() >= IMPORTANCE_DEFAULT);
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mChannel != null) {
+ final boolean checked = (boolean) newValue;
+
+ mChannel.setImportance(checked ? IMPORTANCE_DEFAULT : IMPORTANCE_LOW);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+ saveChannel();
+ mImportanceListener.onImportanceChanged();
+ }
+ return true;
+ }
+}
diff --git a/src/com/android/settings/notification/app/NotificationPreferenceController.java b/src/com/android/settings/notification/app/NotificationPreferenceController.java
index e82f420766c..be1ce1bda5b 100644
--- a/src/com/android/settings/notification/app/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/app/NotificationPreferenceController.java
@@ -24,6 +24,8 @@ import android.app.NotificationChannelGroup;
import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.pm.ShortcutInfo;
+import android.graphics.drawable.Drawable;
import android.os.UserManager;
import android.util.Log;
@@ -53,6 +55,10 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
protected final UserManager mUm;
protected final PackageManager mPm;
protected Preference mPreference;
+ @Nullable
+ protected Drawable mConversationDrawable;
+ @Nullable
+ protected ShortcutInfo mConversationInfo;
public NotificationPreferenceController(Context context, NotificationBackend backend) {
super(context);
@@ -87,11 +93,15 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
protected void onResume(NotificationBackend.AppRow appRow,
@Nullable NotificationChannel channel, @Nullable NotificationChannelGroup group,
+ Drawable conversationDrawable,
+ ShortcutInfo conversationInfo,
RestrictedLockUtils.EnforcedAdmin admin) {
mAppRow = appRow;
mChannel = channel;
mChannelGroup = group;
mAdmin = admin;
+ mConversationDrawable = conversationDrawable;
+ mConversationInfo = conversationInfo;
}
protected boolean checkCanBeVisible(int minImportanceVisible) {
diff --git a/src/com/android/settings/notification/app/NotificationSettings.java b/src/com/android/settings/notification/app/NotificationSettings.java
index 79b256721fc..983ad2b20c4 100644
--- a/src/com/android/settings/notification/app/NotificationSettings.java
+++ b/src/com/android/settings/notification/app/NotificationSettings.java
@@ -32,6 +32,8 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
+import android.content.pm.ShortcutInfo;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
@@ -46,8 +48,6 @@ import com.android.settings.SettingsActivity;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.HeaderPreferenceController;
-import com.android.settings.notification.app.NotificationPreferenceController;
import com.android.settingslib.RestrictedLockUtilsInternal;
import java.util.ArrayList;
@@ -71,6 +71,8 @@ abstract public class NotificationSettings extends DashboardFragment {
protected NotificationChannelGroup mChannelGroup;
protected NotificationChannel mChannel;
protected NotificationBackend.AppRow mAppRow;
+ protected Drawable mConversationDrawable;
+ protected ShortcutInfo mConversationInfo;
protected boolean mShowLegacyChannelConfig = false;
protected boolean mListeningToPackageRemove;
@@ -118,10 +120,17 @@ abstract public class NotificationSettings extends DashboardFragment {
loadChannelGroup();
collectConfigActivities();
- getSettingsLifecycle().addObserver(use(HeaderPreferenceController.class));
+ if (use(HeaderPreferenceController.class) != null) {
+ getSettingsLifecycle().addObserver(use(HeaderPreferenceController.class));
+ }
+ if (use(ConversationHeaderPreferenceController.class) != null) {
+ getSettingsLifecycle().addObserver(
+ use(ConversationHeaderPreferenceController.class));
+ }
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null,
+ mSuspendedAppsAdmin);
}
}
}
@@ -169,6 +178,7 @@ abstract public class NotificationSettings extends DashboardFragment {
return;
}
loadChannel();
+ loadConversation();
loadChannelGroup();
collectConfigActivities();
}
@@ -180,7 +190,21 @@ abstract public class NotificationSettings extends DashboardFragment {
Bundle args = intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
channelId = args != null ? args.getString(Settings.EXTRA_CHANNEL_ID) : null;
}
- mChannel = mBackend.getChannel(mPkg, mUid, channelId);
+ String conversationId = intent != null
+ ? intent.getStringExtra(Settings.EXTRA_CONVERSATION_ID) : null;
+ mChannel = mBackend.getChannel(mPkg, mUid, channelId, conversationId);
+ }
+
+ private void loadConversation() {
+ if (mChannel == null || TextUtils.isEmpty(mChannel.getConversationId())
+ || mChannel.isDemoted()) {
+ return;
+ }
+ mConversationInfo = mBackend.getConversationInfo(
+ mContext, mPkg, mUid, mChannel.getConversationId());
+ if (mConversationInfo != null) {
+ mConversationDrawable = mBackend.getConversationDrawable(mContext, mConversationInfo);
+ }
}
private void loadAppRow() {
@@ -194,7 +218,7 @@ abstract public class NotificationSettings extends DashboardFragment {
if (mShowLegacyChannelConfig) {
mChannel = mBackend.getChannel(
- mAppRow.pkg, mAppRow.uid, NotificationChannel.DEFAULT_CHANNEL_ID);
+ mAppRow.pkg, mAppRow.uid, NotificationChannel.DEFAULT_CHANNEL_ID, null);
}
if (mChannel != null && !TextUtils.isEmpty(mChannel.getGroup())) {
NotificationChannelGroup group = mBackend.getGroup(mPkg, mUid, mChannel.getGroup());
diff --git a/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java
new file mode 100644
index 00000000000..342f3ad077d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.pm.ShortcutInfo;
+
+import androidx.preference.Preference;
+
+import com.android.settings.notification.NotificationBackend;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class AddToHomeScreenPreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationBackend mBackend;
+
+ private AddToHomeScreenPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new AddToHomeScreenPreferenceController(mContext, mBackend);
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notIfNull() {
+ mController.onResume(null, null, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, si, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testHandlePreferenceTreeClick() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, si, null);
+
+ Preference pref = new Preference(RuntimeEnvironment.application);
+ pref.setKey("add_to_home");
+ mController.handlePreferenceTreeClick(pref);
+
+ verify(mBackend).requestPinShortcut(any(), eq(si));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
index d8292862cde..e121cfe4a63 100644
--- a/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
@@ -92,10 +92,10 @@ public class AllowSoundPreferenceControllerTest {
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, mock(NotificationChannel.class), null, null);
+ mController.onResume(null, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
- mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -103,7 +103,7 @@ public class AllowSoundPreferenceControllerTest {
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -112,7 +112,7 @@ public class AllowSoundPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something new");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -122,7 +122,7 @@ public class AllowSoundPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -130,7 +130,7 @@ public class AllowSoundPreferenceControllerTest {
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext);
@@ -145,7 +145,7 @@ public class AllowSoundPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("");
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -158,7 +158,7 @@ public class AllowSoundPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -170,7 +170,7 @@ public class AllowSoundPreferenceControllerTest {
public void testUpdateState_checkedForHighImportanceChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -181,7 +181,7 @@ public class AllowSoundPreferenceControllerTest {
public void testUpdateState_checkedForUnspecifiedImportanceChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_UNSPECIFIED);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -192,7 +192,7 @@ public class AllowSoundPreferenceControllerTest {
public void testUpdateState_notCheckedForLowImportanceChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -203,7 +203,7 @@ public class AllowSoundPreferenceControllerTest {
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -220,7 +220,7 @@ public class AllowSoundPreferenceControllerTest {
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java
index c48f142bfeb..41aeacbc03f 100644
--- a/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java
@@ -36,7 +36,6 @@ import android.os.UserManager;
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.AppLinkPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -76,7 +75,7 @@ public class AppLinkPreferenceControllerTest {
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -84,7 +83,7 @@ public class AppLinkPreferenceControllerTest {
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -93,7 +92,7 @@ public class AppLinkPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -103,7 +102,7 @@ public class AppLinkPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -114,7 +113,7 @@ public class AppLinkPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -123,7 +122,7 @@ public class AppLinkPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
Intent intent = new Intent("action");
appRow.settingsIntent = intent;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java
index 5dfd393095b..277e6b2dd7e 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java
@@ -44,7 +44,6 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.BadgePreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -94,7 +93,7 @@ public class BadgePreferenceControllerTest {
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -103,7 +102,7 @@ public class BadgePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -113,7 +112,7 @@ public class BadgePreferenceControllerTest {
appRow.showBadge = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -123,7 +122,7 @@ public class BadgePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 0);
assertFalse(mController.isAvailable());
@@ -132,7 +131,7 @@ public class BadgePreferenceControllerTest {
@Test
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertTrue(mController.isAvailable());
@@ -145,7 +144,7 @@ public class BadgePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertTrue(mController.isAvailable());
@@ -157,7 +156,7 @@ public class BadgePreferenceControllerTest {
appRow.showBadge = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertTrue(mController.isAvailable());
@@ -169,7 +168,7 @@ public class BadgePreferenceControllerTest {
appRow.showBadge = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertFalse(mController.isAvailable());
@@ -180,7 +179,7 @@ public class BadgePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null,
- mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -194,7 +193,7 @@ public class BadgePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("");
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -207,7 +206,7 @@ public class BadgePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canShowBadge()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -215,7 +214,7 @@ public class BadgePreferenceControllerTest {
assertTrue(pref.isChecked());
when(channel.canShowBadge()).thenReturn(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -225,14 +224,14 @@ public class BadgePreferenceControllerTest {
public void testUpdateState_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.showBadge = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
assertTrue(pref.isChecked());
appRow.showBadge = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -245,7 +244,7 @@ public class BadgePreferenceControllerTest {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setShowBadge(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -264,7 +263,7 @@ public class BadgePreferenceControllerTest {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
channel.setShowBadge(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -280,7 +279,7 @@ public class BadgePreferenceControllerTest {
public void testOnPreferenceChange_on_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.showBadge = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -297,7 +296,7 @@ public class BadgePreferenceControllerTest {
public void testOnPreferenceChange_off_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.showBadge = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
index d819a186de1..e73ee5a3d3a 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
@@ -45,8 +45,6 @@ import android.os.UserManager;
import com.android.settings.R;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.BlockPreferenceController;
-import com.android.settings.notification.app.NotificationSettings;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.widget.LayoutPreference;
@@ -99,7 +97,7 @@ public class BlockPreferenceControllerTest {
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -109,7 +107,7 @@ public class BlockPreferenceControllerTest {
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -119,7 +117,7 @@ public class BlockPreferenceControllerTest {
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -129,7 +127,7 @@ public class BlockPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -137,7 +135,7 @@ public class BlockPreferenceControllerTest {
public void testIsAvailable_GroupNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null);
+ mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null);
assertTrue(mController.isAvailable());
}
@@ -145,7 +143,7 @@ public class BlockPreferenceControllerTest {
public void testIsAvailable_AppNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -155,7 +153,7 @@ public class BlockPreferenceControllerTest {
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -165,7 +163,7 @@ public class BlockPreferenceControllerTest {
appRow.systemApp = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -174,7 +172,7 @@ public class BlockPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedImportance = true;
appRow.systemApp = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isEnabled());
}
@@ -183,7 +181,7 @@ public class BlockPreferenceControllerTest {
public void testIsEnabled_GroupNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null);
+ mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isEnabled());
}
@@ -192,7 +190,7 @@ public class BlockPreferenceControllerTest {
public void testIsEnabled_systemAppNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isEnabled());
}
@@ -203,7 +201,7 @@ public class BlockPreferenceControllerTest {
appRow.systemApp = true;
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setBlockableSystem(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mSwitch.isEnabled());
}
@@ -214,7 +212,7 @@ public class BlockPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
@@ -227,7 +225,7 @@ public class BlockPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
@@ -239,7 +237,7 @@ public class BlockPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
@@ -249,7 +247,7 @@ public class BlockPreferenceControllerTest {
@Test
public void testIsEnabled_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
@@ -260,7 +258,7 @@ public class BlockPreferenceControllerTest {
public void testUpdateState_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
assertNotNull(mPreference.findViewById(R.id.switch_bar));
@@ -268,7 +266,7 @@ public class BlockPreferenceControllerTest {
assertFalse(mSwitch.isChecked());
appRow.banned = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mSwitch.isChecked());
@@ -279,20 +277,20 @@ public class BlockPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = true;
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
when(group.isBlocked()).thenReturn(true);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = false;
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
when(group.isBlocked()).thenReturn(false);
mController.updateState(mPreference);
@@ -303,21 +301,21 @@ public class BlockPreferenceControllerTest {
public void testUpdateState_channelBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = true;
channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = false;
channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mSwitch.isChecked());
@@ -327,7 +325,7 @@ public class BlockPreferenceControllerTest {
public void testUpdateState_noCrashIfCalledTwice() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
mController.updateState(mPreference);
}
@@ -336,7 +334,7 @@ public class BlockPreferenceControllerTest {
public void testUpdateState_doesNotResetImportance() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertEquals(IMPORTANCE_LOW, channel.getImportance());
@@ -349,7 +347,7 @@ public class BlockPreferenceControllerTest {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_UNSPECIFIED);
when(mBackend.onlyHasDefaultChannel(anyString(), anyInt())).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
mController.onSwitchChanged(null, false);
@@ -370,7 +368,7 @@ public class BlockPreferenceControllerTest {
public void testOnSwitchChanged_channel_nonDefault() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
mController.onSwitchChanged(null, false);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java
index 5fd51235a91..404625efde2 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java
@@ -45,7 +45,6 @@ import android.os.UserManager;
import android.provider.Settings;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.BubblePreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -108,7 +107,7 @@ public class BubblePreferenceControllerTest {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -118,7 +117,7 @@ public class BubblePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -129,7 +128,7 @@ public class BubblePreferenceControllerTest {
appRow.allowBubbles = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -137,7 +136,7 @@ public class BubblePreferenceControllerTest {
@Test
public void testIsNotAvailable_ifOffGlobally_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
@@ -149,7 +148,7 @@ public class BubblePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
@@ -159,7 +158,7 @@ public class BubblePreferenceControllerTest {
@Test
public void testIsAvailable_app_evenIfOffGlobally() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mAppPageController.onResume(appRow, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
@@ -169,7 +168,7 @@ public class BubblePreferenceControllerTest {
@Test
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -182,7 +181,7 @@ public class BubblePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -194,7 +193,7 @@ public class BubblePreferenceControllerTest {
appRow.allowBubbles = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -206,7 +205,7 @@ public class BubblePreferenceControllerTest {
appRow.allowBubbles = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertFalse(mController.isAvailable());
@@ -217,7 +216,7 @@ public class BubblePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null,
- mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -231,7 +230,7 @@ public class BubblePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -245,7 +244,7 @@ public class BubblePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBubble()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -253,7 +252,7 @@ public class BubblePreferenceControllerTest {
assertTrue(pref.isChecked());
when(channel.canBubble()).thenReturn(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -265,14 +264,14 @@ public class BubblePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "App!";
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
assertTrue(pref.isChecked());
appRow.allowBubbles = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -288,7 +287,7 @@ public class BubblePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "App!";
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -303,7 +302,7 @@ public class BubblePreferenceControllerTest {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setAllowBubbles(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -323,7 +322,7 @@ public class BubblePreferenceControllerTest {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
channel.setAllowBubbles(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -340,7 +339,7 @@ public class BubblePreferenceControllerTest {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -358,7 +357,7 @@ public class BubblePreferenceControllerTest {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -377,7 +376,7 @@ public class BubblePreferenceControllerTest {
SYSTEM_WIDE_OFF);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java
index 1bd960009f8..80abfbb5f20 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java
@@ -40,7 +40,6 @@ import android.content.Context;
import android.provider.Settings;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.BubbleSummaryPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -80,7 +79,7 @@ public class BubbleSummaryPreferenceControllerTest {
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -89,7 +88,7 @@ public class BubbleSummaryPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
SYSTEM_WIDE_OFF);
@@ -99,7 +98,7 @@ public class BubbleSummaryPreferenceControllerTest {
@Test
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -108,7 +107,7 @@ public class BubbleSummaryPreferenceControllerTest {
@Test
public void testIsNotAvailable_app_globalOff() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
SYSTEM_WIDE_OFF);
@@ -122,7 +121,7 @@ public class BubbleSummaryPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -132,7 +131,7 @@ public class BubbleSummaryPreferenceControllerTest {
public void testUpdateState() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Preference pref = new Preference(mContext);
mController.updateState(pref);
@@ -144,7 +143,7 @@ public class BubbleSummaryPreferenceControllerTest {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertEquals("On", mController.getSummary());
@@ -154,7 +153,7 @@ public class BubbleSummaryPreferenceControllerTest {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
appRow.allowBubbles = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertEquals("Off", mController.getSummary());
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java
new file mode 100644
index 00000000000..89007f0bd7c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationChannel;
+import android.content.Context;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.notification.NotificationBackend;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class ConversationDemotePreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationBackend mBackend;
+ @Mock
+ SettingsPreferenceFragment mFragment;
+
+ private ConversationDemotePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ mContext = RuntimeEnvironment.application;
+ when(mFragment.getActivity()).thenReturn(mock(FragmentActivity.class));
+ mController = spy(new ConversationDemotePreferenceController(
+ mContext, mFragment, mBackend));
+
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ mController.handlePreferenceTreeClick(mock(Preference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notConversation() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_conversation_demoted() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(true);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_conversation_notDemoted() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(false);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testHandlePreferenceClick() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(false);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = mock(Preference.class);
+ when(pref.getKey()).thenReturn("demote");
+ assertTrue(mController.handlePreferenceTreeClick(pref));
+
+ ArgumentCaptor captor =
+ ArgumentCaptor.forClass(NotificationChannel.class);
+
+ verify(mBackend).updateChannel(eq(null), anyInt(), captor.capture());
+ assertTrue(captor.getValue().isDemoted());
+
+ verify(mFragment).getActivity();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
new file mode 100644
index 00000000000..96f4e0bf497
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationManager.IMPORTANCE_NONE;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationChannel;
+import android.app.NotificationChannelGroup;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.content.pm.ShortcutInfo;
+import android.os.UserManager;
+import android.view.View;
+
+import androidx.fragment.app.FragmentActivity;
+
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.widget.LayoutPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class ConversationHeaderPreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationManager mNm;
+ @Mock
+ private UserManager mUm;
+
+ private ConversationHeaderPreferenceController mController;
+ @Mock
+ private LayoutPreference mPreference;
+ @Mock
+ private View mView;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
+ shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
+ mContext = RuntimeEnvironment.application;
+ DashboardFragment fragment = mock(DashboardFragment.class);
+ when(fragment.getContext()).thenReturn(mContext);
+ FragmentActivity activity = mock(FragmentActivity.class);
+ when(activity.getApplicationContext()).thenReturn(mContext);
+ when(fragment.getActivity()).thenReturn(activity);
+ mController = spy(new ConversationHeaderPreferenceController(mContext, fragment));
+ when(mPreference.findViewById(anyInt())).thenReturn(mView);
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(LayoutPreference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notIfNull() {
+ mController.onResume(null, null, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.banned = true;
+ mController.onResume(appRow, null, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testGetLabel() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ when(si.getShortLabel()).thenReturn("hello");
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ mController.onResume(appRow, null, null, null, si, null);
+ assertEquals(si.getShortLabel(), mController.getLabel());
+
+ NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertEquals(channel.getName(), mController.getLabel());
+ }
+
+ @Test
+ public void testGetSummary() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.label = "bananas";
+ mController.onResume(appRow, null, null, null, null, null);
+ assertEquals("", mController.getSummary());
+
+ NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
+ mController.onResume(appRow, null, group, null, null, null);
+ assertEquals(appRow.label, mController.getSummary());
+
+ NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
+ mController.onResume(appRow, channel, group, null, null, null);
+ assertTrue(mController.getSummary().toString().contains(group.getName()));
+ assertTrue(mController.getSummary().toString().contains(appRow.label));
+
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.getSummary().toString().contains(group.getName()));
+ assertTrue(mController.getSummary().toString().contains(appRow.label));
+
+ NotificationChannel defaultChannel = new NotificationChannel(
+ NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
+ mController.onResume(appRow, defaultChannel, null, null, null, null);
+ assertEquals("", mController.getSummary());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationImportantPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationImportantPreferenceControllerTest.java
new file mode 100644
index 00000000000..d1dd0a64483
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationImportantPreferenceControllerTest.java
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.os.UserManager;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class ConversationImportantPreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationBackend mBackend;
+ @Mock
+ private NotificationManager mNm;
+ @Mock
+ private UserManager mUm;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private PreferenceScreen mScreen;
+
+ private ConversationImportantPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
+ shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
+ mContext = RuntimeEnvironment.application;
+ mController = spy(new ConversationImportantPreferenceController(mContext, mBackend));
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ mController.onPreferenceChange(mock(Preference.class), true);
+ }
+
+ @Test
+ public void testIsAvailable_notChannelNull() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ mController.onResume(appRow, null, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testUpdateState_disabledByAdmin() {
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getId()).thenReturn("something");
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
+ RestrictedLockUtils.EnforcedAdmin.class));
+
+ Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
+ mController.updateState(pref);
+
+ assertFalse(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setImportantConversation(true);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref =
+ new RestrictedSwitchPreference(RuntimeEnvironment.application);
+ mController.updateState(pref);
+
+ assertTrue(pref.isChecked());
+
+ channel.setImportantConversation(false);
+ mController.onResume(appRow, channel, null, null, null, null);
+ mController.updateState(pref);
+ assertFalse(pref.isChecked());
+ }
+
+ @Test
+ public void testOnPreferenceChange_on() {
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
+ channel.setImportantConversation(false);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref =
+ new RestrictedSwitchPreference(RuntimeEnvironment.application);
+ mController.updateState(pref);
+
+ mController.onPreferenceChange(pref, true);
+
+ assertTrue(channel.isImportantConversation());
+ verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
+ }
+
+ @Test
+ public void testOnPreferenceChange_off() {
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
+ channel.setImportantConversation(true);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref =
+ new RestrictedSwitchPreference(RuntimeEnvironment.application);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+ mController.displayPreference(mScreen);
+ mController.updateState(pref);
+
+ mController.onPreferenceChange(pref, false);
+
+ assertFalse(channel.isImportantConversation());
+ verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java
new file mode 100644
index 00000000000..725be3de1b3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationChannel;
+import android.content.Context;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.notification.NotificationBackend;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class ConversationPromotePreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationBackend mBackend;
+ @Mock
+ SettingsPreferenceFragment mFragment;
+
+ private ConversationPromotePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ mContext = RuntimeEnvironment.application;
+ when(mFragment.getActivity()).thenReturn(mock(FragmentActivity.class));
+ mController = spy(new ConversationPromotePreferenceController(
+ mContext, mFragment, mBackend));
+
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ mController.handlePreferenceTreeClick(mock(Preference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notConversation() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_conversation_notDemoted() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_conversation_demoted() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(true);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testHandlePreferenceClick() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(true);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = mock(Preference.class);
+ when(pref.getKey()).thenReturn("convo_promote");
+ assertTrue(mController.handlePreferenceTreeClick(pref));
+
+ ArgumentCaptor captor =
+ ArgumentCaptor.forClass(NotificationChannel.class);
+
+ verify(mBackend).updateChannel(eq(null), anyInt(), captor.capture());
+ assertFalse(captor.getValue().isDemoted());
+
+ verify(mFragment).getActivity();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/DefaultImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DefaultImportancePreferenceControllerTest.java
new file mode 100644
index 00000000000..dc2303fd37a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/DefaultImportancePreferenceControllerTest.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2017 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.settings.notification.app;
+
+import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.app.NotificationManager.IMPORTANCE_LOW;
+import static android.app.NotificationManager.IMPORTANCE_NONE;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.os.UserManager;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class DefaultImportancePreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationManager mNm;
+ @Mock
+ private NotificationBackend mBackend;
+ @Mock
+ private NotificationSettings.ImportanceListener mImportanceListener;
+ @Mock
+ private UserManager mUm;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private PreferenceScreen mScreen;
+
+ private DefaultImportancePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
+ shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
+ mContext = RuntimeEnvironment.application;
+ mController = spy(new DefaultImportancePreferenceController(
+ mContext, mImportanceListener, mBackend));
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notIfNull() {
+ mController.onResume(null, null, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_ifAppBlocked() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.banned = true;
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_notIfChannelBlocked() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_notForDefaultChannel() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testUpdateState_disabledByAdmin() {
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
+ RestrictedLockUtils.EnforcedAdmin.class));
+
+ Preference pref = new RestrictedSwitchPreference(mContext, null);
+ mController.updateState(pref);
+
+ assertFalse(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState_notConfigurable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.isImportanceLockedByOEM()).thenReturn(true);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = new RestrictedSwitchPreference(mContext, null);
+ mController.updateState(pref);
+
+ assertFalse(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState_systemButConfigurable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.systemApp = true;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.isImportanceLockedByOEM()).thenReturn(false);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = new RestrictedSwitchPreference(mContext, null);
+ mController.updateState(pref);
+
+ assertTrue(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState_defaultApp() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.systemApp = true;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = new RestrictedSwitchPreference(mContext, null);
+ mController.updateState(pref);
+
+ assertTrue(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState_default() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
+ mController.updateState(pref);
+
+ assertTrue(pref.isChecked());
+ }
+
+ @Test
+ public void testUpdateState_low() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
+ mController.updateState(pref);
+
+ assertFalse(pref.isChecked());
+ }
+
+ @Test
+ public void onPreferenceChange_onToOff() {
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+ mController.displayPreference(mScreen);
+ mController.updateState(pref);
+
+ mController.onPreferenceChange(pref, false);
+
+ assertEquals(IMPORTANCE_LOW, channel.getImportance());
+ verify(mImportanceListener, times(1)).onImportanceChanged();
+ }
+
+ @Test
+ public void onPreferenceChange_offToOn() {
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+ mController.displayPreference(mScreen);
+ mController.updateState(pref);
+
+ mController.onPreferenceChange(pref, true);
+
+ assertEquals(IMPORTANCE_DEFAULT, channel.getImportance());
+ verify(mImportanceListener, times(1)).onImportanceChanged();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java
index c2868cee697..5515a55efb6 100644
--- a/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java
@@ -35,7 +35,6 @@ import android.os.UserManager;
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.DeletedChannelsPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -80,42 +79,43 @@ public class DeletedChannelsPreferenceControllerTest {
public void isAvailable_appScreen_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_groupScreen_never() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null);
+ mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_channelScreen_never() {
mController.onResume(
- new NotificationBackend.AppRow(), mock(NotificationChannel.class), null, null);
+ new NotificationBackend.AppRow(), mock(NotificationChannel.class), null, null, null,
+ null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_appScreen_notIfNoDeletedChannels() {
when(mBackend.getDeletedChannelCount(any(), anyInt())).thenReturn(0);
- mController.onResume(new NotificationBackend.AppRow(), null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_appScreen() {
when(mBackend.getDeletedChannelCount(any(), anyInt())).thenReturn(1);
- mController.onResume(new NotificationBackend.AppRow(), null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
public void updateState() {
when(mBackend.getDeletedChannelCount(any(), anyInt())).thenReturn(1);
- mController.onResume(new NotificationBackend.AppRow(), null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null);
Preference pref = mock(Preference.class);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java
index e078e58ef07..3e37327f6fc 100644
--- a/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java
@@ -35,7 +35,6 @@ import android.os.UserManager;
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.DescriptionPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -75,7 +74,7 @@ public class DescriptionPreferenceControllerTest {
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -83,7 +82,7 @@ public class DescriptionPreferenceControllerTest {
public void testIsAvailable_notIfChannelGroupBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -92,7 +91,7 @@ public class DescriptionPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -101,7 +100,7 @@ public class DescriptionPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -109,7 +108,7 @@ public class DescriptionPreferenceControllerTest {
public void testIsAvailable_notIfNoChannelGroupDesc() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -119,7 +118,7 @@ public class DescriptionPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getDescription()).thenReturn("AAA");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -129,7 +128,7 @@ public class DescriptionPreferenceControllerTest {
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.getDescription()).thenReturn("something");
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -139,7 +138,7 @@ public class DescriptionPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getDescription()).thenReturn("AAA");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -154,7 +153,7 @@ public class DescriptionPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.getDescription()).thenReturn("something");
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java
index 2f1b913cadd..4220beda0da 100644
--- a/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java
@@ -41,7 +41,6 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.DndPreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -84,7 +83,7 @@ public class DndPreferenceControllerTest {
public void testIsAvailable_app() {
when(mNm.getNotificationPolicy()).thenReturn(new NotificationManager.Policy(0, 0, 0, 0));
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -94,7 +93,7 @@ public class DndPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_MIN);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -102,7 +101,7 @@ public class DndPreferenceControllerTest {
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -116,7 +115,7 @@ public class DndPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -129,7 +128,7 @@ public class DndPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -141,7 +140,7 @@ public class DndPreferenceControllerTest {
public void testUpdateState_bypassDnd() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBypassDnd()).thenReturn(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -153,7 +152,7 @@ public class DndPreferenceControllerTest {
public void testUpdateState_noBypassDnd() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBypassDnd()).thenReturn(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -165,7 +164,7 @@ public class DndPreferenceControllerTest {
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -183,7 +182,7 @@ public class DndPreferenceControllerTest {
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
index 7b8ad48b615..c4e94a9ce02 100644
--- a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
@@ -37,7 +37,6 @@ import androidx.fragment.app.FragmentActivity;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.HeaderPreferenceController;
import com.android.settingslib.widget.LayoutPreference;
import org.junit.Before;
@@ -88,7 +87,7 @@ public class HeaderPreferenceControllerTest {
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -96,7 +95,7 @@ public class HeaderPreferenceControllerTest {
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -104,20 +103,20 @@ public class HeaderPreferenceControllerTest {
public void testGetLabel() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "bananas";
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertEquals(appRow.label, mController.getLabel());
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertEquals(group.getName(), mController.getLabel());
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertEquals(channel.getName(), mController.getLabel());
NotificationChannel defaultChannel = new NotificationChannel(
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
- mController.onResume(appRow, defaultChannel, null, null);
+ mController.onResume(appRow, defaultChannel, null, null, null, null);
assertEquals(appRow.label, mController.getLabel());
}
@@ -125,25 +124,25 @@ public class HeaderPreferenceControllerTest {
public void testGetSummary() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "bananas";
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertEquals("", mController.getSummary());
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertEquals(appRow.label, mController.getSummary());
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertTrue(mController.getSummary().toString().contains(group.getName()));
assertTrue(mController.getSummary().toString().contains(appRow.label));
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.getSummary().toString().contains(group.getName()));
assertTrue(mController.getSummary().toString().contains(appRow.label));
NotificationChannel defaultChannel = new NotificationChannel(
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
- mController.onResume(appRow, defaultChannel, null, null);
+ mController.onResume(appRow, defaultChannel, null, null, null, null);
assertEquals("", mController.getSummary());
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java
index bed6ccc2c7e..8dc74215945 100644
--- a/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java
@@ -36,8 +36,6 @@ import android.content.Context;
import android.os.UserManager;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.HighImportancePreferenceController;
-import com.android.settings.notification.app.NotificationSettings;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -90,7 +88,7 @@ public class HighImportancePreferenceControllerTest {
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -98,7 +96,7 @@ public class HighImportancePreferenceControllerTest {
public void testIsAvailable_ifAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -107,7 +105,7 @@ public class HighImportancePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -117,7 +115,7 @@ public class HighImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -126,7 +124,7 @@ public class HighImportancePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -134,7 +132,7 @@ public class HighImportancePreferenceControllerTest {
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext, null);
@@ -149,7 +147,7 @@ public class HighImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -164,7 +162,7 @@ public class HighImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -179,7 +177,7 @@ public class HighImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -191,7 +189,7 @@ public class HighImportancePreferenceControllerTest {
public void testUpdateState_high() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -203,7 +201,7 @@ public class HighImportancePreferenceControllerTest {
public void testUpdateState_default() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -215,7 +213,7 @@ public class HighImportancePreferenceControllerTest {
public void onPreferenceChange() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java
index b8fc6c40b94..2c7e17f843e 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java
@@ -46,9 +46,6 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.ImportancePreference;
-import com.android.settings.notification.app.ImportancePreferenceController;
-import com.android.settings.notification.app.NotificationSettings;
import com.android.settingslib.RestrictedLockUtils;
import org.junit.Before;
@@ -97,7 +94,7 @@ public class ImportancePreferenceControllerTest {
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -105,7 +102,7 @@ public class ImportancePreferenceControllerTest {
public void testIsAvailable_ifAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -116,7 +113,7 @@ public class ImportancePreferenceControllerTest {
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -125,7 +122,7 @@ public class ImportancePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -135,7 +132,7 @@ public class ImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -144,7 +141,7 @@ public class ImportancePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -152,7 +149,7 @@ public class ImportancePreferenceControllerTest {
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new ImportancePreference(mContext, null);
@@ -167,7 +164,7 @@ public class ImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -182,7 +179,7 @@ public class ImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -197,7 +194,7 @@ public class ImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -209,7 +206,7 @@ public class ImportancePreferenceControllerTest {
public void testUpdateState() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
ImportancePreference pref = mock(ImportancePreference.class);
mController.updateState(pref);
@@ -224,7 +221,7 @@ public class ImportancePreferenceControllerTest {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
ImportancePreference pref = new ImportancePreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -242,7 +239,7 @@ public class ImportancePreferenceControllerTest {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
channel.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
ImportancePreference pref = new ImportancePreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java
index 547880e15c1..4f3b4962ea6 100644
--- a/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java
@@ -42,7 +42,6 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.LightsPreferenceController;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -108,7 +107,7 @@ public class LightsPreferenceControllerTest {
com.android.internal.R.bool.config_intrusiveNotificationLed, false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -117,7 +116,7 @@ public class LightsPreferenceControllerTest {
Settings.System.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 0);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -125,7 +124,7 @@ public class LightsPreferenceControllerTest {
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -134,7 +133,7 @@ public class LightsPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -142,7 +141,7 @@ public class LightsPreferenceControllerTest {
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -151,7 +150,7 @@ public class LightsPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null,
- mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -164,7 +163,7 @@ public class LightsPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -176,7 +175,7 @@ public class LightsPreferenceControllerTest {
public void testUpdateState_lightsOn() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldShowLights()).thenReturn(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -187,7 +186,7 @@ public class LightsPreferenceControllerTest {
public void testUpdateState_lightsOff() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldShowLights()).thenReturn(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -198,7 +197,7 @@ public class LightsPreferenceControllerTest {
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -215,7 +214,7 @@ public class LightsPreferenceControllerTest {
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(mContext);
diff --git a/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java
index 2a06fa80c40..bed12af539e 100644
--- a/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java
@@ -36,8 +36,6 @@ import android.content.Context;
import android.os.UserManager;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.MinImportancePreferenceController;
-import com.android.settings.notification.app.NotificationSettings;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -90,7 +88,7 @@ public class MinImportancePreferenceControllerTest {
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -98,7 +96,7 @@ public class MinImportancePreferenceControllerTest {
public void testIsAvailable_ifAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -107,7 +105,7 @@ public class MinImportancePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -117,7 +115,7 @@ public class MinImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -126,7 +124,7 @@ public class MinImportancePreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -134,7 +132,7 @@ public class MinImportancePreferenceControllerTest {
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext, null);
@@ -149,7 +147,7 @@ public class MinImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -164,7 +162,7 @@ public class MinImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -179,7 +177,7 @@ public class MinImportancePreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -191,7 +189,7 @@ public class MinImportancePreferenceControllerTest {
public void testUpdateState_min() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -203,7 +201,7 @@ public class MinImportancePreferenceControllerTest {
public void testUpdateState_low() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -215,7 +213,7 @@ public class MinImportancePreferenceControllerTest {
public void onPreferenceChange() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
index 6a6818f34ff..170a5e0901d 100644
--- a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
@@ -42,7 +42,6 @@ import android.os.UserManager;
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.NotificationPreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import org.junit.Before;
@@ -91,7 +90,7 @@ public class NotificationPreferenceControllerTest {
@Test
public void isAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -100,7 +99,7 @@ public class NotificationPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
mController.onResume(appRow, mock(NotificationChannel.class),
- mock(NotificationChannelGroup.class), null);
+ mock(NotificationChannelGroup.class), null, null, null);
assertFalse(mController.isAvailable());
}
@@ -112,7 +111,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -123,7 +122,7 @@ public class NotificationPreferenceControllerTest {
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
when(group.isBlocked()).thenReturn(true);
assertFalse(mController.isAvailable());
}
@@ -136,7 +135,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -147,7 +146,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
RestrictedLockUtils.EnforcedAdmin admin = mock(RestrictedLockUtils.EnforcedAdmin.class);
- mController.onResume(appRow, channel, group, admin);
+ mController.onResume(appRow, channel, group, null, null, admin);
assertEquals(appRow, mController.mAppRow);
assertEquals(channel, mController.mChannel);
@@ -161,7 +160,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_UNSPECIFIED);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.checkCanBeVisible(IMPORTANCE_MIN));
}
@@ -171,7 +170,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.checkCanBeVisible(IMPORTANCE_LOW));
}
@@ -181,7 +180,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.checkCanBeVisible(IMPORTANCE_MIN));
}
@@ -191,7 +190,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.checkCanBeVisible(IMPORTANCE_DEFAULT));
}
@@ -201,7 +200,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.saveChannel();
verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
}
@@ -213,11 +212,11 @@ public class NotificationPreferenceControllerTest {
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
when(channel.isImportanceLockedByOEM()).thenReturn(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -228,7 +227,7 @@ public class NotificationPreferenceControllerTest {
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -239,7 +238,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isBlockableSystem()).thenReturn(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -251,7 +250,7 @@ public class NotificationPreferenceControllerTest {
when(channel.isBlockableSystem()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -262,7 +261,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isBlockableSystem()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -274,7 +273,7 @@ public class NotificationPreferenceControllerTest {
when(channel.isBlockableSystem()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -285,7 +284,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertTrue(mController.isChannelGroupBlockable());
}
@@ -297,7 +296,7 @@ public class NotificationPreferenceControllerTest {
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -309,7 +308,7 @@ public class NotificationPreferenceControllerTest {
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -320,7 +319,7 @@ public class NotificationPreferenceControllerTest {
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertFalse(mController.isChannelGroupBlockable());
}
@@ -331,13 +330,13 @@ public class NotificationPreferenceControllerTest {
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertTrue(mController.isChannelGroupBlockable());
}
@Test
public void testIsDefaultChannel_noChannel() {
- mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, null, null);
assertFalse(mController.isDefaultChannel());
}
@@ -345,7 +344,7 @@ public class NotificationPreferenceControllerTest {
@Test
public void testIsDefaultChannel_nonDefaultChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null, null, null);
assertFalse(mController.isDefaultChannel());
}
@@ -354,7 +353,7 @@ public class NotificationPreferenceControllerTest {
public void testIsDefaultChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn(NotificationChannel.DEFAULT_CHANNEL_ID);
- mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null, null, null);
assertTrue(mController.isDefaultChannel());
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java
index 6dd71a3162b..cfbe5f7120d 100644
--- a/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java
@@ -33,7 +33,6 @@ import android.os.UserManager;
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.NotificationsOffPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -73,7 +72,7 @@ public class NotificationsOffPreferenceControllerTest {
public void testIsAvailable_yesIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -82,7 +81,7 @@ public class NotificationsOffPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -91,7 +90,7 @@ public class NotificationsOffPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -100,7 +99,7 @@ public class NotificationsOffPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -114,7 +113,7 @@ public class NotificationsOffPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -127,7 +126,7 @@ public class NotificationsOffPreferenceControllerTest {
public void testUpdateState_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java
index ba4b5f0e1c4..157e66676d0 100644
--- a/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java
@@ -108,7 +108,7 @@ public class SoundPreferenceControllerTest {
@Test
public void testIsAvailable_notIfChannelNull() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -116,7 +116,7 @@ public class SoundPreferenceControllerTest {
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -125,7 +125,7 @@ public class SoundPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -133,7 +133,7 @@ public class SoundPreferenceControllerTest {
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -151,7 +151,7 @@ public class SoundPreferenceControllerTest {
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
@@ -166,7 +166,7 @@ public class SoundPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
Preference pref = new NotificationSoundPreference(mContext, attributeSet);
@@ -182,7 +182,7 @@ public class SoundPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
when(channel.getSound()).thenReturn(sound);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref = new NotificationSoundPreference(mContext, attributeSet);
@@ -198,7 +198,7 @@ public class SoundPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(sound, Notification.AUDIO_ATTRIBUTES_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
@@ -238,7 +238,7 @@ public class SoundPreferenceControllerTest {
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(null, new AudioAttributes.Builder().setUsage(
AudioAttributes.USAGE_ALARM).build());
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
@@ -259,7 +259,7 @@ public class SoundPreferenceControllerTest {
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(null, new AudioAttributes.Builder().setUsage(
AudioAttributes.USAGE_NOTIFICATION_RINGTONE).build());
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
@@ -280,7 +280,7 @@ public class SoundPreferenceControllerTest {
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(null, new AudioAttributes.Builder().setUsage(
AudioAttributes.USAGE_UNKNOWN).build());
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
diff --git a/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java
index 38d4dce0210..06a319f7ad1 100644
--- a/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java
@@ -42,7 +42,6 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.VibrationPreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -99,7 +98,7 @@ public class VibrationPreferenceControllerTest {
when(mVibrator.hasVibrator()).thenReturn(false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -107,7 +106,7 @@ public class VibrationPreferenceControllerTest {
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -116,7 +115,7 @@ public class VibrationPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -124,7 +123,7 @@ public class VibrationPreferenceControllerTest {
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -132,7 +131,7 @@ public class VibrationPreferenceControllerTest {
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -146,7 +145,7 @@ public class VibrationPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -159,7 +158,7 @@ public class VibrationPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -171,7 +170,7 @@ public class VibrationPreferenceControllerTest {
public void testUpdateState_vibrateOn() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldVibrate()).thenReturn(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -183,7 +182,7 @@ public class VibrationPreferenceControllerTest {
public void testUpdateState_vibrateOff() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldVibrate()).thenReturn(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -195,7 +194,7 @@ public class VibrationPreferenceControllerTest {
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -211,7 +210,7 @@ public class VibrationPreferenceControllerTest {
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java
index 9de12ceb3ec..2150c820afc 100644
--- a/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java
@@ -48,7 +48,6 @@ import android.provider.Settings;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.RestrictedListPreference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.VisibilityPreferenceController;
import com.android.settings.testutils.shadow.ShadowRestrictionUtils;
import com.android.settingslib.RestrictedLockUtils;
@@ -122,7 +121,7 @@ public class VisibilityPreferenceControllerTest {
when(mLockUtils.isSecure(anyInt())).thenReturn(false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -130,7 +129,7 @@ public class VisibilityPreferenceControllerTest {
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -139,11 +138,11 @@ public class VisibilityPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -160,7 +159,7 @@ public class VisibilityPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
RestrictedListPreference pref = mock(RestrictedListPreference.class);
@@ -182,7 +181,7 @@ public class VisibilityPreferenceControllerTest {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
RestrictedListPreference pref = mock(RestrictedListPreference.class);
@@ -198,7 +197,7 @@ public class VisibilityPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -223,7 +222,7 @@ public class VisibilityPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -246,7 +245,7 @@ public class VisibilityPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -263,7 +262,7 @@ public class VisibilityPreferenceControllerTest {
public void testUpdateState_noGlobalRestriction() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -294,7 +293,7 @@ public class VisibilityPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getLockscreenVisibility()).thenReturn(VISIBILITY_NO_OVERRIDE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -313,7 +312,7 @@ public class VisibilityPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getLockscreenVisibility()).thenReturn(Notification.VISIBILITY_SECRET);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -332,7 +331,7 @@ public class VisibilityPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", 4);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -351,7 +350,7 @@ public class VisibilityPreferenceControllerTest {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", 4);
channel.setLockscreenVisibility(VISIBILITY_NO_OVERRIDE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);