Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ?

like image 431
android developer Avatar asked Apr 19 '19 06:04

android developer


1 Answers

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.

like image 150
Tim Schumacher Avatar answered Oct 11 '22 13:10

Tim Schumacher