[Samsung Galaxy Tab S4 ROMs, Kernels, Recoveries, &] ianmacd:
Modesty - a modest custom kernel for the Samsung Tab S4

Modesty aims to provide a mildly appealing and reasonable alternative to the stock 4.4.78 kernel that comes with The Tab S4. In its pursuit of being both mildly appealing and reasonable, it will eschew features that could compromise device stability, whilst gleefully embracing low-risk, self-contained enhancements. In other words, your lowest expectation should be that this kernel will be at least as stable as the stock kernel.

Since there are currently no other custom kernel projects supporting the Tab S4, there isn't really any previous device-specific work to build on. Development of this kernel is therefore likely to be slow and steady.

"Why is this kernel called Modesty? That's crap! Why not Wolverine, Intrepid or Jupiter?"

Because it's just a operating-system kernel, not a turbo-charged supercar or a mission into outer space. Even as operating-system kernels go, this one is pretty dull. Besides, I'm a weary curmudgeon in his fifties, not a teenager.

This project has the modest aim of modestly enhancing the pleasure you derive from your Tab S4 and is therefore modestly named Modesty.

Key characteristics

Supports both the wi-fi only (T830) and wi-fi/LTE (T835) models.

Forked from Samsung's pristine kernel source code (Linux 4.4.78 for ARGH firmware at time of launch).

Regular merging of the upstream Linux kernel's linux-4.4.y branch (4.4.161 at time of public launch).

Regular merging of Samsung's updates to its modified kernel source as they are made available.

Includes [MENTION=4316709]savoca[/MENTION]'s KCAL advanced colour/gamma control driver.

Includes [MENTION=4684315]flar2[/MENTION]'s sound control driver to manage headphone and microphone gain.

Disables a huge amount of tracing and logging features inexplicably left enabled by Samsung in the stock release kernel. These debugging features have no place outside engineering builds.

Packed into a boot.img (boot image) taken directly from Samsung's latest stock firmware and kept as close to the original as possible. No obscure boot-time kernel configuration is stashed away here, and no changes are made to any other part of the file system at either install time or run time.

Provides a fully automated installer, with the option of interactive installation to allow manual selection of features and the ability to automatically root the device with Magisk in the post-installation phase.

Includes WireGuard VPN support (version 0.0.20180818 at the time of public launch), which will be updated as available.

Includes [MENTION=947981]Lord Boeffla[/MENTION]'s generic kernel wakelock blocker. The conservative default block-list is: qcom_rx_wakelock and NETLINK.

Utilises Westwood+ TCP congestion algorithm by default.

Includes Veno TCP congestion algorithm.

SELinux operates in enforcing mode and cannot be dynamically switched to permissive mode.

FAQ

Q. Is this kernel still actively developed?

A. No. The final ianmacd release was v1.0.0 on 21st November 2019 and no-one else has picked up maintenance of the project.​

Q. Will this kernel also run on Android 9.0 (Pie) devices?

A. No. Modesty targets Android 8.1 (Oreo) and there was never an intention to update it for 9.0 (Pie).​

Q. Can I overclock or underclock the CPU using this kernel?

A. No.​

Q. How does interactive installation mode work?

A. If the ZIP file name contains the string _interactive or a dot-file called .modesty_interactive is present in the root of the external SD card, interactive installation mode is triggered. Please note that this mode overrides any selections implied by the archive name or the presence of dot-files on the file-system.

In interactive mode, you will be asked whether to root the device afterwards with Magisk. Selections are made using the Volume buttons. Just follow the on-screen prompts.​

Q. Can I safely block wakelock X?

A. Perhaps. However, unless you know what a particular wakelock does and are certain that it is causing an actual problem on your device, I suggest you leave it alone.​

Q. Why is this kernel labelled beta? Is it safe to use? And who are you, anyway? Can you be trusted?

A. My T830 has been running this kernel every day since I first rooted it, and I can therefore personally vouch for its stability on this model.

A couple of users have reported Modesty running well on the T835. Initially, it was reported that the kernel did not boot on this model, but after trying several test kernels, the user in question discovered that his machine had a non-standard firmware installation. Once this situation was remedied, Modesty booted and worked as designed.

As the person who built the kernel, I know exactly what's in it, and therefore the only risk I'm exposing myself to when I run it is that of my own incompetence. That's not true for you, however, and you should exercise due caution and at least pause for a moment to consider what you are installing, and the far-reaching powers you are about to grant this unaudited code over your device. Although I link to the source code below, you have only my word for it that this bears any resemblance to the kernel actually provided in the installer.

There are likely to be many iterations of this kernel before it sees a 1.0 release. Features may be added or removed along the way, although there is no clear roadmap at this point in time. Development will go where the needs of the users take it.

Please see the Installation section below for an important note regarding the use of this kernel in combination with stock (i.e. unmodified) Samsung firmware.
​

Q. Can I safely root this kernel?

A. Of course. What use would it be if you couldn't? I recommend Magisk for the task. It has a few minor issues, but as a project is very much alive, something that cannot be said about its peers. Magisk has arguably now established itself as the de facto root solution for Android devices.

It just so happens that I also produce my own builds of Magisk, which you are welcome to use. These are release builds (as opposed to debugging builds), produced from my own fork of [MENTION=4470081]topjohnwu[/MENTION]'s original source, often augmented with patches. You can use anyone's builds, though.

Again, these builds work for me on various Samsung devices, but they are unofficial and you should approach them with fitting caution.​

Q. Can I install Magisk at the same time as Modesty?

A. Yes. The Modesty installer allows you to automatically root your device with Magisk following installation of Modesty..

