For a very long time, there wasn\'t an official API for blocking calls on Android.
What developers did for CallerId and call-blocking apps, is to us
It should be quite easy with the new Android P API. Your app needs to request the permission Manifest.permission.ANSWER_PHONE_CALLS. Then you can call the method endCall of TelecomManager class doc here.
Manifest.permission.ANSWER_PHONE_CALLS
endCall
TelecomManager