@@ -37,8 +37,6 @@ public class NotificationUtils {
37
37
public static String NOTIFICATION_MESSAGE = "notification_message" ;
38
38
public static String NOTIFICATION_TITLE = "notification_title" ;
39
39
40
- private static final Map <String , Object > autoReply = ReflexPlugin .autoReply ;
41
-
42
40
private static final List <String > listeningPackageNameList = ReflexPlugin .packageNameList ;
43
41
private static final List <String > listeningExceptionPackageNameList = ReflexPlugin .packageNameExceptionList ;
44
42
@@ -114,47 +112,50 @@ public static String getTitleRaw(StatusBarNotification sbn) {
114
112
static boolean canReply (StatusBarNotification notification ) {
115
113
String notificationPackageName = notification .getPackageName ();
116
114
117
- boolean isServiceEnabled = false ;
118
115
List <String > autoReplyPackageNameList = null ;
119
116
117
+ final Map <String , Object > autoReply = ReflexPlugin .autoReply ;
118
+
120
119
if (autoReply != null ) {
121
- isServiceEnabled = true ;
120
+
122
121
autoReplyPackageNameList = (List <String >) autoReply .get ("packageNameList" );
122
+
123
+ return isSupportedPackage (notificationPackageName ,autoReplyPackageNameList ) &&
124
+ checkListeningAndReplyPackages (notificationPackageName ,autoReplyPackageNameList ) &&
125
+ NotificationUtils .isNewNotification (notification );
123
126
}
124
127
125
128
// 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 ;
131
130
}
132
131
133
132
private static boolean checkListeningAndReplyPackages (String notificationPackageName ,
134
133
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 ){
141
134
142
- return !listeningExceptionPackageNameList .contains (notificationPackageName );
143
- }
144
- else {
135
+ if (listeningPackageNameList == null && listeningExceptionPackageNameList == null &&
136
+ replyPackageNameList == null ) {
145
137
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 );
146
144
}
145
+
146
+ return listeningPackageNameList .contains (notificationPackageName );
147
147
}
148
148
149
149
@ 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 ) {
151
152
// If packageNameList coming from flutter is null,
152
153
// then AutoReply is enabled for all packageNames
153
- if (packageList == null ) {
154
+ if (replyPackageNameList == null ) {
154
155
return true ;
155
156
}
156
157
157
158
// Check notification's package name contained in AutoReply's PackageNameList
158
- return packageList .contains (notificationPackageName );
159
+ return replyPackageNameList .contains (notificationPackageName );
159
160
}
160
161
}
0 commit comments