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 - "simple-phone" ) 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 which doesn't have the UI of the during-call, another here which has some issues with call-log, and has a lot of deprecated and forbidden things being used ), 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 :
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.
And yet somehow developers managed to make it work. If you try out "Lineage OS Phone" app from ApkMirror, you will most likely have it working fine, especially if you use v11 instead of v19 (v19 worked for me on Pixel 2 but not on Note 8, yet v11 worked on both).
It is also said that Google's Dialer is now available on more and more devices (here), but for some reason I don't see it available for many (tested on Note 8).
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...
So far, the only thing that worked for me is to use one of the sample repositories (here) , and made a working fork of it (here), but as I wrote it has various issues, such as not able to handle call-logs, and when I try to update its targetSdk, it has some DB issues (like what's written here). Maybe even more issues that I didn't notice.
Update: found yet another repository, here ("Koler"), that generally works fine. Not the AOSP one, but can help in some cases to understand how things work.
The questions
How can I clone the latest version of the Dialer app and use it? What are the steps to achieve a build-able project ?
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) ?
Alternatively to the one of Vanilla Android OS (meaning if there is no good solution to using it), is it possible to do it for a custom ROM that gets updated from time to time, like Lineage OS ?