add SpamBlocker to BlockingManager - #802
Conversation
|
@aj3423 you're a legend for doing this, greatly appreciated! |
0ff6e01 to
2f1d5eb
Compare
Inhishonor
left a comment
There was a problem hiding this comment.
Thank you very much for this!
I have a few general questions:
- Should a general interface be defined elsewhere and then a new app has to just extend that interface for everything it would like to use?
- Should an interface be defined and the protocol to be expanded for automatic detection of all apps with the
PublicSMSScreeningService?
Do you want to implement any of these comments, or do you want me to take this over? (No problem either way)
| // If either version of Should I Answer? is installed and SIA is enabled, build the | ||
| // intent to request a rating |
There was a problem hiding this comment.
Not understanding this comment. Is it necessary?
| const val action = "sms.screening.provider.PublicSMSScreeningService" | ||
|
|
||
| const val smsScreening = 1 | ||
| const val smsScreeningResult = 2 | ||
|
|
||
| // request | ||
| const val keyNumber = "number" | ||
| const val keySmsContent = "smsContent" | ||
| const val keySimSlot = "simSlot" | ||
|
|
||
| // response | ||
| const val keyShouldBlock = "shouldBlock" | ||
| const val keyReason = "reason" // Why the message is blocked or allowed | ||
| } |
There was a problem hiding this comment.
Maybe this should be moved to a specific file or module where all of the protocol related things should live? Rather than redefining it for every new app.
| const val action = "sms.screening.provider.PublicSMSScreeningService" | ||
|
|
||
| const val smsScreening = 1 | ||
| const val smsScreeningResult = 2 | ||
|
|
||
| // request | ||
| const val keyNumber = "number" | ||
| const val keySmsContent = "smsContent" | ||
| const val keySimSlot = "simSlot" | ||
|
|
||
| // response | ||
| const val keyShouldBlock = "shouldBlock" | ||
| const val keyReason = "reason" // Why the message is blocked or allowed | ||
| } | ||
|
|
||
|
|
||
| const val SpamBlockerPackageName = "spam.blocker" |
There was a problem hiding this comment.
All of the const vals need to be upper case with underscores.
| // If the intent isn't null, bind the service and wait for a result. Otherwise, don't block | ||
| if (intent != null) { | ||
| val r = context.bindService(intent, this, Context.BIND_AUTO_CREATE) | ||
| Log.i("quik spamblocker", "bind service: $r") |
There was a problem hiding this comment.
Please use Timber here.
| what = Protocol.smsScreening | ||
| data = bundleOf(Protocol.keyNumber to address) | ||
| replyTo = Messenger(IncomingHandler { response -> | ||
| Log.i("quik spamblocker", "shouldBlock: ${response.shouldBlock}") |
I don't know, i'm okay with either. An interface doesn't seem necessary as the current protocol is just some integers/strings, it will definitely be useful later on for complex features like timeout handling. Maybe we can start simple and see.
Here's the code for client listing: https://github.com/aj3423/sms_screening_demo/blob/0df225a50fe3928b632354b71df8ee480f14c0c7/demo_sms_app/src/main/java/demo/sms/app/Client.kt#L196-L206 That code is an demo SMS app, it also handles timeout. (the repo is AI generated)
Please take over this and feel free to change anything, I'll update SpamBlocker accordingly. |
|
This is the most important PR SpamBlocker shows what, why, and has really smart features like allowing everything for a few hours if you call 911, or pizza updates if you just used the pizza app. I only wish it worked on voicemail |

Add app SpamBlocker as a screening provider, for SMS content screening.