Joke Collection Website - Public benefit messages - Can I send text messages after being blocked?

Can I send text messages after being blocked?

Yes.

As long as the phone is turned on and has a signal, you can receive the other party's message. When set to reject calls or blacklist, if the other party sends a text message, the phone can still receive the text message. The text message is saved in your phone's blacklist or rejected call record. In addition to the rejected call record, the record also contains SMS interception records.

SMS interception is actually a relatively simple one. There are many related introductions on the Internet. Here we mainly introduce some of the problems encountered during the writing process.

First of all, the implementation principle of SMS interception is to monitor the broadcast of SMS messages, and then determine the number of the SMS message to determine whether it is in the blacklist. If so, just use the abortBroadcast method to end the broadcast delivery. The most important problem in the process is not to receive the monitoring, but to receive the monitoring first. Because the broadcast of SMS is an orderly broadcast, then whoever receives the broadcast first will have the right to end the broadcast delivery, so What we are actually doing is trying to find a way to maximize our permission to receive broadcasts. There are two main methods here. One is to set the permission value to the maximum value, and the other is to set the registration method to dynamic registration.

Setting the maximum authority actually means setting the priority when registering for broadcast to the maximum. The Android system API states that the maximum authority is 1000, but in fact, what is received is an int value, and the system has no judgment value. is online, so we can set the maximum value of int, this permission is the highest.

So if they all have maximum permissions, who has the higher priority? Then it is the second point, dynamic registration for monitoring, because the broadcast registered dynamically in the source code is put into the listening list before the static broadcast. , so we use dynamic registration to set up monitoring here.

If everyone uses dynamic registration, who will receive it first? This seems to be related to the package name of the application. I don’t understand the details. It probably means the installation time. The earlier, the higher the priority. The higher the alias order of the package name in the system, the higher the priority (not the alphabetical order of the package names we wrote).

Then let’s take a look at the specific implementation. First, build a service, and then ensure that the service always runs in the background (you can use daemon processes, monitor boot broadcasts, etc. to ensure that it always exists), and then in the service Register broadcast and unregister in onStartCommand and onDestroy methods respectively.