To make use of this facility, either rename the Modesty zip file to contain the string _magisk or create a file called .modesty_magisk in either the root of your external SD card or in the standard Download directory of the internal SD card. Alternatively, you can utilise interactive installation mode. See above for details.

If any of these trigger conditions is met, the installer will look in the standard internal Download directory as well as in ./Magisk (if present) on the external SD card (if present) for a suitable Magisk zip file to install. Preference is given to versioned files matching the glob Magisk-v*, in which case the latest according to lexical sort order will be used. If none is found, the installer then looks for unversioned release builds (e.g. official Canary channel release builds) called magisk-release.zip in the same locations, selecting the one with the most recent timestamp. If none is found, the installer will then try to find unversioned debug builds (e.g. official Canary channel debug builds) called magisk-debug.zip, again picking the one with the most recent timestamp. Finally, the installer falls back to looking for the most recent file called Magisk.zip or magisk.zip. If still no files have been found by this stage, chaining of Magisk is abandoned.

For example:

star2lte:/ $ ls -l /storage/0000-0000/.modesty_magisk
-rwxrwx--x 1 root sdcard_rw 0 2018-09-15 14:31 /storage/0000-0000/.modesty_magisk
star2lte:/ $ ls /storage/0000-0000/Magisk/Magisk-* | tail -n 3
/storage/0000-0000/Magisk/Magisk-v17.2-2018091001-ianmacd.zip
/storage/0000-0000/Magisk/Magisk-v17.2-2018091201-ianmacd.zip
/storage/0000-0000/Magisk/Magisk-v17.2-2018091501-ianmacd.zip

When you flash the Modesty archive in TWRP, the most recent version of Magisk that could be found will now be used to automatically root your kernel, i.e. Magisk-v17.2-2018091501-ianmacd.zip in this example.​

Q. Why doesn't Modesty have its own Telegram group?

A. Because my experience of Android-themed Telegram groups is that they invariably degenerate into seething cesspits of rudeness, ignorance, superstition and — on a good day — pseudo-science. I don't wish to police such a den of iniquity. Of course, it's a free world (or so I still like to kid myself), so you are at liberty to create your own Telegram group for Modesty if you wish. Just please don't invite me to it.
​

Building

Building the kernel from source is beyond the scope of this document. If you want to build this kernel from scratch, for example to change its configuration, start with this handy reference tailored to building kernels for Android.

Download

See posting #2 in this thread for links to the latest and all previous versions.

Known Issues

Bluetooth HID (input) devices do not work.

Versions 0.99.11 to 0.99.22 contained a bug that caused Bluetooth HID (input) devices, such as mice, keyboards and gamepads, not to function. They could be paired with the tablet, but their input was not recognised. This bug was finally traced and fixed in 0.99.23.​

Installation

Make a back-up of your existing boot partition using the custom recovery environment provided by TWRP. If your device doesn't yet have TWRP, you will need to install it first. Then, use it to flash the Modesty ZIP file. The boot image will automatically be installed in the boot partition of your device.

If your device has unmodified Samsung firmware, you will encounter problems with Bluetooth (namely delayed initialisation and forgotten pairings) after installing this or any other custom kernel. To remedy this, you will need to patch your system with modified libsecure_storage.so libraries. Some custom kernel installers actually install these without telling you, overwriting your system libraries and transparently circumventing the problem before you can run into it. This approach necessarily modifies your device's file-system, however, and that may not be what you want. At the very least, the user should be made aware what is happening to his device.

For this reason, I have instead prepared a companion Magisk module that achieves the same goal without modifying the file-system. This will allow you to run a custom kernel (not just this one, but any custom kernel) on pristine stock firmware without any Bluetooth issues. The module can be found in the official Magisk module repository, accessible from Magisk Manager on your tablet. If you install this Magisk module, you may wish to also disable the secure_storage_daemon by editing /system/etc/init/secure_storage_daemon.rc (change start to stop), as it no longer serves a purpose.

In a similar vein, you may encounter authentication errors when connecting to wireless networks after installing this or any other custom kernel. This problem is not serious and easily remedied by re-entering your passphrase for the networks you use.

Finally, if SecurityLogAgent notifies you that unauthorised actions have been detected, do not be alarmed. This is a normal consequence of having installed a custom kernel. You may wish to disable SecurityLogAgent to avoid being repeatedly notified..

Whilst the above issues are the only ones you can expect to encounter when running this kernel vs. the stock Samsung kernel, they may sound like more trouble than they're worth. In that case, you might be happier just sticking to Samsung's stock kernel. The company supplies a perfectly good kernel straight from the factory.

Configuration

You are encouraged to use either [MENTION=361302]morogoku[/MENTION]'s excellent MTweaks (a modified version of Kernel Aduitor) or [MENTION=4684315]flar2[/MENTION]'s EX Kernel Manager to manage the features provided by this kernel.

Source code

Modesty's GitHub repository.

References

A useful guide to CPU governors, I/O schedulers (and more).

For more information on the some of the individual schedulers included in this kernel, you can also look under Documentation/block in the kernel source.

The WireGuard user guide, control app, home page and source code.

Credits

Thank you to everyone in the Linux kernel universe for getting us this far. Within the Android development community, I am grateful to the following people for their time-saving contributions:

[MENTION=4544860]osm0sis[/MENTION] for Android Image Kitchen, which has saved me a huge amount of work in packing and unpacking boot images.

An honorary mention must go to [MENTION=631273]Chainfire[/MENTION], the extent of whose benefaction to the Android community is still not fully understood or appreciated in some quarters.