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

Geany: the little IDE that could!

geany_ide.png

Recently, while working with some older equipment, I needed a lightweight java IDE to compile some java projects. I really wasn’t looking for something quite as big as eclipse or netbeans, I just wanted a simple, one stop solution that would allow me to build java programs on an older laptop.

So, I rubbed a magic lamp, and out popped Geany!

Well, more specifically, the laptop is running Debian Wheezy, and had openJDK already installed. With that alone, I could have built java programs from the command line, but it can get a little tedious. So, I looked on the repositories for an IDE that wasn’t too large.

Thus enter Geany. I first used Geany a long time ago as a text editor on #! (CrunchBang) Linux, but revisiting the program revealed that I was not using it to it’s full potential. Specifically, you can compile, build, and run various program types from within Geany. Of course, it only outsources the commands for you, so you need a java jdk in order to compile java, or a c++ compiler to compile c++. Geany just does all the command line work for you.

What Geany does accomplish for you, however, is a great user interface with templates and the ability to organize projects or view code with different filters. As you can see in the picture, I was testing out Logic Crazy’s Alpha Beta Chess program.

As well as showing you the code, it can do parenthesis highlighting, colors for different code type, and a class and method tree on the side. It really is a great program if you need a lightweight IDE. I know that I’ll be putting it to good use.

Linux – keep it simple.

Building Android Oreo, error: ADDITIONAL_DEFAULT_PROPERTIES must not be set

So, round one of building Android Oreo. Specifically giving an early try for SlimRoms and OmniRom, both of which have started an Oreo build system. Obviously, anything at this stage is a pre-alpha, more or less just a rebranded AOSP build. Still, it’s fun to check it out and see what Oreo is all about.

That being easier said than done, here was the first error (not counting all the ones to set up the build environment to recognize the H811 phone as an option) :

[CODE]
out/build-slim_h811.ninja is missing, regenerating…
build/core/main.mk:245: error: ADDITIONAL_DEFAULT_PROPERTIES must not be set before here: ro.device.cache_dir=/data/cache.
07:23:13 ckati failed with: exit status 1
make: *** [run_soong_ui] Error 1
[/CODE]

So, I took a look at build/core/main.mk on line 245, and made a few edits:

[CODE]
#
# —————————————————————–
# Validate ADDITIONAL_DEFAULT_PROPERTIES.
# WJH ifneq ($(ADDITIONAL_DEFAULT_PROPERTIES),)
# WJH $(error ADDITIONAL_DEFAULT_PROPERTIES must not be set before here: $(ADDITIONAL_DEFAULT_PROPERTIES))
# WJH endif
[/CODE]

Now the build can continue. This is probably not the right way to fix this, but it is an easy bandaid until I figure that out.

Linux – keep it simple.

 

error: undefined reference to ‘wifi_start_fstman’

Ah, the continuing saga of the far far away dream of building OmniRom Nougat for the LG G4. Yet again, another set of errors:

[CODE]
system/qcom/softap/sdk/qsap.c:705: error: undefined reference to ‘wifi_start_fstman’
system/qcom/softap/sdk/qsap.c:714: error: undefined reference to ‘wifi_stop_fstman’
system/qcom/softap/sdk/qsap.c:722: error: undefined reference to ‘is_fst_enabled’
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[/CODE]

So I took a look at the lines in question of system/qcom/softap/sdk/qsap.c:

[CODE]
int qsap_prepare_softap()
{
ALOGD(“Starting fstman\n”);
return wifi_start_fstman(TRUE);
}

int qsap_unprepare_softap()
{
ALOGD(“Stopping fstman\n”);
return wifi_stop_fstman(TRUE);
}

int qsap_is_fst_enabled()
{
return is_fst_enabled();
}
[/CODE]

No big deal, I thought. I could just wrap them in an #ifdef (if defined) statement, and only use them if they are actually defined. So I did.

[CODE]
int qsap_prepare_softap()
{
/* WJH */
#ifdef wifi_start_fstman
ALOGD(“Starting fstman\n”);
return wifi_start_fstman(TRUE);
#endif
}

