Search code examples
androidcordovaionic-frameworkcallkitsim-card

How can I avoid having my hybrid app showing up on the Android dialer?


I built a calling app for Android and iOS and I'm using Callkit for the calling interface.

This is a hybrid app developed with Ionic and Cordova.

My problem is that in some android devices (not all), my app shows up (as an option) when the user wants to call someone via SIM card. And I don't want that to happen.

I've tried to fix it through the phone settings, and I can get it done, but as soon as I enter my app, it happens again ever since.

This is the fork of the plugin I'm using:

https://github.com/Qvadis/cordova-plugin-callkit

I've done some research and I saw that could be related to this code:

if(android.os.Build.VERSION.SDK_INT >= 23) {
    phoneAccount = new PhoneAccount.Builder(handle, appName)
               .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
               .build();
    tm.registerPhoneAccount(phoneAccount);
 }

However, if I comment it, the callkit UI doesn't show.

Can someone shed some light here?

Thank you, Borja.


Solution

  • I found the solution:

    Apparently it was that CAPABILITY_CALL_PROVIDER, the one that was registering my app able to call from within the telephony stack.

    Let me copy the code I found from googles PhoneAccount class:

    public class PhoneAccount implements Parcelable {
    /**
     * Flag indicating that this {@code PhoneAccount} can act as a connection manager for
     * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount}
     * will be allowed to manage phone calls including using its own proprietary phone-call
     * implementation (like VoIP calling) to make calls instead of the telephony stack.
     * <p>
     * When a user opts to place a call using the SIM-based telephony stack, the
     * {@link ConnectionService} associated with this {@code PhoneAccount} will be attempted first
     * if the user has explicitly selected it to be used as the default connection manager.
     * <p>
     * See {@link #getCapabilities}
     */
    public static final int CAPABILITY_CONNECTION_MANAGER = 0x1;
    /**
     * Flag indicating that this {@code PhoneAccount} can make phone calls in place of
     * traditional SIM-based telephony calls. This account will be treated as a distinct method
     * for placing calls alongside the traditional SIM-based telephony stack. This flag is
     * distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage
     * calls from or use the built-in telephony stack to place its calls.
     * <p>
     * See {@link #getCapabilities}
     * <p>
     * {@hide}
     */
    public static final int CAPABILITY_CALL_PROVIDER = 0x2;
    

    Instead of CAPABILITY_CALL_PROVIDER, I'm using CAPABILITY_CONNECTION_MANAGER. Same behaviour, but my app is no longer appearing as a valid calling app from the telephony stack.