Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a third-party app implement CallScreeningService in android 7?

Android API level 24 introduces a new Service called the CallScreeningService. The documentation says that the service can by implemented by the default dialer to screen incoming calls. I would like to implement this service in my own app, preferably without creating an entire dialer app, but a simple naive implementation seems to be ignored by the OS when an incoming call happens.

AndroidManifest.xml snippet:

<service android:name="com.example.callbouncer.CallService" android:permission="android.permission.BIND_SCREENING_SERVICE">
    <intent-filter>
        <action android:name="android.telecom.CallScreeningService"/>
    </intent-filter>
</service>

CallService.java:

// imports...
public class CallService extends CallScreeningService {
    @Override
    public void onScreenCall(Call.Details callDetails) {
        CallResponse.Builder response = new CallResponse.Builder();
        Log.e("CallBouncer", "Call screening service triggered");
        respondToCall(callDetails, response.build() );
    }
}

There are no errors while building or installing this program, but the screening doesn't seem to be taking place. Have I done something wrong (like the manifest or missing implementations/overrides in the service) or is it just not possible? If it's not possible in a small app like this, will it be possible if I implement an entire dialing app and set it as the default dialer? Finally, if that's the case, is there anything preventing me from just forking the dialer out of the AOSP and adding my features to it?

like image 512
Segfault Avatar asked Apr 25 '17 17:04

Segfault


2 Answers

As of Android 10 (API 29+), you can have a CallScreeningService without the requirement of also implementing an entire dialer app. Until Android 10, only the default dialer app's call CallScreeningService would be invoked.

https://developer.android.com/about/versions/10/features#call-screening

Don't get too excited though, because it's very buggy and does not work as the documentation says it does:

  • CallScreeningService#onScreenCall is called for known contacts
  • CallScreeningService#setSkipCallLog doesn't show blocked calls in the call log

My workaround for getting called for known contacts was to ask the user for contact access and check if the incoming caller was in the user's contacts. There is no workaround for the other issues at the moment.

I made a very basic screening app that declines all calls from numbers not in the user's contacts you can use an an example if you like: https://github.com/joshfriend/gofccyourself

like image 108
Josh Avatar answered Sep 30 '22 02:09

Josh


Looking at the docs you linked to:

This service can be implemented by the default dialer (see getDefaultDialerPackage()) to allow or disallow incoming calls before they are shown to a user.

Don't think you can do this in a separate app (at least with the current interface: I'd expect in the not too distant feature it will be exposed).

like image 27
Femi Avatar answered Sep 30 '22 03:09

Femi