[Tasker Tips & Tricks] Loganberry:
Apologies for resurrecting an older thread, but a few minutes ago I just worked out how to do exactly what the OP asked:

answer and immediately hang up to effectively block unwanted calls

.

I've created a rudimentary answer-and-hang-up call blocker, in Tasker, on Oreo, on a Sony Xperia X Compact, which is

not rooted

. I don't yet want to root my phone because Sony still provides monthly OS updates, I don't object to the Sony UI, and skvalex's Call Recorder works happily on this non-rooted phone. Once Sony turns off the update tap, then I'll investigate rooting it.

I cannot vouch that my experience will work for everyone on every device. All I can say is, it works for me. If it doesn't work for you, tinker with the various options to see if it can be made to work on your phone.

I don't want to reject calls, because then they go to voicemail and I can't be bothered with the effort of calling my voicemail to delete them. Instead, I want to answer the calls and then hang up, so there's no voicemail to handle. On my phone, the End Call task doesn't cancel the unanswered call; it sends it to voicemail.

I also want wildcard blocking because scammers often spoof caller IDs from area code prefixes which simply don't exist in the UK. I want to block all calls from fake area codes.

Extreme Call Blocker used to do both answer-and-hang-up and wildcard blocking, and was well worth the low purchase price. Unfortunately, it no longer does what it's supposed to do. The app hasn't been updated since 2016 so my suspicion is that newer versions of Android have changed things which ECB relied on. In addition, the developer's domain expired a month ago, so I'm not holding out much hope for an update to the app.

Call Control does have an answer-and-hang-up feature, which works as advertised, but the wildcard blocking does not work. At least, not on my phone. Perhaps it works for other people.

I tried a few other blockers but they all seemed to send the callers to voicemail. I got bored of testing call blocking apps at this point and figured I'd create my own.

So that's the introduction. Now on to the how-to.

This requires two apps, both of which are paid-for (but definitely worth the couple of quid asking price):

Tasker

AutoNotification

In Tasker:

Create a profile based on the Event "Phone Ringing". Add the number blocklist to the optional Caller field, using wildcards if required (for example 020* will block all calls from London). Use / as a separator, e.g. 020*/01234*/0870* etc.

Add these Tasks:

Task -> Wait -> 1 second (adjust timing for your preference)

Plugin -> AutoNotification -> Query (Configure the Apps section to intercept notifications from Phone.)

Plugin -> AutoNotification -> Actions (Configure the Intercept Action ID with the appropriate variable from the above Query. On my phone it's %anbutton2action() - yours may well differ.)

Task -> Wait -> 2 seconds (as before, adjust timing for your preference)

Phone -> End Call

It's not elegant, and requires manual updates of the Caller data in the Tasker Event, but it does what I want it to do.

If someone wants to update Extreme Call Blocker, or fix the wildcard handling of Call Control, then I'll ditch this in a heartbeat. But for now it meets my needs (and hopefully those of the OP, too).

Some additional background: In the UK (and maybe elsewhere), callers pay the termination fee to call a mobile phone, unlike in the USA and Canada where the recipient pays the termination fee. I'm in the UK so I like to answer the calls and hang up, so that the scammers get charged. Or, whoever is providing services to the scammers gets charged. Either way, if enough people do this, and the aggregate monetary cost is significant, then someone might take action to cut the scammers off.

It's a slim hope, I know, but you do what you can, right?