File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
app/src/main/java/com/addev/listaspam Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ import androidx.annotation.RequiresApi
1919@RequiresApi(Build .VERSION_CODES .P )
2020class MyCallReceiver : BroadcastReceiver () {
2121
22+ companion object {
23+ private const val SPAM_PREFS = " SPAM_PREFS"
24+ private const val BLOCK_NUMBERS_KEY = " BLOCK_NUMBERS"
25+ }
26+
2227 private val spamUtils = SpamUtils ()
2328
2429 /* *
@@ -44,6 +49,15 @@ class MyCallReceiver : BroadcastReceiver() {
4449 * @param incomingNumber The incoming phone number.
4550 */
4651 private fun handleIncomingCall (context : Context , incomingNumber : String ) {
52+ val sharedPreferences = context.getSharedPreferences(SPAM_PREFS , Context .MODE_PRIVATE )
53+ val blockedNumbers = sharedPreferences.getStringSet(BLOCK_NUMBERS_KEY , null )
54+
55+ // End call if the number is already blocked
56+ if (blockedNumbers?.contains(incomingNumber) == true ) {
57+ endCall(context)
58+ return
59+ }
60+
4761 spamUtils.checkSpamNumber(context, incomingNumber) { isSpam ->
4862 if (isSpam) {
4963 endCall(context)
You can’t perform that action at this time.
0 commit comments