Video Tutorial on How to Compile Android and Modify Kernels

video

For those interested, I have just posted a video tutorial series on XDA for building Android Oreo, Nougat, Marshmallow, and Lollipop on 5 different phones, the emulator, and 5 different ROMs. Also included are custom kernel editing, adding apps, changing source code, backgrounds, and more. Here’s what I posted:

From XDA: https://forum.xda-developers.com/android/general/guide-how-to-build-custom-roms-kernel-t3814251

===========================================================================

Praise God! Finally a video tutorial of how to build Android and modify kernels!

I have created a video tutorial and guide for how to compile Android, from Lollipop through Marshmallow, Nougat, and Oreo. The video series covers several different phones, the emulator, kernel and rom editing, app source code editing, and much more!

Who is this video series for?
Well, this video tutorial is a step by step guide built primarily for the beginner. This is written for those who already know how to flash TWRP, CWM, or the like, and who have installed a custom rom before. This is designed to help those who are ready to move up from flashing and installing other peoples custom rom to actually start making their own custom roms. I recommend that a beginner watch the entire series in numerical/alphabetical order (the videos are marked).

That said, I believe that an intermediate developer may find a useful trick here and there, and they should just skip ahead to videos of interest. Perhaps kernel development, or something along those lines.

An advanced rom/kernel developer will probably far exceed my feeble abilities, and will not likely find much useful information here. Perhaps if you are an advanced developer, you would consider continuing the tutorial or making an advanced video series! (See further posts for recommendations on contributing videos.)

Why did you put this together?
Well, after building roms for several different devices, I started receiving requests from users who wanted to start building their own roms, but didn’t know how. I didn’t have enough time to answer everyones questions, so I wrote a few guides, pointed others to guides that were available, but there are some things that you just need to see to understand. Hence, the video tutorial. I just hope that someone finds it useful.

This course was written in order! While Lollipop and Marshmallow are old by today’s standards, there is still good learning value in building them, and there are topics covered there that really make them worth watching.

What’s in the videos?
During the series, we will be building for the emulator, as well as 5 different phones of various brands, and 5 different roms. I hope that this will give the viewer a good idea of how to build for their own specific phone as they see the differences and similarities across the phones and custom roms.

[CODE]
+ Ubuntu installation
+ Java installations
+ Using Git, GitHub, GitKraken, and the command line
+ Fastboot and ADB
+ Heimdall/Odin
+ QFIL, QPST, SALT, and other tools
+ AOSP, SlimRoms, PACrom, AOKP, AOSCP
+ Lollipop, Marshmallow, Nougat, Oreo
+ Errors
+ Overclocking CPU/GPU
+ Adding Governors and I/O Schedulers
+ Sound modifications
+ Changing app colors, text, and icons
+ Adding prebuilt apps
+ Adding source code
+ Converting device from one rom to another
+ AND MORE!
[/CODE]

**** This is an UNOFFICIAL TUTORIAL. Use at your own risk! ****
Download links:
Ogg Vorbis Video GitLab:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide[/url]
Clicking on a video in GitLab will allow you to watch it online.

Ogg Vorbis Video Downloads:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide/-/archive/master/course_android_developer_guide-master.zip[/url]
This download is rather large due to the multiple videos.

MP4 Video GitLab:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide_mp4[/url]
Clicking on a video in GitLab will allow you to watch it online.

MP4 Video Downloads:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide_mp4/-/archive/master/course_android_developer_guide_mp4-master.zip[/url]
This download is rather large due to the multiple videos.

I also have several written guides available on XDA, here are a few:

Building ROMs for the Galaxy Note Edge: [url]https://forum.xda-developers.com/note-edge/general/guide-build-aosp-roms-kernels-note-edge-t3488840[/url]
Building ROMs for the Galaxy S4: [url]https://forum.xda-developers.com/galaxy-s4-tmobile/general/guide-step-step-instructions-building-t3402637[/url]

===========================================================================

Be sure to check out the videos or the XDA thread! I hope that these will help some of the aspiring Android developers out there!

Linux – keep it simple.

Advertisements

New builds! New device! The N915T Galaxy Note Edge!

While I don’t have one yet, I have decided that I will be getting one of these Galaxy Note Edge phones. They are a couple years old, and the price on them is going down significantly. In the meantime, I noticed that there were not very many custom roms available for them. Actually, there are only 2 roms that are not just modifications of stock roms. Those two roms are CM 12.1 (Lollipop) and Resurrection Remix (Marshmallow).

