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

error: use of undeclared identifier ‘LED_ADJUSTMENT_G’

After synching my source with AOKP for Nougat 7.1.2, I ran into this error when trying to build for the JFLTETMO:

[CODE]
target thumb C: lights.MSM8960 <= hardware/samsung/liblights/lights.c
hardware/samsung/liblights/lights.c:215:40: error: use of undeclared identifier ‘LED_ADJUSTMENT_R’
int red = ((color >> 16) & 0xFF) * LED_ADJUSTMENT_R;
^
hardware/samsung/liblights/lights.c:216:41: error: use of undeclared identifier ‘LED_ADJUSTMENT_G’
int green = ((color >> 8) & 0xFF) * LED_ADJUSTMENT_G;
^
hardware/samsung/liblights/lights.c:217:33: error: use of undeclared identifier ‘LED_ADJUSTMENT_B’
int blue = (color & 0xFF) * LED_ADJUSTMENT_B;
^
hardware/samsung/liblights/lights.c:258:31: error: use of undeclared identifier ‘LED_BRIGHTNESS_BATTERY’
adjusted_brightness = LED_BRIGHTNESS_BATTERY;
^
hardware/samsung/liblights/lights.c:261:31: error: use of undeclared identifier ‘LED_BRIGHTNESS_NOTIFICATION’
adjusted_brightness = LED_BRIGHTNESS_NOTIFICATION;
^
hardware/samsung/liblights/lights.c:264:31: error: use of undeclared identifier ‘LED_BRIGHTNESS_ATTENTION’
adjusted_brightness = LED_BRIGHTNESS_ATTENTION;
^
6 errors generated.
[/CODE]

Pretty simple, as we have talked about this before. In the past, I actually removed these lines from the light.c file, but this time I decided I would leave them in, and declare them instead. Essentially, the outcome is the same though for this build.

What these lines do is allow for custom liblight configurations. Perhaps a particular phone or tablet has a built in LED notification light where the green is brighter than the red or blue. In that case, every mixed color made from those LEDs will look strange. This gives the rom maker the option to “dim” down one or all three of the lights. The same applies for the brightness of the battery, notification, or attention lights.

As you can see below, I just declared them with the default values:

[CODE]
return err;
}

// WJH declaring these undeclared lights.
int LED_ADJUSTMENT_R = 1;
int LED_ADJUSTMENT_G = 1;
int LED_ADJUSTMENT_B = 1;
// WJH declaring these undeclared lights.

static int calibrate_color(int color, int brightness)
{
int red = ((color >> 16) & 0xFF) * LED_ADJUSTMENT_R;
int green = ((color >> 8) & 0xFF) * LED_ADJUSTMENT_G;
int blue = (color & 0xFF) * LED_ADJUSTMENT_B;

return (((red * brightness) / 255) << 16) + (((green * brightness) / 255) << 8) + ((blue * brightness) / 255);
}

…………EDITED FOR SPACE………………

led->delay_off = state->flashOffMS;
break;
default:
return -EINVAL;
}

// WJH declaring these brightness adjustments.
int LED_BRIGHTNESS_BATTERY = 255;
int LED_BRIGHTNESS_NOTIFICATION = 255;
int LED_BRIGHTNESS_ATTENTION = 255;
// WJH declaring these brightness adjustments.

switch (type) {
case TYPE_BATTERY:
adjusted_brightness = LED_BRIGHTNESS_BATTERY;
break;
case TYPE_NOTIFICATION:
adjusted_brightness = LED_BRIGHTNESS_NOTIFICATION;
break;
case TYPE_ATTENTION:
adjusted_brightness = LED_BRIGHTNESS_ATTENTION;
break;
default:
adjusted_brightness = 255;
}
[/CODE]

 

For the LED_ADJUSTMENT_R/G/B, I gave a value of 1. If you look at the math, it is used in the next formulae as (a & b) * LED_ADJUSTMENT_R/G/B. So if I set a value of 0, then the mathmatical outcome will be 0. If I set it at 1, then it will always be (a & b).

For the LED_BRIGHTNESS_BATTERY and so forth, I used the adjusted_brightness of 255, which is the default.

For both of these sets, I could have just removed them all together. But I build for several phones using the same source. By leaving them in, I should have an error if the device tree declared what is already declared in the lights.c file. Or at least that is my hope. In that case, then I could remove my handy work to make room for the actual values.

Linux – keep it simple.

undeclared identifier ‘POWER_HINT_LAUNCH_BOOST’

So, a new one for me. I’m building a rom for the H811, the T-Mobile variant of the LG G4. Currently building the tried and true AOKP 7.1.2 that I have used for my other phones, and I ran into an error:

[CODE]
target thumb C: power.msm8992_32 <= device/qcom/common/power/power-8992.c
device/qcom/common/power/power-8992.c:211:17: error: use of undeclared identifier 'POWER_HINT_LAUNCH_BOOST'; did you mean 'POWER_HINT_CPU_BOOST'?
if (hint == POWER_HINT_LAUNCH_BOOST) {
^~~~~~~~~~~~~~~~~~~~~~~
POWER_HINT_CPU_BOOST
hardware/libhardware/include/hardware/power.h:71:5: note: 'POWER_HINT_CPU_BOOST' declared here
POWER_HINT_CPU_BOOST = 0x00000110,
^
1 error generated.
[/CODE]

The suggested option was to change POWER_HINT_LAUNCH_BOOST to POWER_HINT_CPU_BOOST, but I didn't like that, since just a dozen lines later in the code, there was already an if/then statement for POWER_HINT_CPU_BOOST. Esentially, we need to either declare POWER_HINT_LAUNCH_BOOST, or get rid of it in our code. In this case, I decided to scrap it because if it was needed, then it would have existed already. Strange logic perhaps, but what we see is that if it is not called, it will not return anything anyways. If it is called, it just supplies some information that I think we can live without.

[/CODE]
// WJH was POWER_HINT_LAUNCH_BOOST
// WJH if (hint == POWER_HINT_LAUNCH_BOOST) {
// WJH launch_boost_info_t *info = (launch_boost_info_t *)data;
// WJH if (info == NULL) {
// WJH ALOGE("Invalid argument for launch boost");
// WJH return HINT_HANDLED;
// WJH }

// WJH ALOGV("LAUNCH_BOOST: %s (pid=%d)", info->packageName, info->pid);

// WJH int duration = 2000;
// WJH int resources[] = { SCHED_BOOST_ON, 0x20C };

// WJH start_prefetch(info->pid, info->packageName);
// WJH interaction(duration, ARRAY_SIZE(resources), resources);

// WJH return HINT_HANDLED;
// WJH }

if (hint == POWER_HINT_CPU_BOOST) {
int duration = *(int32_t *)data / 1000;
int resources[] = { SCHED_BOOST_ON };
………….EDITED FOR SPACE…………….
[/CODE]

That will cut it out of the loop, which means the loss of a feature, but I think it is one we can live without.

Linux – keep it simple.

POWER_HINT_LAUNCH_BOOST is not declared in this scope!

While building AOKP 7.1.2 for the kltevwz (the Verizon Samsung Galaxy S5), I ran into this error:

[CODE]

device/qcom/common/power/power-8974.c:143:17: error: ‘POWER_HINT_LAUNCH_BOOST’ was not declared in this scope …….Edited for space…….. make: *** Waiting for unfinished jobs….

[/CODE]

So, I headed over to device/qcom/common/power/power-8974.c, and this is what I saw:

[CODE]

if (hint == POWER_HINT_LAUNCH_BOOST) {
int duration = 2000;
int resources[] = { CPUS_ONLINE_MIN_3,
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };

interaction(duration, ARRAY_SIZE(resources), resources);

return HINT_HANDLED;
}

[/CODE]

Looked pretty normal to me. However, when comparing to LineageOS’s 14.1 files, I saw that they dropped the “boost” from the name of the hint. So I edited mine to match, like so:

[CODE]

if (hint == POWER_HINT_LAUNCH) {
int duration = 2000;
int resources[] = { CPUS_ONLINE_MIN_3,
CPU0_MIN_FREQ_TURBO_MAX, CPU1_MIN_FREQ_TURBO_MAX,
CPU2_MIN_FREQ_TURBO_MAX, CPU3_MIN_FREQ_TURBO_MAX };

interaction(duration, ARRAY_SIZE(resources), resources);

return HINT_HANDLED;
}

[/CODE]

And, it built that part successfully! I like the easy problems!

Linux – keep it simple.

AOKP 7.1.1 for the Galaxy Note Edge!

To God be the glory, my AOKP NOUGAT project finally works!

My fellow T-Mobile-ians, (N915T) you have been left out of AOSP development long enough! By God’s grace I was able to use mickey387’s great tbltexx work, and completely adapt it to our tbltetmo after extracting all of the needed firmware from our 6.0.1 stock roms! No data zips are required here! It is all built in!

I also have made an international version (N915G/F/FY) as well!
This is not a dirty unicorn. This is the original unicorn, the AOKP. Now made out of Nougat! That’s right, all of the AOKP stuff you love, plus LineageOS, plus a built in side bar, and more! All wrapped up into one! With tons of settings from status bar tweaks to button remaps, it’s all here and ready to rumble!

**** This is an UNOFFICIAL ROM. Install at your own risk! ****

Features and Screenshots!

– Advanced Reboot
– Omni-Switcher
– Kernel Adiutor

+ Rom Control:

+ App Launchers
– App Circle Bar
– App Side Bar
– Gesture Anywhere

+ General
– cLock settings
– Recents settings
– Wakelock Blocker

+ Hardware Keys
– Backlight control
– Power button options
– Launch vibration control
– Home button controls
– Recents button controls
– Long press options, double tap options
– Kill app back button option
– Volume buttons wake
– Volume button playback controls
– Keyboard cursor controls
– Volume button reorientation
– IME features

+ Lockscreen
– Media Cover art
– Display music visualizer
– Show weather
– Blur background
– Fingerprint auth vibration
– Double tap to sleep (DT2S)
– Disable quick settings
– Show lockscreen clock and date
– Lockscreen notification count

+ Notification Drawer
– Brightness slider
– Brightness icon
– Rows in portrait and landscape modes
– Columns
– Tile Animations
– Advanced data tile
– Smart pulldown
– Quick pulldown

+ Power Menu
– Animation choices
– Screenshots
– Screenrecord
– Airplane mode
– Sound Panel

+ Sound
– Various sound settings
– Volumn step control

+ Status Bar tweaks
– Network traffic
– Clock style
– Double tap to sleep (DT2S)
– Superuser indicator
– Icon controls
– AOKP logo

+ User interface
– Toast controls
– AOKP animations
– Transparency controls

AND MORE!!!

Background image:
https://qlfiles.net/2017/01/07/upload-fractal-images/
The background images that I used in this ROM came from the Quiet Learner. You should check out his mathematical artwork, including 3D mandelbox images!

Ready to download? Check it out under my menu –> Homemade Roms –> Galaxy Note Edge!

Linux – keep it simple.

AOKP N 7.1.1 for the JFLTETMO and JFLTEXX

To God be the glory, my AOKP Nougat project finally works!

If you are interested in a *mostly* working AOKP 7.1.1 rom for the JFLTETMO or JFLTEXX, head over to XDA or look under my Homemade Roms page for a download link!

http://forum.xda-developers.com/galaxy-s4-tmobile/development/rom-aokp-n-t3519280

**** This is an UNOFFICIAL ROM. Install at your own risk! ****

 

!!!FIRST BOOT TAKES ABOUT 5 EARTH MINUTES TO COMPLETE!!!

Installation instructions:
-Download ROM and gapps, and put them on your phone or external storage.
-Reboot into recovery mode – TWRP (I personally installed this using 3.0.2-0).
-Backup what you had. (Just to be safe.)
-Wipe. (I personally wipe everything prior to flashing new roms, but at least do the basic wipe.)
-Install Rom.
-Install Gapps. – Optional
-Reboot to system and enjoy!

-OPTIONAL – After first boot, then go back to recovery and install the AKLU kernel.

What works:
So far everything that I have tried works, such as
- Camera for pictures only!
- Phone calls/receiving
- Data 2g/3g/LTE
- Bluetooth* - Music and File transfer.
- WiFi
- PTP
- GPS
- Multi-Window, just long press the "recents" button.
etc....

What doesn't:
- Video recording with the camera doesn't work, pictures work, but not video.
- MTP sometimes works, but is finicky, but PTP is also an option and works every time.
- Bluetooth works, but sometimes the Bluetooth share app crashes.
- Browser works, but sometimes doesn't display typing letters until you press enter/search. (I recommend you download a different browser.)
- Choosing to reboot the phone sometimes takes a loooong time. It may be better to Power off and then start the phone, which is faster for some reason.
-Let me know in the forums if you find other issues so I can work on fixing them.

 

 

Here are some screenshots:

Linux – keep it simple.

CONGRATS YOU EARNED A STINKEYE FROM CID!

Well, this certainly is an original code error if I ever saw one.

[CODE]prebuilts/cmsdk/api/6.txt:745: error 8: Removed public class cyanogenmod.platform.R.color
prebuilts/cmsdk/api/6.txt:749: error 8: Removed public class cyanogenmod.platform.R.dimen
prebuilts/cmsdk/api/6.txt:765: error 8: Removed public class cyanogenmod.platform.R.layout

******************************
You have tried to change the API from what has been previously approved.

STOP.
Read this:
https://github.com/CyanogenMod/cm_platform_sdk/wiki/Creating-an-API-for-the-SDK#updating–verifying-the-api

To make these errors go away, you have two choices:
1) You can add “@hide” javadoc comments to the methods, etc. listed in the
errors above.

2) You can update current.txt (locally) by executing the following command:
make update-cm-api

