diff options
14 files changed, 177 insertions, 59 deletions
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/NotificationListenerController.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/NotificationListenerController.java index fac9e98a6caf..6799450079af 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/NotificationListenerController.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/NotificationListenerController.java @@ -14,6 +14,8 @@ package com.android.systemui.plugins; +import android.app.NotificationChannel; +import android.os.UserHandle; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; @@ -30,13 +32,32 @@ public interface NotificationListenerController extends Plugin { void onListenerConnected(NotificationProvider provider); + /** + * @return whether plugin wants to skip the default callbacks. + */ default boolean onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) { return false; } + + /** + * @return whether plugin wants to skip the default callbacks. + */ default boolean onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap) { return false; } + /** + * Called when a notification channel is modified. + * @param modificationType One of {@link #NOTIFICATION_CHANNEL_OR_GROUP_ADDED}, + * {@link #NOTIFICATION_CHANNEL_OR_GROUP_UPDATED}, + * {@link #NOTIFICATION_CHANNEL_OR_GROUP_DELETED}. + * @return whether a plugin wants to skip the default callbacks. + */ + default boolean onNotificationChannelModified( + String pkgName, UserHandle user, NotificationChannel channel, int modificationType) { + return false; + } + default StatusBarNotification[] getActiveNotifications( StatusBarNotification[] activeNotifications) { return activeNotifications; diff --git a/packages/SystemUI/res/values-bn/strings.xml b/packages/SystemUI/res/values-bn/strings.xml index 31a6e1e6b1b0..92e0c1dd9613 100644 --- a/packages/SystemUI/res/values-bn/strings.xml +++ b/packages/SystemUI/res/values-bn/strings.xml @@ -86,16 +86,11 @@ <string name="screenshot_failed_to_save_unknown_text" msgid="1506621600548684129">"আবার স্ক্রিনশট নেওয়ার চেষ্টা করুন"</string> <string name="screenshot_failed_to_save_text" msgid="8344173457344027501">"বেশি জায়গা নেই তাই স্ক্রিনশটটি সেভ করা যাবে না৷"</string> <string name="screenshot_failed_to_capture_text" msgid="7818288545874407451">"এই অ্যাপ বা আপনার প্রতিষ্ঠান স্ক্রিনশট নেওয়ার অনুমতি দেয়নি"</string> - <!-- no translation found for screenshot_edit_label (8754981973544133050) --> - <skip /> - <!-- no translation found for screenshot_edit_description (3333092254706788906) --> - <skip /> - <!-- no translation found for screenshot_scroll_label (7682877978685434621) --> - <skip /> - <!-- no translation found for screenshot_scroll_description (7855773867093272175) --> - <skip /> - <!-- no translation found for screenshot_dismiss_description (4702341245899508786) --> - <skip /> + <string name="screenshot_edit_label" msgid="8754981973544133050">"এডিট করুন"</string> + <string name="screenshot_edit_description" msgid="3333092254706788906">"স্ক্রিনশট এডিট করুন"</string> + <string name="screenshot_scroll_label" msgid="7682877978685434621">"স্ক্রল করুন"</string> + <string name="screenshot_scroll_description" msgid="7855773867093272175">"স্ক্রিনশট স্ক্রল করুন"</string> + <string name="screenshot_dismiss_description" msgid="4702341245899508786">"স্ক্রিনশট বাতিল করুন"</string> <string name="screenshot_preview_description" msgid="7606510140714080474">"স্ক্রিনশটের প্রিভিউ"</string> <string name="screenrecord_name" msgid="2596401223859996572">"স্ক্রিন রেকর্ডার"</string> <string name="screenrecord_background_processing_label" msgid="7244617554884238898">"স্ক্রিন রেকর্ডিং প্রসেস হচ্ছে"</string> diff --git a/packages/SystemUI/res/values-es/strings.xml b/packages/SystemUI/res/values-es/strings.xml index d9b805bb1f03..2ce271896c50 100644 --- a/packages/SystemUI/res/values-es/strings.xml +++ b/packages/SystemUI/res/values-es/strings.xml @@ -88,8 +88,8 @@ <string name="screenshot_failed_to_capture_text" msgid="7818288545874407451">"La aplicación o tu organización no permiten realizar capturas de pantalla"</string> <string name="screenshot_edit_label" msgid="8754981973544133050">"Editar"</string> <string name="screenshot_edit_description" msgid="3333092254706788906">"Editar captura de pantalla"</string> - <string name="screenshot_scroll_label" msgid="7682877978685434621">"Desplazarse"</string> - <string name="screenshot_scroll_description" msgid="7855773867093272175">"Desplazarse por la captura de pantalla"</string> + <string name="screenshot_scroll_label" msgid="7682877978685434621">"Pantalla continua"</string> + <string name="screenshot_scroll_description" msgid="7855773867093272175">"Hacer captura de pantalla continua"</string> <string name="screenshot_dismiss_description" msgid="4702341245899508786">"Cerrar captura de pantalla"</string> <string name="screenshot_preview_description" msgid="7606510140714080474">"Vista previa de captura de pantalla"</string> <string name="screenrecord_name" msgid="2596401223859996572">"Grabación de pantalla"</string> diff --git a/packages/SystemUI/res/values-eu/strings.xml b/packages/SystemUI/res/values-eu/strings.xml index 453d32e267e1..835449f9939e 100644 --- a/packages/SystemUI/res/values-eu/strings.xml +++ b/packages/SystemUI/res/values-eu/strings.xml @@ -89,7 +89,7 @@ <string name="screenshot_edit_label" msgid="8754981973544133050">"Editatu"</string> <string name="screenshot_edit_description" msgid="3333092254706788906">"Editatu pantaila-argazkia"</string> <string name="screenshot_scroll_label" msgid="7682877978685434621">"Egin gora eta behera"</string> - <string name="screenshot_scroll_description" msgid="7855773867093272175">"Pantaila-kaptura etengabea"</string> + <string name="screenshot_scroll_description" msgid="7855773867093272175">"Pantaila-argazki etengabea"</string> <string name="screenshot_dismiss_description" msgid="4702341245899508786">"Baztertu pantaila-argazkia"</string> <string name="screenshot_preview_description" msgid="7606510140714080474">"Pantaila-argazkiaren aurrebista"</string> <string name="screenrecord_name" msgid="2596401223859996572">"Pantaila-grabagailua"</string> diff --git a/packages/SystemUI/res/values-mr/strings.xml b/packages/SystemUI/res/values-mr/strings.xml index ff67a4019cd4..a487a6377ed5 100644 --- a/packages/SystemUI/res/values-mr/strings.xml +++ b/packages/SystemUI/res/values-mr/strings.xml @@ -86,16 +86,11 @@ <string name="screenshot_failed_to_save_unknown_text" msgid="1506621600548684129">"स्क्रीनशॉट पुन्हा घेण्याचा प्रयत्न करा"</string> <string name="screenshot_failed_to_save_text" msgid="8344173457344027501">"मर्यादित स्टोरेज जागेमुळे स्क्रीनशॉट सेव्ह करू शकत नाही"</string> <string name="screenshot_failed_to_capture_text" msgid="7818288545874407451">"अॅप किंवा आपल्या संस्थेद्वारे स्क्रीनशॉट घेण्याची अनुमती नाही"</string> - <!-- no translation found for screenshot_edit_label (8754981973544133050) --> - <skip /> - <!-- no translation found for screenshot_edit_description (3333092254706788906) --> - <skip /> - <!-- no translation found for screenshot_scroll_label (7682877978685434621) --> - <skip /> - <!-- no translation found for screenshot_scroll_description (7855773867093272175) --> - <skip /> - <!-- no translation found for screenshot_dismiss_description (4702341245899508786) --> - <skip /> + <string name="screenshot_edit_label" msgid="8754981973544133050">"संपादित करा"</string> + <string name="screenshot_edit_description" msgid="3333092254706788906">"स्क्रीनशॉट संपादित करा"</string> + <string name="screenshot_scroll_label" msgid="7682877978685434621">"स्क्रोल करा"</string> + <string name="screenshot_scroll_description" msgid="7855773867093272175">"स्क्रीनशॉटवर स्क्रोल करा"</string> + <string name="screenshot_dismiss_description" msgid="4702341245899508786">"स्क्रीनशॉट डिसमिस करा"</string> <string name="screenshot_preview_description" msgid="7606510140714080474">"स्क्रीनशॉटचे पूर्वावलोकन"</string> <string name="screenrecord_name" msgid="2596401223859996572">"स्क्रीन रेकॉर्डर"</string> <string name="screenrecord_background_processing_label" msgid="7244617554884238898">"स्क्रीन रेकॉर्डिंग प्रोसेस सुरू"</string> diff --git a/packages/SystemUI/res/values-ne/strings.xml b/packages/SystemUI/res/values-ne/strings.xml index 560fd0bff5d2..eca79cbd0a28 100644 --- a/packages/SystemUI/res/values-ne/strings.xml +++ b/packages/SystemUI/res/values-ne/strings.xml @@ -86,16 +86,11 @@ <string name="screenshot_failed_to_save_unknown_text" msgid="1506621600548684129">"स्क्रिनसट फेरि लिएर हेर्नुहोस्"</string> <string name="screenshot_failed_to_save_text" msgid="8344173457344027501">"भण्डारण ठाउँ सीमित भएका कारण स्क्रिनसट सुरक्षित गर्न सकिएन"</string> <string name="screenshot_failed_to_capture_text" msgid="7818288545874407451">"उक्त एप वा तपाईंको संगठनले स्क्रिनसटहरू लिन दिँदैन"</string> - <!-- no translation found for screenshot_edit_label (8754981973544133050) --> - <skip /> - <!-- no translation found for screenshot_edit_description (3333092254706788906) --> - <skip /> - <!-- no translation found for screenshot_scroll_label (7682877978685434621) --> - <skip /> - <!-- no translation found for screenshot_scroll_description (7855773867093272175) --> - <skip /> - <!-- no translation found for screenshot_dismiss_description (4702341245899508786) --> - <skip /> + <string name="screenshot_edit_label" msgid="8754981973544133050">"सम्पादन गर्नुहोस्"</string> + <string name="screenshot_edit_description" msgid="3333092254706788906">"स्क्रिनसट सम्पादन गर्नुहोस्"</string> + <string name="screenshot_scroll_label" msgid="7682877978685434621">"स्क्रोल गर्नुहोस्"</string> + <string name="screenshot_scroll_description" msgid="7855773867093272175">"स्क्रिनसट स्क्रोल गर्नुहोस्"</string> + <string name="screenshot_dismiss_description" msgid="4702341245899508786">"स्क्रिनसट हटाउनुहोस्"</string> <string name="screenshot_preview_description" msgid="7606510140714080474">"स्क्रिनसटको पूर्वावलोकन"</string> <string name="screenrecord_name" msgid="2596401223859996572">"स्क्रिन रेकर्डर"</string> <string name="screenrecord_background_processing_label" msgid="7244617554884238898">"स्क्रिन रेकर्डिङको प्रक्रिया अघि बढाइँदै"</string> diff --git a/packages/SystemUI/res/values-sq/strings.xml b/packages/SystemUI/res/values-sq/strings.xml index d3ebe528c9a7..297ebc6e6a3c 100644 --- a/packages/SystemUI/res/values-sq/strings.xml +++ b/packages/SystemUI/res/values-sq/strings.xml @@ -86,16 +86,11 @@ <string name="screenshot_failed_to_save_unknown_text" msgid="1506621600548684129">"Provo ta nxjerrësh përsëri pamjen e ekranit"</string> <string name="screenshot_failed_to_save_text" msgid="8344173457344027501">"Pamja e ekranit nuk mund të ruhet për shkak të hapësirës ruajtëse të kufizuar"</string> <string name="screenshot_failed_to_capture_text" msgid="7818288545874407451">"Nxjerrja e pamjeve të ekranit nuk lejohet nga aplikacioni ose organizata jote."</string> - <!-- no translation found for screenshot_edit_label (8754981973544133050) --> - <skip /> - <!-- no translation found for screenshot_edit_description (3333092254706788906) --> - <skip /> - <!-- no translation found for screenshot_scroll_label (7682877978685434621) --> - <skip /> - <!-- no translation found for screenshot_scroll_description (7855773867093272175) --> - <skip /> - <!-- no translation found for screenshot_dismiss_description (4702341245899508786) --> - <skip /> + <string name="screenshot_edit_label" msgid="8754981973544133050">"Modifiko"</string> + <string name="screenshot_edit_description" msgid="3333092254706788906">"Modifiko pamjen e ekranit"</string> + <string name="screenshot_scroll_label" msgid="7682877978685434621">"Lëviz"</string> + <string name="screenshot_scroll_description" msgid="7855773867093272175">"Lëviz në pamjen e ekranit"</string> + <string name="screenshot_dismiss_description" msgid="4702341245899508786">"Hiq pamjen e ekranit"</string> <string name="screenshot_preview_description" msgid="7606510140714080474">"Pamja paraprake e imazhit"</string> <string name="screenrecord_name" msgid="2596401223859996572">"Regjistruesi i ekranit"</string> <string name="screenrecord_background_processing_label" msgid="7244617554884238898">"Regjistrimi i ekranit po përpunohet"</string> diff --git a/packages/SystemUI/res/values-te/strings.xml b/packages/SystemUI/res/values-te/strings.xml index 578f62b85432..5fed052d9f5b 100644 --- a/packages/SystemUI/res/values-te/strings.xml +++ b/packages/SystemUI/res/values-te/strings.xml @@ -86,16 +86,11 @@ <string name="screenshot_failed_to_save_unknown_text" msgid="1506621600548684129">"స్క్రీన్షాట్ తీయడానికి మళ్లీ ప్రయత్నించండి"</string> <string name="screenshot_failed_to_save_text" msgid="8344173457344027501">"నిల్వ స్థలం పరిమితంగా ఉన్న కారణంగా స్క్రీన్షాట్ను సేవ్ చేయడం సాధ్యపడదు"</string> <string name="screenshot_failed_to_capture_text" msgid="7818288545874407451">"స్క్రీన్షాట్లు తీయడానికి యాప్ లేదా మీ సంస్థ అనుమతించలేదు"</string> - <!-- no translation found for screenshot_edit_label (8754981973544133050) --> - <skip /> - <!-- no translation found for screenshot_edit_description (3333092254706788906) --> - <skip /> - <!-- no translation found for screenshot_scroll_label (7682877978685434621) --> - <skip /> - <!-- no translation found for screenshot_scroll_description (7855773867093272175) --> - <skip /> - <!-- no translation found for screenshot_dismiss_description (4702341245899508786) --> - <skip /> + <string name="screenshot_edit_label" msgid="8754981973544133050">"ఎడిట్ చేయండి"</string> + <string name="screenshot_edit_description" msgid="3333092254706788906">"స్క్రీన్షాట్ను ఎడిట్ చేయండి"</string> + <string name="screenshot_scroll_label" msgid="7682877978685434621">"స్క్రోల్ చేయి"</string> + <string name="screenshot_scroll_description" msgid="7855773867093272175">"స్క్రీన్షాట్కు స్క్రోల్ చేయండి"</string> + <string name="screenshot_dismiss_description" msgid="4702341245899508786">"స్క్రీన్షాట్ను విస్మరించు"</string> <string name="screenshot_preview_description" msgid="7606510140714080474">"స్క్రీన్షాట్ ప్రివ్యూ"</string> <string name="screenrecord_name" msgid="2596401223859996572">"స్క్రీన్ రికార్డర్"</string> <string name="screenrecord_background_processing_label" msgid="7244617554884238898">"స్క్రీన్ రికార్డింగ్ అవుతోంది"</string> @@ -128,7 +123,7 @@ <string name="installer_cd_button_title" msgid="5499998592841984743">"Macకు Android ఫైల్ బదిలీ యాప్ ఇన్స్టాల్ చేయండి"</string> <string name="accessibility_back" msgid="6530104400086152611">"వెనుకకు"</string> <string name="accessibility_home" msgid="5430449841237966217">"హోమ్"</string> - <string name="accessibility_menu" msgid="2701163794470513040">"మెను"</string> + <string name="accessibility_menu" msgid="2701163794470513040">"మెనూ"</string> <string name="accessibility_accessibility_button" msgid="4089042473497107709">"యాక్సెస్ సామర్థ్యం"</string> <string name="accessibility_rotate_button" msgid="1238584767612362586">"స్క్రీన్ను తిప్పండి"</string> <string name="accessibility_recent" msgid="901641734769533575">"ఓవర్వ్యూ"</string> @@ -932,7 +927,7 @@ <string name="tuner_minus" msgid="5258518368944598545">"తీసివేత చిహ్నం"</string> <string name="tuner_left" msgid="5758862558405684490">"ఎడమ"</string> <string name="tuner_right" msgid="8247571132790812149">"కుడి"</string> - <string name="tuner_menu" msgid="363690665924769420">"మెను"</string> + <string name="tuner_menu" msgid="363690665924769420">"మెనూ"</string> <string name="tuner_app" msgid="6949280415826686972">"<xliff:g id="APP">%1$s</xliff:g> అనురవర్తనం"</string> <string name="notification_channel_alerts" msgid="3385787053375150046">"హెచ్చరికలు"</string> <string name="notification_channel_battery" msgid="9219995638046695106">"బ్యాటరీ"</string> diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java index 8415368fe931..9b7cf6e85ada 100644 --- a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java +++ b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java @@ -16,9 +16,11 @@ package com.android.systemui.people.widget; +import android.app.NotificationChannel; import android.content.ComponentName; import android.content.Context; import android.os.ServiceManager; +import android.os.UserHandle; import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.util.Log; @@ -130,6 +132,18 @@ public class PeopleSpaceWidgetManager { if (DEBUG) Log.d(TAG, "onNotificationsInitialized"); updateWidgets(); } + + @Override + public void onNotificationChannelModified( + String pkgName, + UserHandle user, + NotificationChannel channel, + int modificationType) { + if (DEBUG) Log.d(TAG, "onNotificationChannelModified"); + if (channel.isConversation()) { + updateWidgets(); + } + } }; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java index f9d2d31dbfd4..7f31fddbfb6c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java @@ -22,6 +22,7 @@ import static com.android.systemui.statusbar.phone.StatusBar.DEBUG; import android.annotation.NonNull; import android.annotation.SuppressLint; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.ComponentName; import android.content.Context; @@ -159,6 +160,19 @@ public class NotificationListener extends NotificationListenerWithPlugins { } @Override + public void onNotificationChannelModified( + String pkgName, UserHandle user, NotificationChannel channel, int modificationType) { + if (DEBUG) Log.d(TAG, "onNotificationChannelModified"); + if (!onPluginNotificationChannelModified(pkgName, user, channel, modificationType)) { + mMainHandler.post(() -> { + for (NotificationHandler handler : mNotificationHandlers) { + handler.onNotificationChannelModified(pkgName, user, channel, modificationType); + } + }); + } + } + + @Override public void onSilentStatusBarIconsVisibilityChanged(boolean hideSilentStatusIcons) { for (NotificationSettingsListener listener : mSettingsListeners) { listener.onStatusBarIconsBehaviorChanged(hideSilentStatusIcons); @@ -229,6 +243,14 @@ public class NotificationListener extends NotificationListenerWithPlugins { void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap, int reason); void onNotificationRankingUpdate(RankingMap rankingMap); + /** Called after a notification channel is modified. */ + default void onNotificationChannelModified( + String pkgName, + UserHandle user, + NotificationChannel channel, + int modificationType) { + } + /** * Called after the listener has connected to NoMan and posted any current notifications. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java index 1710daa16735..09ae7eb38a06 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coalescer/GroupCoalescer.java @@ -19,6 +19,8 @@ package com.android.systemui.statusbar.notification.collection.coalescer; import static java.util.Objects.requireNonNull; import android.annotation.MainThread; +import android.app.NotificationChannel; +import android.os.UserHandle; import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; @@ -158,6 +160,15 @@ public class GroupCoalescer implements Dumpable { public void onNotificationsInitialized() { mHandler.onNotificationsInitialized(); } + + @Override + public void onNotificationChannelModified( + String pkgName, + UserHandle user, + NotificationChannel channel, + int modificationType) { + mHandler.onNotificationChannelModified(pkgName, user, channel, modificationType); + } }; private void maybeEmitBatch(StatusBarNotification sbn) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationListenerWithPlugins.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationListenerWithPlugins.java index 9e561d13f347..4651e8446059 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationListenerWithPlugins.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationListenerWithPlugins.java @@ -14,9 +14,11 @@ package com.android.systemui.statusbar.phone; +import android.app.NotificationChannel; import android.content.ComponentName; import android.content.Context; import android.os.RemoteException; +import android.os.UserHandle; import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; @@ -78,7 +80,7 @@ public class NotificationListenerWithPlugins extends NotificationListenerService /** * Called when listener receives a onNotificationPosted. - * Returns true to indicate this callback should be skipped. + * Returns true if there's a plugin determining to skip the default callbacks. */ public boolean onPluginNotificationPosted(StatusBarNotification sbn, final RankingMap rankingMap) { @@ -92,7 +94,7 @@ public class NotificationListenerWithPlugins extends NotificationListenerService /** * Called when listener receives a onNotificationRemoved. - * Returns true to indicate this callback should be skipped. + * Returns true if there's a plugin determining to skip the default callbacks. */ public boolean onPluginNotificationRemoved(StatusBarNotification sbn, final RankingMap rankingMap) { @@ -104,6 +106,20 @@ public class NotificationListenerWithPlugins extends NotificationListenerService return false; } + /** + * Called when listener receives a onNotificationChannelModified. + * Returns true if there's a plugin determining to skip the default callbacks. + */ + public boolean onPluginNotificationChannelModified( + String pkgName, UserHandle user, NotificationChannel channel, int modificationType) { + for (NotificationListenerController plugin : mPlugins) { + if (plugin.onNotificationChannelModified(pkgName, user, channel, modificationType)) { + return true; + } + } + return false; + } + public RankingMap onPluginRankingUpdate(RankingMap rankingMap) { return getCurrentRanking(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java index 8ceebebe9a5b..3e44fa4a9b2b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java @@ -16,6 +16,8 @@ package com.android.systemui.people.widget; +import static android.app.NotificationManager.IMPORTANCE_HIGH; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; @@ -26,8 +28,10 @@ import static org.mockito.Mockito.when; import static java.util.Objects.requireNonNull; +import android.app.NotificationChannel; import android.content.Context; import android.os.RemoteException; +import android.os.UserHandle; import android.testing.AndroidTestingRunner; import androidx.test.filters.SmallTest; @@ -56,6 +60,10 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { private static final String TEST_PACKAGE_A = "com.test.package_a"; private static final String TEST_PACKAGE_B = "com.test.package_b"; + private static final String TEST_CHANNEL_ID = "channel_id"; + private static final String TEST_CHANNEL_NAME = "channel_name"; + private static final String TEST_PARENT_CHANNEL_ID = "parent_channel_id"; + private static final String TEST_CONVERSATION_ID = "conversation_id"; private PeopleSpaceWidgetManager mManager; @@ -100,7 +108,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { } @Test - public void testNotifyAppWidgetIfWidgets() throws RemoteException { + public void testNotifyAppWidgetIfNotificationPosted() throws RemoteException { int[] widgetIdsArray = {1}; when(mIAppWidgetService.getAppWidgetIds(any())).thenReturn(widgetIdsArray); @@ -117,7 +125,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { } @Test - public void testNotifyAppWidgetTwiceIfTwoNotifications() throws RemoteException { + public void testNotifyAppWidgetTwiceIfTwoNotificationsPosted() throws RemoteException { int[] widgetIdsArray = {1, 2}; when(mIAppWidgetService.getAppWidgetIds(any())).thenReturn(widgetIdsArray); @@ -149,4 +157,40 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { verify(mIAppWidgetService, times(2)) .notifyAppWidgetViewDataChanged(any(), eq(widgetIdsArray), anyInt()); } + + @Test + public void testDoNotNotifyAppWidgetIfNonConversationChannelModified() throws RemoteException { + int[] widgetIdsArray = {1}; + when(mIAppWidgetService.getAppWidgetIds(any())).thenReturn(widgetIdsArray); + + NotificationChannel channel = + mNoMan.createNotificationChannel(TEST_CHANNEL_ID, TEST_CHANNEL_NAME); + + mNoMan.issueChannelModification(TEST_PACKAGE_A, + UserHandle.getUserHandleForUid(0), channel, IMPORTANCE_HIGH); + mClock.advanceTime(MIN_LINGER_DURATION); + + verify(mIAppWidgetService, never()).getAppWidgetIds(any()); + verify(mIAppWidgetService, never()).notifyAppWidgetViewDataChanged(any(), any(), anyInt()); + + } + + @Test + public void testNotifyAppWidgetIfConversationChannelModified() throws RemoteException { + int[] widgetIdsArray = {1}; + when(mIAppWidgetService.getAppWidgetIds(any())).thenReturn(widgetIdsArray); + + NotificationChannel channel = + mNoMan.createNotificationChannel(TEST_CHANNEL_ID, TEST_CHANNEL_NAME); + channel.setConversationId(TEST_PARENT_CHANNEL_ID, TEST_CONVERSATION_ID); + + mNoMan.issueChannelModification(TEST_PACKAGE_A, + UserHandle.getUserHandleForUid(0), channel, IMPORTANCE_HIGH); + mClock.advanceTime(MIN_LINGER_DURATION); + + verify(mIAppWidgetService, times(1)).getAppWidgetIds(any()); + verify(mIAppWidgetService, times(1)) + .notifyAppWidgetViewDataChanged(any(), eq(widgetIdsArray), anyInt()); + + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NoManSimulator.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NoManSimulator.java index c113df0b4ee7..1bfe10c5263b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NoManSimulator.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NoManSimulator.java @@ -16,8 +16,12 @@ package com.android.systemui.statusbar.notification.collection; +import static android.app.NotificationManager.IMPORTANCE_DEFAULT; + import static org.junit.Assert.assertNotNull; +import android.app.NotificationChannel; +import android.os.UserHandle; import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; @@ -72,6 +76,17 @@ public class NoManSimulator { } } + public NotificationChannel createNotificationChannel(String id, String name) { + return new NotificationChannel(id, name, IMPORTANCE_DEFAULT); + } + + public void issueChannelModification( + String pkg, UserHandle user, NotificationChannel channel, int modificationType) { + for (NotificationHandler listener : mListeners) { + listener.onNotificationChannelModified(pkg, user, channel, modificationType); + } + } + public void setRanking(String key, Ranking ranking) { mRankings.put(key, ranking); } |