How to make a dialer based on Google's Android latest dialer app (or of a Vanilla based ROM such as Lineage OS)?
Asked Answered
I

1

12

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 :

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.

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

  1. How can I clone the latest version of the Dialer app 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) ?

  3. 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 ?

Internuncial answered 19/4, 2019 at 6:31 Comment(16)
Have you try to create a jar or aar with the project and import it in your current project ?Hithermost
@Hithermost There is no such file, and even if there was, I'm interested in modifying the dialer, and not just use it. Why the downvote though?Internuncial
"What are the steps to achieve a build-able project ?" -- if by "build-able project" you mean an Android Studio project that compiles against the Android SDK, that is unlikely to be possible. AOSP projects usually depend upon non-public APIs, as they are not designed to be standalone apps, but part of a firmware build.Viscose
@Viscose And yet somehow people managed to do it. Try the Github repository. It still works. Maybe they removed some functionality in the process. Also, it's (or was) possible to download and install dialers from custom roms on akp-mirror website. In the past it was CM rom (worked even on SGS4), and now lineageos . For example search "Lineage OS Phone" on apkMirror website. v19 worked for me on Pixel 2 but not on note 8, but v11 worked on both . Probably needs some minor modificationsInternuncial
@Viscose I've updated the question with more information.Internuncial
@Viscose Anyway, if it was as simple as cloning a normal repository, I wouldn't have asked how people did it. I usually get things working on my own when the repository is ok.Internuncial
@androiddeveloper Keep in mind that installing an APK is different from building it. All the APKs that you found on the apk-mirror website (which are from Custom ROMs) were probably extracted from a full ROM, i.e. they were built with the AOSP build system. If you want to build the APK with Android Studio, you'll have to convert it to Gradle. To make it build successfully, you will have to replicate everything that is written in Android.mk (and every Makefile included by that) in Grade. Which is hard, if you look at all the libraries, dependencies, private APIs, etc.Karmakarmadharaya
@TimSchumacher OK, so if you know how to do it, put an answer showing the full details of how you think those developers did it, including a sample project to show that what you say is correct. I wouldn't have asked it if it was easy. If it was easy just a simple cloning would be enough. That's why I asked about it. I want a working project, like others have succeeded doing.Internuncial
Did this work for you github.com/arekolek/simple-phone? If you have the apk you can simply reverse engineer it to see the code.Send
@Send I've already mentioned inside the question that I've tried it, and even made a fork from it. It has the bare minimum: answer and reject calls. There are many things that exist in the real dialer and not here: mute, add call, keybpad, speaker, showing caller information&photo (including if not inside address book), hold call, maybe even video calls... and all of this by just looking at the UI. I'm sure there is much more than what you can see...Internuncial
This question might be too broad for a simple Q&A. There may not be a general solution for all such projects to make them buildable. Maybe the question should focus on a single one.Tow
@Trilarion The question is about a single one: The one that works. I don't care which one, as long as it's working (meaning that I can build one that gets updated from time to time). If someone wants to talk about multiple solutions it's even better, of course, but I think one solution is enough for me. I've mentioned all that I've tried because I wanted to share my experience with what I've done so far, and to show that I indeed tried to search for a solution.Internuncial
@androiddeveloper So you are asking for a recommendation of a tool or software (that is buildable and gets updated)? That's probably also off-topic because it may soon change. Nobody can make sure it will be updated or that it will remain buildable.Tow
@Trilarion I'm not asking for any tool or software here. Where do you see I've written such a thing? AOSP has a dialer inside. So does various custom ROMs. I already have the tools (I think) for this: Git (more specifically: "tortoise git") and Android-Studio as the IDE. Do you think I should need more? If there is a need for more software inside the solution, of course it should be written about, and if something has changed, I'm sure there will be a different software as alternative.Internuncial
@androiddeveloper Your question three is kind of asking for a software recommendation (which custom ROM does what I want). Question one is a very good one but kind of hard to answer (judging by the lack of answers).Tow
@Trilarion OK updated question 3, to make sure you understand that it's only an alternative, in case it's impossible to use the vanilla solution. I prefer vanilla, but if it's not possible, it's ok to use something similar that is about as good. There is the official one, and there are others. Some are quite similar to it, and might be easy enough to be used without too much work.Internuncial
K
2

How can I clone the latest version of the Dialer app and use it?

You can't. AOSP Dialer based projects heavily rely on the AOSP build system, internal libraries, and APIs, which simply aren't available outside of a full AOSP context.

What are the steps to achieve a build-able project?

You won't get very far with building it in Android Studio, unless you put in a lot of work with reworking or removing things that prevent you from migrating it to the Gradle build system.

Why does it have to be so hard?

It's simply not intended to be built outside of AOSP by default. Google engineers don't care, they have a full AOSP checkout. Custom ROM developers usually don't care as well, most of them have a full checkout of their modified source as well.

Will the solution you offer work for other types of apps that are inside of Android (like the launcher, for example)?

The only solution to build it with Android Studio is using Gradle (an then using Import, as you already found). Some apps include a build.gradle, whether it works you'll have to see. The launcher (packages/apps/Launcher3 in AOSP, packages/apps/Trebuchet in CM/LineageOS) ships a build.gradle that was made by Google (for whatever reason), intended for building the Launcher externally. Again, you'll have to see if it works.

Alternatively to the one of Vanilla Android OS, is it possible to do it for a custom ROM that gets updated from time to time, like Lineage OS?

As already stated earlier, most Custom ROM developers have a full source checkout, so they usually don't care about using Gradle (or Android Studio). Some LineageOS apps (Jelly/Browser, Eleven/Music, and some others) received Gradle support to allow contributors to test changes without having a full source checkout (which can be 70GB and more), but that only happened on LineageOS' own apps so far, not anything that is also used upstream by AOSP.

Karmakarmadharaya answered 22/4, 2019 at 1:36 Comment(4)
I'm searching for a solution. Simply saying that it's impossible is not true, because I see others succeed with it (as I wrote in the question). Look at the examples that worked. The Github repository. The Phone app of Lineage OS. Both work fine on 2 very different devices (Pixel 2 and Note 8). I want to know how to do it. Not how not to do it. Obviously it will be more than just cloning a project. That's why I'm asking it. If it was so easy I would have succeeded and not ask how to do it.Internuncial
Most of the dialers you linked aren't even AOSP/Google based, so those are technically irrelevant to your question. The APKs of the LineageOS phone app probably weren't built through Gradle either, but rather from a full ROM, which was built through the AOSP build system. The only slightly relevant project you linked is the one from geniusgithub, which wraps everything into Gradle instead of fully converting the project (as fas as I can tell). You can try if you get further by basing your work on that, you should get at least somewhere by updating the src/main directories and the dependencies.Karmakarmadharaya
I want a solution that works, gets updated from time to time and handles all of what a real dialer should handle. Lineage OS is pretty similar to what Android vanilla has . Which of what I've written isn't similar or based on AOSP ? I could even use MIUI dialer (even though I don't like it at all), if that's the only thing that works.Internuncial
Of course, I prefer from Vanilla, but if there is another good dialer that keep updated, it can be a good alternative.Internuncial

© 2022 - 2024 — McMap. All rights reserved.