Sunday, 21 April 2019

How to make a dialer based on Google's Android latest dialer app?

Background

Starting from Android M, it's possible to make a replacement to the dialer app of the OS, meaning that taking phone calls could show your own customized UI.

This is done by extending InCallService class, and having an Activity that handles dialing intents:

<service android:name="your.package.YourInCallServiceImplementation"
           android:permission="android.permission.BIND_INCALL_SERVICE">
       <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
       <meta-data android:name="android.telecom.IN_CALL_SERVICE_RINGING"
           android:value="true" />
       <intent-filter>
           <action android:name="android.telecom.InCallService"/>
       </intent-filter>
  </service>

<activity android:name="your.package.YourDialerActivity"
            android:label="@string/yourDialerActivityLabel">
       <intent-filter>
            <action android:name="android.intent.action.DIAL" />
            <category android:name="android.intent.category.DEFAULT" />
       </intent-filter>
  </activity>

And to request to be the default dialer, you can use:

private fun offerReplacingDefaultDialer() {
    if (getSystemService(TelecomManager::class.java).defaultDialerPackage != packageName) {
        startActivity( Intent(ACTION_CHANGE_DEFAULT_DIALER)
                .putExtra(EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, packageName))

    }
}

The problem

The API is so big that very few apps even tried such a thing, and when they did, they made a very minimal implementation compared to the built-in one. Even compared to Google's dialer.

Example of features that should be implemented, by just looking on the UI of the dialer during calls: mute, keypad, speaker, add call (conference), hold, various states, video calls (?), ...

What I've found

Trying to make my own solution, I've found a sample repository (here) that I've made my own fork of (here), only to find out how many things I should implement to make something that is at least as feature-rich as what Google offers.

I've also searched if others have cloned the Dialer before, but found out only 2, and they are quite old versions of the Dialer (one here, another here ), and with some bugs that I've stopped to even consider using.

So I tried to clone the project that I've found of Android itself, here. Sadly it has a very weird folders structure, that made it impossible to understand what should be done with it and how to even import it on the IDE :

enter image description here

enter image description here

enter image description here

But somehow the repositories that I've found had a different folders structure, meaning they know it should be modified somehow, or that it has changed since then.

I even tried to clone dialer apps from custom ROMs (searching on Github, here), but got similar issues.

It reminds me of so many problems I had when I tried to clone the launcher and make my own one (made repository here), back in Eclipse IDE time, 4 years ago. It's just weird to me that this would be as hard as it was for the launcher...

The questions

  1. How can I clone the latest version of the Dialer and use it? What are the steps to achieve a build-able project ?

  2. Why does it have to be so hard? Will the solution you offer work for other types of apps that are inside of Android (like the launcher, for example) ?



from How to make a dialer based on Google's Android latest dialer app?

No comments:

Post a Comment