@@ -37,8 +37,6 @@ public class NotificationUtils {
3737 public static String NOTIFICATION_MESSAGE = "notification_message" ;
3838 public static String NOTIFICATION_TITLE = "notification_title" ;
3939
40- private static final Map <String , Object > autoReply = ReflexPlugin .autoReply ;
41-
4240 private static final List <String > listeningPackageNameList = ReflexPlugin .packageNameList ;
4341 private static final List <String > listeningExceptionPackageNameList = ReflexPlugin .packageNameExceptionList ;
4442
@@ -114,47 +112,50 @@ public static String getTitleRaw(StatusBarNotification sbn) {
114112 static boolean canReply (StatusBarNotification notification ) {
115113 String notificationPackageName = notification .getPackageName ();
116114
117- boolean isServiceEnabled = false ;
118115 List <String > autoReplyPackageNameList = null ;
119116
117+ final Map <String , Object > autoReply = ReflexPlugin .autoReply ;
118+
120119 if (autoReply != null ) {
121- isServiceEnabled = true ;
120+
122121 autoReplyPackageNameList = (List <String >) autoReply .get ("packageNameList" );
122+
123+ return isSupportedPackage (notificationPackageName ,autoReplyPackageNameList ) &&
124+ checkListeningAndReplyPackages (notificationPackageName ,autoReplyPackageNameList ) &&
125+ NotificationUtils .isNewNotification (notification );
123126 }
124127
125128 // If AutoReply object coming from flutter side is null, AutoReply feature is disabled
126- if (!isServiceEnabled ) return false ;
127-
128- return isSupportedPackage (notificationPackageName ,autoReplyPackageNameList ) &&
129- checkListeningAndReplyPackages (notificationPackageName ,autoReplyPackageNameList ) &&
130- NotificationUtils .isNewNotification (notification );
129+ return false ;
131130 }
132131
133132 private static boolean checkListeningAndReplyPackages (String notificationPackageName ,
134133 List <String > replyPackageNameList ) {
135- if (listeningPackageNameList == null && listeningExceptionPackageNameList == null && replyPackageNameList == null ){
136- return true ;
137- }else if (listeningPackageNameList == null && listeningExceptionPackageNameList == null ){
138- return replyPackageNameList .contains (notificationPackageName );
139- }
140- else if (listeningPackageNameList == null ){
141134
142- return !listeningExceptionPackageNameList .contains (notificationPackageName );
143- }
144- else {
135+ if (listeningPackageNameList == null && listeningExceptionPackageNameList == null &&
136+ replyPackageNameList == null ) {
145137 return true ;
138+ } else if (listeningExceptionPackageNameList == null && listeningPackageNameList == null ) {
139+ return replyPackageNameList .contains (notificationPackageName );
140+ } else if (listeningPackageNameList == null && replyPackageNameList == null ) {
141+ return !listeningExceptionPackageNameList .contains (notificationPackageName );
142+ } else if (listeningPackageNameList == null ) {
143+ return replyPackageNameList .contains (notificationPackageName );
146144 }
145+
146+ return listeningPackageNameList .contains (notificationPackageName );
147147 }
148148
149149 @ RequiresApi (api = Build .VERSION_CODES .JELLY_BEAN_MR2 )
150- private static boolean isSupportedPackage (String notificationPackageName , List <String > packageList ) {
150+ private static boolean isSupportedPackage (String notificationPackageName ,
151+ List <String > replyPackageNameList ) {
151152 // If packageNameList coming from flutter is null,
152153 // then AutoReply is enabled for all packageNames
153- if (packageList == null ) {
154+ if (replyPackageNameList == null ) {
154155 return true ;
155156 }
156157
157158 // Check notification's package name contained in AutoReply's PackageNameList
158- return packageList .contains (notificationPackageName );
159+ return replyPackageNameList .contains (notificationPackageName );
159160 }
160161}
0 commit comments