int qsap_unprepare_softap()
{
/* WJH */
#ifdef wifi_stop_fstman
ALOGD(“Stopping fstman\n”);
return wifi_stop_fstman(TRUE);
#endif
}

int qsap_is_fst_enabled()
{
/* WJH */
#ifdef is_fst_enabled
return is_fst_enabled();
#endif
}
[/CODE]

You are all probably smarter than me, and see the error of my ways, but non the less, I ran it as so, and this was my next set of errors:

[CODE]
system/qcom/softap/sdk/qsap.c:707:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
system/qcom/softap/sdk/qsap.c:716:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
system/qcom/softap/sdk/qsap.c:724:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
[/CODE]

The problem was that the in int qsap_is_fst_enabled(), int qsap_unprepare_softap(), and int qsap_prepare_softap() integers all return nothing, or are “null”. That’s no good for follow on code, they have to have some value. So, I thought about it for a while, and right or wrong, I decided to use an #ifndef (if not defined) flag.
If the functions were defined, they would be used, if they are not defined, then I gave a return value, arbitrary as they may be, but what I suspect is the “right answer”. Take a look:

[CODE]
int qsap_prepare_softap()
{
/* WJH */
#ifdef wifi_start_fstman
ALOGD(“Starting fstman\n”);
return wifi_start_fstman(TRUE);
#endif
#ifndef wifi_start_fstman
ALOGD(“Starting fstman\n”);
return 1;
#endif
}

int qsap_unprepare_softap()
{
/* WJH */
#ifdef wifi_stop_fstman
ALOGD(“Stopping fstman\n”);
return wifi_stop_fstman(TRUE);
#endif
#ifndef wifi_stop_fstman
ALOGD(“Stopping fstman\n”);
return 1;
#endif
}

int qsap_is_fst_enabled()
{
/* WJH */
#ifdef is_fst_enabled
return is_fst_enabled();
#endif
#ifndef is_fst_enabled
return 0;
#endif
}
[/CODE]

And viola! This time it worked. What result that will have in the end? I’m not sure. Hopefully it still functions properly, but that remains to be seen….

Linux – keep it simple.

 

Function “appears in overlay but not in the base package”

Ah, OmniRom. Yes, I am still working on it. Hopefully you are not getting tired of these errors, but I find it helpful to log them here, and hopefully others will also. Previously, we looked at ways to use <add-resource> to add functions into a rom, but here we are just going to disable an overlay that we can work on later.

[CODE]
FAILED: /bin/bash -c “(touch out/target/common/obj/APPS/framework-res_intermediates/zipdummy ) && ((cd out/target/common/obj/APPS/framework-res_intermediates/ && jar cf package-export.apk zipdummy) ) && (zip -qd out/target/common/obj/APPS/framework-res_intermediates/package-export.apk zipdummy ) && (rm out/target/common/obj/APPS/framework-res_intermediates/zipdummy ) && (out/host/linux-x86/bin/aapt package -u -x –private-symbols com.android.internal -z –pseudo-localize -M frameworks/base/core/res/AndroidManifest.xml -S device/lge/g4-common/overlay/frameworks/base/core/res/res -S frameworks/base/core/res/res -A frameworks/base/core/res/assets –min-sdk-version 25 –target-sdk-version 25 –product default –version-code 25 –version-name 7.1.2 –skip-symbols-without-default-localization -F out/target/common/obj/APPS/framework-res_intermediates/package-export.apk )”
device/lge/g4-common/overlay/frameworks/base/core/res/res/values/config.xml:277: error: Resource at config_supportDoubleTapWake appears in overlay but not in the base package; use <add-resource> to add.
[/CODE]

So, as you can see, we have something in our overlay that is supposed to lay over the top of some source code, but the base source code doesn’t have that function to be “overlayed”. Here is where we see the overlay in device/lge/g4-common/overlay/frameworks/base/core/res/res/values/config.xml:277:

[CODE]
<!– Whether device supports double tap to wake –>
<bool name=”config_supportDoubleTapWake”>true</bool>
[/CODE]

So, we changed it to:

[CODE]
<!– Whether device supports double tap to wake
<bool name=”config_supportDoubleTapWake”>true</bool> WJH –>
[/CODE]

