Updated KPPD Control app for Android Oreo!

Now that Oreo is out, I needed to go through my apps and make adjustments and updates for the new platform. One of the biggest problems I found was that of the KPPD Control app.

For some reason, assets in the asset folder are not transferring with the apk. I fiddled with this for a while, but became so frustrated that I eventually gave up. Instead, I moved the kppd file to the /res/raw folder. The difference is, the asset folder is copied to the drive, while the raw files are hidden in the app, I think. Either way, it worked great!

You can check out the commit here: https://github.com/alaskalinuxuser/app_kppdcontrol/commit/7a781de16ddbbd047f743b7d0153e7a42867fbc4

And I have updated the Play Store, as well as posting the new apk on GitHub.

Linux – keep it simple.

Advertisements

Ril-daemon control app for LG G4 AOSCP Oreo!

I’m sure many of you are already using Kessaras’ great AOSCP Oreo Rom for the LG G4!

One small current issue is the ril-daemon sometimes needs to be stopped and started to make your sim card and cellular work properly. In the past, you could just reboot, or stop and start the daemon from the command line. But now you can just tap a button! That’s right, just a simple, easy to use app that stops or starts the ril-daemon when you tap the buttons.

This app requires root permission!

This app is open source, licensed under the Apache 2.0, and you can check out the source code here:
https://github.com/alaskalinuxuser/app_ril_control

You can download the app here:
https://github.com/alaskalinuxuser/app_ril_control/blob/master/app/Ril_Control.apk

Or get it on the Play Store!
https://play.google.com/store/apps/details?id=com.alaskalinuxuser.rilcontrol

Linux – keep it simple.

Error: TARGET_USES_UNCOMPRESSED_KERNEL is depreciated!

While starting my new attempt at an Oreo build for the H811/H815 (T-Mobile LG G4), I ran into an error, right off the bat:

Error: TARGET_USES_UNCOMPRESSED_KERNEL is depreciated!

I took a look at the make files that build the kernel. You can find them in the tasks folder under vendor/lineage/build/tasks/kernel.mk, which has a very lengthy explanation on how to name the kernel to build uncompressed images. Here is the pertinent part:

# BOARD_KERNEL_IMAGE_NAME = Built image name
# for ARM use: zImage
# for ARM64 use: Image.gz
# for uncompressed use: Image
# If using an appended DT, append ‘-dtb’
# to the end of the image name.
# For example, for ARM devices,
# use zImage-dtb instead of zImage.

So all I had to do was remove this line from my device/lge/g4-common/BoardConfigCommon.mk file:

TARGET_USES_UNCOMPRESSED_KERNEL := true

Because my kernel has the naming convention like so:

BOARD_KERNEL_IMAGE_NAME := Image

Which alludes to an uncompressed image already. I love it when the solution is easy!

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.

 

LG G4 on SlimRoms: delete the pin key in TWRP!

In my last post, I told the epic adventure of figuring out how to get into recovery mode so I could fix my unbooting phone. I had performed a backup of SlimRoms before trying to flash OmniRom, and since I was back into TWRP, I restored my backup. Figuring all was well, I rebooted.

Everything booted up great. However, once into the rom, it asked for my screen lock pin, as usual. But unlike the normal response, it kept saying that I was entering the wrong pin. I tried my pin, my old pin, and no pin. No luck. It wasn’t working.

There are a lot of articles on this, and this will not be much new, however, the names of my lock files were different than the article I read, so I am posting the names of the files here in case I forget when this happens to me again. (Most of this blog is simply my own scratchpad of notes to help me remember something….)

So, power off the phone, and jump back into TWRP (see the previous post if you need help with that). In TWRP, go to Advanced – > File Manager.

Scroll down to the /data folder. Open the /system folder and look at the contents.

On my phone I had to delete these files to disable the lock:

gatekeeper.password.key

gatekeeper.pattern.key

locksettings.db

locksettings.db-shm

locksettings.db-wal

After deleting these five files in the TWRP file manager, I then rebooted the phone. Sure enough, now I had no lock screen settings nor pin in the ROM. Back in action! I, of course, immediately set up a new lock screen and pin for security purposes. Hopefully that helps you too!

Linux – keep it simple.

How to get to TWRP on a LG G4 with the hardware buttons….

This is something that should be easy. Really easy. However, it took me a while to find this on the web, and since it did, I’m posting it here too. On XDA, there is a thread about this, intermingled with numerous other threads that say different or sometimes erroneous information.

Back story:

I flashed my LG G4 T-Mobile (H811) phone with a new custom rom I built – OmniRom. Only it didn’t boot. Don’t know why yet, I’m making an engineering build now so I can use ADB to figure that out. As far as I knew, the only ways to get to TWRP were to choose such from your power down menu, or use ADB to reboot into recovery. I thought all was lost, because ADB was not set to on in my custom build, and there was no way to get to TWRP, or so I thought.

I started trying every button combination I could think of.

Found the IMEI screen:

This did lead me to an interesting discovery, if you press Volume down + Volume up + Power, then, when you see the LG logo, release Power (but hold the volumes) wait a second, then press and hold the Power button with the volume buttons, you go into a special IEMI screen that displays a barcode with your IMEI on it.

But I didn’t need that. Quite frankly, you can just open the case and read the sticker to know your IMEI, so this was useless to me, but interesting enough for me to note it here.

After multiple tries, I found the “Factory Reset” screen by holding Volume down + Power, then, when you see the LG logo, release Power (but hold the volume) wait a second, then press and hold the Power button with the volume button. This will take you to the “Factory Reset” screen.  I thought that was no good. I wanted to get to the recovery mode.

However, feeling frustrated and hopeless, I chose “yes” for the factory reset. Interestingly, it then flashed the screen, and took me to TWRP!

Believe me, I was very happy!

So, if TWRP is installed properly, then you can get there by entering “Factory Reset” mode, and selecting “yes”. Simply confusing, right? I guess when you say “yes” on stock firmware, it boots stock recovery and performs a factory reset, but since there is no stock recovery, it enters TWRP with a reset flag, which TWRP doesn’t use. Makes sense, I guess. Too bad they just didn’t make it so when you push volume down and the power button during startup that it would just take you to recovery mode like every other Android phone on the market.

Linux – keep it simple.