@@ -125,6 +125,24 @@ class SpamUtils {
125125 }
126126 }
127127
128+ val isNumberInAgenda = isNumberInAgenda(context, number)
129+
130+ // Don't check number if is in contacts
131+ if (isNumberInAgenda) {
132+ return @launch
133+ }
134+
135+ if (shouldBlockNonContacts(context)) {
136+ handleSpamNumber(
137+ context,
138+ number,
139+ false ,
140+ context.getString(R .string.block_non_contact),
141+ callback
142+ )
143+ return @launch
144+ }
145+
128146 // End call if the number is already blocked
129147 if (blockedNumbers?.contains(number) == true ) {
130148 handleSpamNumber(
@@ -152,13 +170,6 @@ class SpamUtils {
152170 return @launch
153171 }
154172
155- if (isNumberWhitelisted(context, number) ||
156- isNumberBlocked(context, number) ||
157- isContactOrShouldBlockNonContacts(context, number)
158- ) {
159- return @launch
160- }
161-
162173 if (isInternationalCall(number) && shouldBlockInternationalNumbers(context)) {
163174 handleSpamNumber(
164175 context,
@@ -221,26 +232,6 @@ class SpamUtils {
221232 return @coroutineScope isSpam
222233 }
223234
224- private fun isContactOrShouldBlockNonContacts (context : Context , number : String ): Boolean {
225- if (ContextCompat .checkSelfPermission(
226- context,
227- Manifest .permission.READ_CONTACTS
228- ) == PackageManager .PERMISSION_GRANTED
229- ) {
230- if (isNumberInAgenda(context, number)) return true
231- if (shouldBlockNonContacts(context)) {
232- handleSpamNumber(
233- context,
234- number,
235- false ,
236- context.getString(R .string.block_non_contact),
237- {})
238- return true
239- }
240- }
241- return false
242- }
243-
244235 private fun buildSpamCheckers (context : Context ): List <suspend (String ) -> Boolean > {
245236 val spamCheckers = mutableListOf< suspend (String ) -> Boolean > ()
246237
0 commit comments