Android is built on top of the Linux kernel, but it has always used a heavily-modified version with changes from OEMs, chip manufacturers like Qualcomm and MediaTek, and Google. There have been efforts over the years to close the gap between the two kernels, but now Google is getting more serious about it.
At this year's Linux Plumbers Conference, Google engineers held talks about the company's efforts to get Android as close as possible to the mainline Linux kernel. Not only would this reduce technical overhead for Google and other companies, because they would no longer have to merge thousands of changes into each new Linux kernel version (and Google would no longer have to support Linux kernel versions for six years), but it could also benefit the Linux project as a whole. For example, the growing number of ARM-based Linux phones and computers could see improved performance and battery life.
The first stage of this process is merging as many of Android's modifications as possible back into the mainline Linux kernel. As of Feburary 2018, the Android common kernel (which OEMs make additional changes to) has over 32,000 insertions and over 1,500 deletions compared to mainline Linux 4.14.0. That's an improvement from a few years ago, when Android added over 60,000 lines of code on top of Linux.
To show off how much progress has been made, Tom Gall, the director of the Linaro Consumer Group, brought a Xiaomi Pocophone on stage that was running Android 10 on top of a mainline Linux kernel. He told the audience, "there are major, major props to be given to the Google Kernel Team in particular for getting their code upstream so that we can boot devices with a mainline kernel." It's likely that some of the phone's features were non-functional (the battery percentage in the picture reads as 0%), but it's still impressive.
Xiaomi Pocophone booting Android 10 on top of a mainline Linux kernel
The Android kernel still receives modifications from chip makers (like Qualcomm and MediaTek) and per-device tweaks from OEMs (like Samsung and LG). Google improved this process in 2017 with Project Treble, which separates device-specific drivers from the rest of Android. The company wants to bring this technology to the mainline Linux kernel, which could potentially eliminate the need for per-device kernels, and further speed up Android updates.
The idea proposed by Google engineers is to build an interface in the Linux kernel that would allow proprietary device drivers to run as plug-in modules, so no modifications to the kernel itself are needed. In simple terms, it would bring the modularity of Project Treble to regular Linux.
Of course, this is a massive undertaking that isn't guaranteed to succeed. Google would have to get its Android hardware partners on board, and as Ron Amadeo from Ars Technica pointed out, some of the Linux community is against the idea of a stable kernel interface. Greg Kroah-Hartman, a major developer for Linux, has already written this in documentation files:
Linux kernel development is continuous and at a rapid pace, never stopping to slow down. As such, the kernel developers find bugs in current interfaces, or figure out a better way to do things. [...] This is in stark contrast to a number of closed source operating systems which have had to maintain their older USB interfaces over time. This provides the ability for new developers to accidentally use the old interfaces and do things in improper ways, causing the stability of the operating system to suffer. [Also,] if the internal interfaces were not allowed to change, fixing [a] security problem and insuring that it could not happen again would not be possible.
Switching Android to a vanilla Linux kernel and integrating a Project Treble-like system in the mainline kernel is a massive endeavor, and it may never even come to fruition. Meanwhile, Google is still working on its new Fuchsia operating system that may one day replace Android, with a custom kernel that does away with many of the technical hurdles involved with Linux.
- Ars Technica