So, I decided to build some of my own. To God be the glory, it worked! Well, sort of.

Working with a group of willing testers, I have put together this rom:

http://www.mediafire.com/download/lccy75jfrx8itmt/pac_tbltetmo__20160909-125802.zip

At this time, it does not have functioning WiFi or Cellular, but it is a start. It is my hope to continue working on this and get it squared away. For now, it is a fun Alpha teaser to try out.

Some of the main problems with custom roms on this phone is the “edge” feature. The curved glass edge has never truly been done justice by a non-touchwiz rom, which I suspect is why most stick with the stock roms, or modifications thereof.

My long term goals are to find a way to put the edge back into play, and to also make the s-pen fully functional. Short term goals are to get the usual hardware working. If you have a N915T, feel free to try out this alpha build, but remember, it is not a daily driver yet.

Linux – keep it simple.

How to manually update your custom rom source code with security updates

For those of you who compile your own custom roms directly using AOSP source, the latest security updates are always added in as soon as they occure. For those of us using custom roms, such as SlimRoms, AOKP, PAC roms, and others, this is not always the case.

Because the custom rom community downloads AOSP source, and then manipulates it to their needs/tastes, they cannot always directly integrate AOSP security updates. Some of these updates may not apply. Others, if unedited, may cause some features not to function.

For this reason, custom roms can sometimes fall behind, because one of the developers on that team needs to manually apply a lot of the fixes. This can be quite tedious. For instance, the libvpx security issue found in March of 2016 changed over 800 files. For the most part, the custom rom teams do a great job updating the security patches for the current version of their rom. The question is, what do you do to update the security patches of older versions of the roms?

This is actually a problem that I ran into with my build of SlimLP for the SGH-M919, T-Mobile Galaxy S4. I am mainting a current build of SlimLP for that phone, because the Marshmallow builds have some Bluetooth issues on these phones. Thus, users who still want to use Lollipop roms still need up to date security. But how do I fix this problem? The SlimRom’s team has moved on to work on Slim6, and there is almost no activity on SlimLP. Well, by God’s grace, I figured it out, and I thought I would share that here with you, in case you face a similar problem.

First, you could apply these same methods to all levels of security, however, since there are so many security updates, I have decided to only manually update my SlimLP source code with Critical security updates. Yes, that does mean that I am skipping the High, Moderate, and Low security threats. As I mentioned before, some of the updates are over 800 files, and that would be a new full time job for me, which I don’t have time for. So, hopefully, these Critical updates will strike the balance between keeping my rom users safe, and allowing me to still have time for important things like family, work, and sleeping!

The first thing I noticed as I started building SlimLP in May was that the security updates had stopped in February. After syncing in August, I found that the security updates had still not changed. You can verify in your source (if it is Lollipop or later) by looking at /build/core/version_defaults.mk, where you should see this line:

[CODE]
ifeq “” “$(PLATFORM_SECURITY_PATCH)”
# Used to indicate the security patch that has been applied to the device.
# Can be an arbitrary string, but must be a single word.
#
# If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
PLATFORM_SECURITY_PATCH := 2016-02-01
endif
[/CODE]

Obviously, if it is now August, then the security patches are 6 months out of date. That is pretty old, and there were a lot of big security threats found since then, some of which are specific to Qualcomm phones. This prompted me to start the process of updating my source by hand.

Granted, you could also join the team of your favorite rom and help others by updating thier security patches too, but as I pointed out, I am only updating the Critical security updates, not all of them, so it would not meet all of the official requirements to push my source upstream. If that is something you are interested in doing, that is great!

The next thing I did was look at the current security updates by going here:
https://source.android.com/security/bulletin/index.html

I decided to work on one month at a time, and compile inbetween to make sure that each update did not break anything that is in my SlimLP rom. So, I clicked on March, 2016. There were 19 CVE’s, or Common Vulnerability and Exposures ID’s for that month, 7 of which were marked Critical. Those are the ones I decided to work on.

There are many different ways to go about this, but here is what worked best for me. I copied the CVE number, in this case, CVE-2016-0818, and punched it into Google. Google brought up several options, but I found a good one to click on is the NVD detail, which is teh National Vulnerability Database. In this case, it took me here:
https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-0818