By commenting it out, it will no longer “overlay” it onto something that doesn’t exist. Be sure to take a look at my other article for how to use <add resource> to actually add an overlay item to the base package.

Linux – keep it simple.

 

Failed to mmap at expected address

In the continuing OmniRom saga, another day with another fail:

[CODE]FAILED: /bin/bash -c “(mkdir -p out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/ && rm -f out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex ) && (find out/target/common/obj/APPS/CaptivePortalLogin_intermediates/ -maxdepth 1 -name \”classes*.dex\” | sort | xargs zip -0qjX out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex ) && (mv out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex.input ) && (rm -f out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex ) && (mkdir -p out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/ ) && (ANDROID_LOG_TAGS=\”*:e\” out/host/linux-x86/bin/dex2oatd –runtime-arg -Xms64m –runtime-arg -Xmx512m –runtime-arg -classpath –runtime-arg \”&\” –boot-image=out/target/product/h811/dex_bootjars/system/framework/boot.art –dex-file=out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex.input –dex-location=/system/app/CaptivePortalLogin/CaptivePortalLogin.apk –oat-file=out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex –android-root=out/target/product/h811/system –instruction-set=arm64 –instruction-set-variant=generic –instruction-set-features=default –include-patch-information –runtime-arg -Xnorelocate –no-generate-debug-info –abort-on-hard-verifier-error –no-inline-from=core-oj.jar   –compile-pic ) && (rm out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex.input )”dex2oatd E 16505 16505 art/runtime/gc/heap.cc:324] Could not create image space with image file ‘out/target/product/h811/dex_bootjars/system/framework/boot.art’. Attempting to fall back to imageless running. Error was: Failed to load /system image ‘out/target/product/h811/dex_bootjars/system/framework/arm64/boot-telephony-ext.art’: Failed to mmap at expected address, mapped at 0x2b038dbfd000 instead of 0x70ddd000 : Requested region 0x70ddd000-0x70dde000 overlaps with existing map 0x70ddd000-0x70dde000 (/home/alaskalinuxuser/compile/20170727_aospa7/out/target/product/h811/dex_bootjars/system/framework/arm64/boot-telephony-ext.art)dex2oatd E 16505 16505 art/runtime/gc/heap.cc:324] 0x70ddd000-0x70dde000 rw- /home/alaskalinuxuser/compile/20170727_aospa7/out/target/product/h811/dex_bootjars/system/framework/arm64/boot-telephony-ext.art[/CODE]
It took me a while to figure this out, but the heart and soul of this problem lies with ART’s AOT (Ahead Of Time) preoptimization. Fortunately, I found a helpful tidbit on how to disable the preoptimization of this app. I did so here, in the /frameworks/base/packages/captiveportallogin/AndroidManifest.xml file:

[CODE]
    <application android:label=”@string/app_name” android:vmSafeMode=”true” >        <activity            android:name=”com.android.captiveportallog
[/CODE]
By adding android:vmSafeMode=”true”, the AOT of ART is disabled for this app. You can read more about that here: https://developer.android.com/guide/topics/manifest/application-element.html#vmSafeMode
Linux – keep it simple.

To skia or not to skia?

What is skia? Well, skia is used for drawing 2d graphics, and that is pretty important in Android.
More specifics can be read here at their website.
Essentially, it is used for making menus and drawings.

Now you are wondering why we are talking about it. Well, because we had an error:

[CODE]
ninja: error: ‘out/target/product/h811/obj_arm/STATIC_LIBRARIES/libqc-skia_intermediates/libqc-skia.a’, needed by ‘out/target/product/h811/obj_arm/SHARED_LIBRARIES/libskia_intermediates/LINKED/libskia.so’, missing and no known rule to make it
[/CODE]

As it turns out, the open source skia project was forked and some closed material was added for specific hardware, like qcom boards. So, with a few edits in ./external/skia/Android.mk, we changed it to go back to using the open source method, rather than qual comm’s specific one. All that is lost is a little bit of efficiency on qcom chips, which is actually important, but not more important than working at all.