^^^^^^^^^^^^^^^^^^
CONGRATS YOU EARNED A STINKEYE FROM CID!
[/CODE]

It even comes with it’s very own ASCII art, which I did not post here. The above implies that I need to make some changes to my api files. Option #2 sounded really easy, so I gave it a try, here was the output:

[CODE]
$ make update-cm-api
…..edited for space…….
nes/compile/build_aokp7/out/target/common/docs/cm-api-stubs
35 warnings
[100% 5/5] build update-cm-public-api
Copying cm_current.txt
Copying cm_removed.txt

#### make completed successfully (02:47 (mm:ss)) ####
[/CODE]

However, it didn’t solve the problem. Then I tried option #1 by editing the build_aokp7/prebuilts/cmsdk/api/6.txt file. I simply added @hide to the beginning of lines that were flagged, in this case, lines 745, 749, and 769. Once that was done, I stopped getting the stinkeye error. Hopefully that will be useful for you to know as well.

Linux – keep it simple.

Neverallow failures occurred

What does that even mean? Let’s take a look at the code:

[CODE]
libsepol.report_failure: neverallow on line 574 of system/sepolicy/system_server.te (or line 18452 of policy.conf) violated by allow system_server system_server:process { execmem };
libsepol.report_failure: neverallow on line 544 of system/sepolicy/domain.te (or line 9255 of policy.conf) violated by allow mediaserver shell_data_file:dir { search };
libsepol.report_failure: neverallow on line 459 of system/sepolicy/domain.te (or line 9170 of policy.conf) violated by allow mm-qcamerad system_file:file { execmod };
libsepol.report_failure: neverallow on line 459 of system/sepolicy/domain.te (or line 9170 of policy.conf) violated by allow mediaserver system_file:file { execmod };
libsepol.report_failure: neverallow on line 459 of system/sepolicy/domain.te (or line 9170 of policy.conf) violated by allow system_server system_file:file { execmod };
libsepol.report_failure: neverallow on line 433 of system/sepolicy/domain.te (or line 9159 of policy.conf) violated by allow mm-qcamerad system_file:file { execmod };
libsepol.report_failure: neverallow on line 433 of system/sepolicy/domain.te (or line 9159 of policy.conf) violated by allow mediaserver system_file:file { execmod };
libsepol.report_failure: neverallow on line 433 of system/sepolicy/domain.te (or line 9159 of policy.conf) violated by allow system_server system_file:file { execmod };
libsepol.check_assertions: 8 neverallow failures occurred
Error while expanding policy
[/CODE]

From the error output, I can only discern that these should never be allowed to happen in a sepolicy configuration. So, to make ammends with the compiler, I edited build_aokp7/device/samsung/jf-common/sepolicy/system_server.te, build_aokp7/device/samsung/jf-common/sepolicy/mm-qcamerad.te, and build_aokp7/device/samsung/jf-common/sepolicy/media_server.te, simply removing the sepolicy rule that was causing the issue, namely

[CODE]system_file:file { execmod };[/CODE]

It is worth noting that they do appear twice in the list of errors, but only once in the file itself. Hopefully that will help me as I compile AOKP 7.0 for the jfltetmo Samsung Galaxy S4, T-Mobile edition.

Linux – keep it simple.

 

Error: could not load context file

While working on AOKP 7.0, I came across an interesting error:

[CODE]
libsepol.context_from_record: could not create context structure
/home/alaskalinuxuser/Documents/projects/phones/compile/build_aokp7/out/target/product/jfltetmo/obj/ETC/file_contexts.bin_intermediates/file_contexts.device.tmp: line 475 has invalid context u:object_r:misc_partition:s0
Error: could not load context file from /home/alaskalinuxuser/Documents/projects/phones/compile/build_aokp7/out/target/product/jfltetmo/obj/ETC/file_contexts.bin_intermediates/file_contexts.device.tmp
[/CODE]