The website has a poor color scheme, but is very informative. It tells you what type of threat this is, how it can be used, and other great information. There is also a section called “References to Advisories, Solutions, and Tools”, below which I found several hyperlinks, including this one, which contains the fixes:
https://android.googlesource.com/platform/external/conscrypt/+/4c9f9c2201116acf790fca25af43995d29980ee0

This Google Git page shows us where the file is located, and how many, and exactly which file(s) have been changed. For this particular CVE, it is a really small change of just one file:

src/platform/java/org/conscrypt/TrustedCertificateIndex.java [diff]

By clicking on the word [diff], you are brought to the next page, that shows you exactly which lines of code need to change, like so:

[CODE]
@@ -68,6 +68,15 @@
if (anchors == null) {
anchors = new ArrayList<TrustAnchor>(1);
subjectToTrustAnchors.put(subject, anchors);
+ } else {
+ // Avoid indexing the same certificate multiple times
+ if (cert != null) {
+ for (TrustAnchor entry : anchors) {
+ if (cert.equals(entry.getTrustedCert())) {
+ return;
+ }
+ }
+ }
}
anchors.add(anchor);
}
[/CODE]

If you have never read these before, the + signs tell you to add these lines. Any – signs tell you to delete those lines. At the top, the @@ -68,6 +68,15 @@ is used to tell you which line numbers to look for, such as the case here, of line 68. Pretty straightforward. So, in this case, I found that file, and made these changes of adding these new lines. Note, in some of the files I changed, the line numbers were not correct for where to find this portion of code. The easy thing to do is copy a snipit of the code and do a search in the file, corrolating that with the surounding code and approximate line numbers for guidance. This is especially true if that file has been hacked to add some function or feature to your rom.

The next step is to go back to where we started. If you recall, we looked in /build/core/version_defaults.mk, where we saw this line:

[CODE]
PLATFORM_SECURITY_PATCH := 2016-02-01
[/CODE]

Now we can update it if we desire. Granted, if you are not doing all of the updates, you may not wish to change this, as you do not want to intentionally mislead anyone. In my case, I did update it, but was very sure to write in my rom’s long description that the security updates are only the Critical updates that I applied by hand, as of 2016-02-01. How you handle this is up to you.

Obviously, the last step is to go ahead and compile your new code, and see if it still works right! Hopefully, you now have a more secure rom for your phones.

Linux – keep it simple.

The AKLU-Lionheart kernel!

For those of you who are downloading or using the PAC-ROM 6.0.1 or AOKP 6.0.1 that God graciously enabled me to build, I have released a new kernel for them, the AKLU-Lionheart kernel. You can install it in TWRP without having to re-load your rom. This will allow you to keep all of the data you already have. The updated rom links that are on the “Homemade Roms” page include this kernel in it already, but for any who are using an older build that just want to upgrade to the new kernel, here it is:

[url]http://www.mediafire.com/download/mkiz1745si6bm4p/aklu-lionheart-kernel-jfltetmo.zip[/url]

The first boot the WiFi may not work, but after a reboot it works every time there after! To God be the glory, the new kernel builds are working great!

Changes to the kernel include 2 new governors:

LionHeart – Lionheart is a conservative-based governor which is based on samsung’s update3 source.

SmartMax – By default this is configured for battery saving, so this is NOT a gaming or benchmark governor! Additionally, to make it “snappy”, smartmax has “touch poke”. So input events from the touchscreen will boost the cpu for a specific time to a specific frequency. Developed by XDA user maxwen.

You can still choose ondemand, powersave, performance, conservative, interactive, and userspace, but this allows you to choose two “battery friendlier” options. SmartMax will help your battery the most, and LionHeart is a bit more performance oriented, but still conservative. Enjoy!

Linux – keep it simple.

Changing the default wallpaper in an Android build

The other day, God graciously allowed me to compile PAC-ROM MM for the T-Mobile Samsung Galaxy S4 (JFLTETMO SGH-M919). So there are a lot of great things about this rom, but there were also a few things that I thought were lacking in creativity. Simple things really. Like the background. It comes standard with the CyanogenMod background. Well, that just doesn’t seem very PacRomish. So, I downloaded a custom background and edited the jpg until it was the right shape and size. I typically use Gimp for that, and today was no exception. After making the jpg into a 1920×1280 jpg file, I then used my home built script to make all of the “default_wallpaper.jpg” files. Here is the script:

[CODE]
#!/bin/bash

echo “Changing name of jpg file.”
mv *.jpg 1920×1280.jpg

echo “Converting to 1080×960”
convert -resize 1080×960 1920×1280.jpg 1080×960.jpg
echo “Converting to 960×800”
convert -resize 960×800 1920×1280.jpg 960×800.jpg
echo “Converting to 1440×1280”
convert -resize 1440×1280 1920×1280.jpg 1440×1280.jpg
echo “Converting to 2160×1920”
convert -resize 2160×1920 1920×1280.jpg 2160×1920.jpg
echo “Converting to 2880×2560”
convert -resize 2880×2560 1920×1280.jpg 2880×2560.jpg

echo “making folders”
mkdir ./drawable-hdpi
mkdir ./drawable-nodpi
mkdir ./drawable-sw600dp-nodpi
mkdir ./drawable-sw720dp-nodpi
mkdir ./drawable-xhdpi
mkdir ./drawable-xxhdpi
mkdir ./drawable-xxxhdpi

echo “copying and renaming pictures”
cp ./1080×960.jpg ./drawable-hdpi/default_wallpaper.jpg
cp ./960×800.jpg ./drawable-nodpi/default_wallpaper.jpg
cp ./1920×1280.jpg ./drawable-sw600dp-nodpi/default_wallpaper.jpg
cp ./1920×1280.jpg ./drawable-sw720dp-nodpi/default_wallpaper.jpg
cp ./1440×1280.jpg ./drawable-xhdpi/default_wallpaper.jpg
cp ./2160×1920.jpg ./drawable-xxhdpi/default_wallpaper.jpg
cp ./2880×2560.jpg ./drawable-xxxhdpi/default_wallpaper.jpg

echo “Complete.”
echo “Move the drawable* folders to ‘vendor/pac/overlay/common/frameworks/base/core/res/res’ folder.”
[/CODE]

You have to have imagemagic installed on your machine to use this script. Then, simply place your jpg file in a folder by itself, add this script to the folder, and run it! Here is the output:

[CODE]
alaskalinuxuser@alaskalinuxuser-HP-Compaq-6715b-FY288UC-ABA:~/Documents/projects/phones/wallpapers/pacman/images$ ls
pacman.jpg picscriptphones.sh
alaskalinuxuser@alaskalinuxuser-HP-Compaq-6715b-FY288UC-ABA:~/Documents/projects/phones/wallpapers/pacman/images$ ./picscriptphones.sh
Changing name of jpg file.
Converting to 1080×960
Converting to 960×800
Converting to 1440×1280
Converting to 2160×1920
Converting to 2880×2560
making folders
copying and renaming pictures
Complete.
Move the drawable* folders to ‘vendor/pac/overlay/common/frameworks/base/core/res/res’ folder.
alaskalinuxuser@alaskalinuxuser-HP-Compaq-6715b-FY288UC-ABA:~/Documents/projects/phones/wallpapers/pacman/images$ ls
1080×960.jpg 2160×1920.jpg drawable-hdpi drawable-sw720dp-nodpi drawable-xxxhdpi
1440×1280.jpg 2880×2560.jpg drawable-nodpi drawable-xhdpi picscriptphones.sh
1920×1280.jpg 960×800.jpg drawable-sw600dp-nodpi drawable-xxhdpi
alaskalinuxuser@alaskalinuxuser-HP-Compaq-6715b-FY288UC-ABA:~/Documents/projects/phones/wallpapers/pacman/images$ ls drawable-hdpi/
default_wallpaper.jpg
alaskalinuxuser@alaskalinuxuser-HP-Compaq-6715b-FY288UC-ABA:~/Documents/projects/phones/wallpapers/pacman/images$
[/CODE]

Once I moved the drawable folders to the folder mentioned above, I simply re-ran the compiler:

[CODE]
$ brunch jfltetmo
…..Edited for space…..
===============================-Package complete-===============================
Zip: /home/alaskalinuxuser/Documents/projects/phones/compile/pac6/out/target/product/jfltetmo/pac_jfltetmo__20160616-055233.zip
MD5: 61321450dfd6eed47ac7702cb7da7b1a
Size: 294M
OTA Link: http://pac-rom.com/ota/?device=jfltetmo&version=pac_jfltetmo__20160616-055233&md5=61321450dfd6eed47ac7702cb7da7b1a
================================================================================
…..Edited for space…..
[/CODE]

Now even a simple change like the backgrounds takes a good bit of time. It took my slow computer 2 hours just to make this one change. So don’t be alarmed if it takes a while for you too!

Linux – keep it simple.