A while back I created a small app to kill off the telemarketers .. it worked OK on my old galaxy fit.
It would error on incoming private numbers (-1 , -2 ??). never got around to fixing it and have no need of it anymore.
it basically uses a service and Phone events(Core) to monitor the phone state.
on "Ringing" if the number was in the barred list the below library would answer the call .. and after short interval hang up.
I offer the app as a start to your project.
It would be a good idea to read thru the thread before grabbing the lib.
specially the last post .. something about it don't work anymore under Lolipop... !
Answer Call library ..
also include reflection lib ..