The reason this was interesting, is because I could not find the sepolicy file to change in my device trees to fix this. Generally, when there is an sepolicy issue, I look through my device tree (in this case, jf-common/sepolicy) and edit those files to solve the issue. However, this time, the issue did not stem directly from one of those files. In the end, I opened build_aokp7/out/target/product/jfltetmo/obj/ETC/file_contexts.bin_intermediates/file_contexts.device.tmp and removed line 475, which was causing the error. That did allow the build to continue, but only time will tell if that was the right answer or not.

Linux – keep it simple.

 

Testers requested for AOKP 6.0.1 on the Note Edge, T-Mobile variant.

Testers requested for AOKP 6.0.1 on the Note Edge, T-Mobile variant.

Hi, I have built several roms for other phones, both personally, and shared here on my website, or on XDA.

The Note Edge N915T is getting pretty cheap to buy off of Swappa, Ebay, and Amazon, and I was thinking about picking one up. I am a dad, so I have to be frugal and stick with older/cheaper phones. I can’t afford to buy everybody in the family a new cell phone! As I save up a few bucks for it, I was thumbing through the forums and noticed that there were not many non-stock based roms available for it. So, I built one. By God’s grace it compiled after a few tries of error fixing. I would like to ask for any volunteers to assist me with testing it out.

The applicants would need a little bit of knowledge:

– Have a N915T variant
– Have TWRP installed
– Know how to make a backup
– Know how to wipe and flash roms
– Preferably be able to use adb (I can help with that)
– Know how to recover back to stock rom or TWRP in the event of a failure
– Know how to take screenshots/pictures (common sense is in fact a super power)

Essentially, if interested, click on the “contact” link in the bar at the top. Fill out the contact form with a valid email address, and I will email you a reply with a link to Media-Fire for the download and I would include instructions.

If it fails, well, you can just jump back into TWRP and restore your daily driver.

If it passes, I can  list you as an Alpha/Beta tester!

I never charge money for my rom work, I do not accept donations, so this is not a ploy to exploit cash from anyone. I just like building custom roms, and I am really interested in building one for this phone.

 

You can click on the “Homemade Roms” link above if you would like to check out some of my other work.

Linux – keep it simple.