简体   繁体   中英

Block incoming SMS on rooted Android 4.4 and higher?

In accordance with the doc :

Note that—beginning with Android 4.4—any attempt by your app to abort the SMS_RECEIVED_ACTION broadcast will be ignored so all apps interested have the chance to receive it.

so, only default SMS app can do it and looks like nothing is changed with Android 5.0 (due to unknown reason, according issue is marked as Obsolete).

Is there any way to block incoming SMS for non-default SMS app if phone is rooted (this is is needed for spam-blocking app)? How to do it?

Make your app the default SMS provider. Then it can register for SMS_DELIVER_ACTION. In that receiver, you can choose to either write the SMS to the database or not. If you choose not to, the SMS is basically ignored. If you choose to, any other app can receive the SMS.

You could write a service that overrides CarrierMessagingService . If the bind to this is successful , then the message is not delivered to the main app.

BIND_CARRIER_MESSAGING_SERVICE permission required to register as carrier messaging service requires the app to be system app. So you need to push your app to the system.

You can try the following solution:

Iterate through list of packages capable of handling SMS and disable them programmatically.

To get an API to disable an app you will have to become an MDM(Mobile Device Management) partner app.OEMs provides additional APIs to their MDM partner apps to control the device.For example samsung provides api to disable specific app.I guess they also have APIs to control permission of specific apps.

Alternatively I guess the new android Device/Profile Owner mode must have an API to disable specific apps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM