Android Q has introduced CallRedirectionService
API - seems like one of the way 3rd party apps can use it is to cancel calls and reroute them over VoIP - essentially intercepting the phone calls.
I was trying to implement this class as below
public class CallMonitorService extends CallRedirectionService {
private static final String TAG = "CallMonitorService";
public CallMonitorService() {
}
@Override
public void onPlaceCall(Uri uri, PhoneAccountHandle phoneAccountHandle, boolean b) {
Log.e(TAG, "onPlaceCall:### ");
}
}
As you can see I am overriding onPlaceCall
which is abstract method in the CallRedirectionService
and simply keeping a log statement to check/test if this callback method hook is invoked by Android framework.
I added this service in my Manifest.xml as well as below, which is what is documented in the Source code of CallRedirectionService
class
<service
android:name=".CallMonitorService"
android:permission="android.permission.BIND_REDIRECTION_SERVICE"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.telecom.CallRedirectionService"/>
</intent-filter>
</service>
My Guess is that when Android system places a outgoing call this onPlaceCall
will be invoked and then we can write our custom code to do further action on the outgoing call. Am not 100% sure if this is how CallRedirectionService
is supposed to work - By the way there is no example available in developer.android.com for how to implement CallRedirectionService
as of this writing. I set both minSdkVersion 29
targetSdkVersion 29
in my build.gradle
However when the call is made - the onPlaceCall
inside my Service is not getting invoked.
I am using Android Q Emulator for testing as i do not have Android phone running Android Q to test this - can this be not tested on Android emulator by placing a emulated phone call or What else Am I missing?