[CODE]
#ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
# LOCAL_WHOLE_STATIC_LIBRARIES += libqc-skia
#endif
# WJH
[/CODE]

A few comments here and there, keeping it from checking if the board is a qcom board allows us to build and use the open source variant. Simple!

Linux – keep it simple.

use BUILD_PREBUILT instead!

OmniRoms Nougat. An elusive dream of mine is building OmniRoms for my devices. In the past I just couldn’t seem to get them to work. Well, I have decided to give it another go, and here was one of my first errors:

[CODE]
build/core/Makefile:34: *** Prebuilt apk found in PRODUCT_COPY_FILES: vendor/lge/g4-common/proprietary/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk:system/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk, use BUILD_PREBUILT instead!.
[/CODE]

So, I took a look at g4-common-vendor-blobs.mk:

[CODE]
vendor/lge/g4-common/proprietary/lib/libloc_ds_api.so:system/lib/libloc_ds_api.so \
vendor/lge/g4-common/proprietary/lib/libalhdri.so:system/lib/libalhdri.so \
vendor/lge/g4-common/proprietary/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk:system/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk \
vendor/lge/g4-common/proprietary/vendor/firmware/libpn547_fw_C9.so:system/vendor/firmware/libpn547_fw_C9.so \
vendor/lge/g4-common/proprietary/vendor/firmware/BCM4335_003.001.009.0117.0620_LGE_P1_EU.hcd:system/vendor/firmware/BCM43…..
[/CODE]

Here we can see that the file in question “qcrilmsgtunnel.apk” is being copied over with the vendor blobs. The error is telling us that we need to install it as a prebuilt app, instead of copying the app over as a normal file. So, I edited out that line in the g4-common-vendor-blobs.mk file, and edited g4-common-vendor.mk by adding it like so:

[CODE]
PRODUCT_PACKAGES += \
qcrilmsgtunnel \
qcnvitems \
qcrilhook
[/CODE]

Notice that I did not move the apk file around, just redefined how to get it moved into the rom. Well, that took care of that error! 1 down, untold dozens to go!

Linux – keep it simple.

 

Installing the latest PicoLisp on Ubuntu

While testing out The Quiet Learner‘s game, Dr. Theobold, a text based adventure game written in picolisp, I ran into several issues. As discussed previously, I added these issues to the bug tracker on Savannah. Come to find out, the distributed packages for Ubuntu are using version 15.xxx of picolisp, and The Quiet Learner wrote his program for version 16+. We needed to find out if the old version was the culprit, or if there truly were issues in the game.

So, I updated to version 17.7.6 (a rather interesting numbering, since I tried this the 4th of July week, but that is something else entirely).

As simple as the above statement was, my trek was not quite as simple. I am used to compiling programs. Typically, you start by unzipping the source, using ./configure, then make, and sudo make install. However, this was different.

Of course, I downloaded the source from the link in the PicoLisp Wiki. After that, I unzipped it with the standard

$ tar -xzvf ./picoLisp.tgz

and moved into the new director with

$ cd picoLisp

Once there my usual bag of tricks didn’t work, which is why it is always good to read the instructions. Ends up that I needed to cd into the src64 directory and run make. No ./configure first.

$ cd src64

$ make

And there was no option to make install. Instead I had to manually symbolically link the files, and that is where everything went wrong. You see, the INSTALL file had pre-typed instructions with all 3 links you could use, like so:

# ln -s /<installdir> /usr/lib/picolisp
# ln -s /usr/lib/picolisp/bin/picolisp /usr/bin
# ln -s /usr/lib/picolisp/bin/pil /usr/bin

But after doing that, it didn’t work. It didn’t work because I forgot that the directory was picoLisp, not picolisp. I chased my tail for a while, re-creating the same bad links over and over again until I realized my mistake. Since /<installdir> was not the directory (obviously) I was hand typing picolisp, and it wasn’t working. So, be smart and not like me. Do as I now say, not as I erroneously did!

After straightening it out, it worked great! Actually it cleared up 3 of the issues that I put on the tracker for the Dr. Theobold game. I guess it pays to have the latest and the greatest when it comes to PicoLisp!

Linux – keep it simple.

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.