Android 10 on the XA2 Ultra!

Okay, so I’ve been playing around some more with the SODP material and AOSP 10. That’s right, they decided to stop naming Android versions after deserts and just give them numbers. Seems lame to me, but, oh well.

Either way, I did a build of Android 10 with the SODP material, and it is interesting. I’m also using the new 4.14 kernel as well, which is great to keep progressing with newer kernels.

Unfortunately, it’s not quite ready for release yet, it has random crashes and many issues at present, so perhaps I’ll go back and build Android 10 with the 4.9 kernel instead.

Linux – keep it simple.

Fix for MTP/PTP crashes on the XA2 Ultra!

One of the prevailing issues with the SODP build of AOSP was that every time I hooked up my phone to the computer to transfer files, it would cause the phone to crash and reboot. Obviously that is not very productive. I was a bit stumped and decided to join the unofficial SODP telegram group and ask if the developers there had ever seen this issue.

Sure enough, they had. Not only that, but they pointed me to a bug-tacker tool that allowed me to search issues they’ve seen before! It was a huge help! In there, I found a post by a user who had similar problems with another SODP phone. More importantly, there was a helpful response from a developer who pointed out what the issue was, and how to fix it!

It appears that the problem is the buffer size for the file transfer. All one has to do to fix it was make a simple change to the buffer size in

drivers/usb/gadget/function/f_mtp.c

Once you make the edits, then MTP works. He put together a patch, if you don’t want to hand edit them. Here it is:

diff --git a/drivers/usb/gadget/function/f_mtp.c b/drivers/usb/gadget/function/f_mtp.c
index 7692b9d86633..ddf5faedc3c6 100644
--- a/drivers/usb/gadget/function/f_mtp.c
+++ b/drivers/usb/gadget/function/f_mtp.c
@@ -42,8 +42,8 @@
 
 #include "../configfs.h"
 
-#define MTP_RX_BUFFER_INIT_SIZE    1048576
-#define MTP_TX_BUFFER_INIT_SIZE    1048576
+#define MTP_RX_BUFFER_INIT_SIZE    16384
+#define MTP_TX_BUFFER_INIT_SIZE    16384
 #define MTP_BULK_BUFFER_SIZE       16384
 #define INTR_BUFFER_SIZE           28
 #define MAX_INST_NAME_LEN          40

It’s great to have that working properly now! It’s also great to work with a team of really helpful developers, for a change.

Linux – keep it simple.

Google Apps on the SODP AOSP for the XA2 Ultra?

As you know, I’ve gone Google App-less, or “gappless”. But, for better or worse, not all of my ROM users have done the same. Typically, when you build a custom ROM, you build it without things like ROOT or GAPPS, and leave it to the ROM user to decide what they would like to install. In the case of installing GAPPS, they typically use TWRP to flash an opengapps zip file that installs all the desired Google Apps.

This is useful, because there are lots of Google Apps, and users may want some of them, but not all of them. Thus, when you install your zip from opengapps, you choose how many Google Apps you would like, pico, nano, mini, stock, full, etc., the bigger the tag, the more Google Apps you get.

Unfortunately, my SODP based AOSP ROM has an issue with Gapps. As I said, I don’t use Gapps anymore, but my users reported that they could not install Gapps. So I tried installing it myself to see what the issue was. Sure enough, it would install properly, but when you booted into the phone, the Gapps were not there! It was as if they never installed. I’d like to take credit for the Gapps resistant ROM, but it was purely unintentional.

So, this may seem counter productive, but I’ve release a build with built in Gapps as well. Since the end user can’t install it themselves, you can actually follow opengapps guide to build your ROM with Gapps included in the build. While I don’t like using Gapps anymore, I certainly want others to have the freedom to do so. The only difficult thing was figuring out which level of Gapps to include. In the end I decided with “stock”, which is less that full or all, and more than pico, nano, and mini. I figure that if you want Gapps, you probably want the standard, or stock amount of programs.

The only downside, is it makes my build almost three times the size! Believe me, it took three times longer to upload too! I think next go around, I’ll probably use mini for the Gapps level, to save myself some uploading bandwidth. I of course, still release my own builds without Gapps, for those so inclined.

Linux – keep it simple.

Fixing Camera issues with SODP/AOSP on the XA2 Ultra

c

Well, last post I was telling you how I started using the SODP material to build AOSP on the XA2 Ultra, and how well it worked. However, there were a few issues. One notable issue was with the camera preview, and how it would look green. The pictures themselves would be fine, but the display would look green while taking them. That obviously would not do.

One thing I came to realize is that the manifest I was using downloaded the 4.9 kernel source, but also a pre-built 4.9 kernel to be used during the build. Once it was deemed stable, they start using the pre-built kernel instead of building them from source while you build Android. This saves time and resources, but isn’t (in my opinion) a good idea.

So, I decided to build the kernel from source myself, instead of using the pre-built one. Long story short, I simply had to delete the kernel/sony/4.9/common-kernel/ folder and all of it’s contents to force the build process to also build the kernel from the already available source code.

Once I did that, not only did it build the 4.9 kernel from source, but, to God be the glory, it also fixed the green camera display issue! So, it looks like some code or another was updated somewhere along the line and the older pre-built kernel did not interact well with that code, or did not take advantage of it…. Either way, I’m quite pleased to have the kernel built from source and the camera working properly!

Linux – keep it simple.

AOSP with the SODP on XA2 Ultra!

Alright! Well, the first build of AOSP using the SODP on the XA2 Ultra are out! For those who are caught in acronym paralysis, that is the Android Open Source Project built using the Sony Open Devices Project. I used the SODP material to build my first AOSP ROM with it. And, I like it.

There are, however, a few issues. So far, the camera sometimes turns green when displaying the preview, but the pictures come out normal. Also, MTP/PTP (connecting to your computer to transfer files) causes the phone to crash at times. This is a bit of a problem. The FM radio does not work, and the gallery app can’t play back videos.

Originally, I thought the videos were not recording properly, but I found installing any other app to view/playback videos worked just fine. Just the built in app doesn’t have the ability to play back videos.

Well, that is very interesting, no I need to figure out how to fix this. On the plus side, I did use the newer 4.9 kernel, as opposed to the original 4.4 kernel, so that is an exciting step in the right direction! You can check out my builds on XDA if you’d like.

Linux – keep it simple.

Sony Open Device Project and the Xperia XA2 Ultra….

Now that I’ve built a few ROMs for the XA2 Ultra (AOKP and Resurrection Remix), I’ve turned my attention to the Sony Open Devices Project. The SODP, as it is abbreviated, is an effort to make custom ROMs for various Sony devices that are as open source as possible. This includes reducing the amount of vendor blobs (binary large objects) by replacing them with open source code wherever possible.

While the phones in this program are not 100% vendor blob free, they are dramatically reduced and continue progressing as time goes on and developers continue their work. It’s a great idea with several volunteer and professional staff members (courtesy of Sony), and I am all for it. Here is their statement from their web page linked above:

For some of the Xperia™ devices, we provide Android™ Open Source Project (AOSP) device configurations on GitHub. This means that the software will be open for you as a developer to use and contribute to. This is a way for us to support the open Android community, and it is also a tool for us to facilitate and verify contributions to AOSP.

That said, I’ve started progressing in that direction. I’m not skilled enough to do the helpful work of breaking down blobs and coding an open source alternative, but I’m jumping in by using their material as a base for my ROMs that I build.

One of the greatest advantages I see in using this material is the newer kernels. The XA2 Ultra comes with kernel version 4.4. However, the SODP includes kernels 4.9 and 4.14! Using a newer kernel brings better performance and enhanced security, which is always a plus!

It will be interesting to see what comes of this, how functional the ROMs are, and where I can go from here….

Linux – Keep it simple.

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.

Apache bouncy castles….

So, another day, and another error. While building SlimRoms 7 for the Note Edge, I ran into this error:

[CODE]
[ 0% 60/15886] Docs droiddoc: /home/a…rget/common/docs/apache-http-stubs-gen
external/apache-http/../../frameworks/base/core/java/android/net/http/SslCertificate.java:19: error: cannot find symbol
import com.android.internal.util.HexDump;
^
symbol: class HexDump
location: package com.android.internal.util
external/apache-http/../../frameworks/base/core/java/android/net/http/SslCertificate.java:42: error: package com.android.org.bouncycastle.asn1.x509 does not exist
import com.android.org.bouncycastle.asn1.x509.X509Name;
^
external/apache-http/../../frameworks/base/core/java/android/net/http/HttpResponseCache.java:19: error: package com.android.okhttp does not exist
import com.android.okhttp.Cache;
^
external/apache-http/../../frameworks/base/core/java/android/net/http/HttpResponseCache.java:20: error: package com.android.okhttp does not exist
import com.android.okhttp.AndroidShimResponseCache;
[/CODE]

Hours of online surfing and scrounging, and trying different things led me to this Google issue:
https://code.google.com/p/android/issues/detail?id=230820

That perfectly detailed the same problem I had, as well as providing a viable solution. So I implemented it by opening build_slim7/external/apache-http/Android.mk, which read (among other things) :

[CODE]
LOCAL_JAVA_LIBRARIES := $(apache_http_java_libs)
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH)/src \
$(LOCAL_PATH)/android \
$(LOCAL_PATH)/../../frameworks/base/core/java/org/apache
[/CODE]

And exchanged it with this:

[CODE]
# WJH LOCAL_JAVA_LIBRARIES := $(apache_http_java_libs)
LOCAL_JAVA_LIBRARIES := $(apache_http_java_libs) okhttp bouncycastle framework
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH)/src \
$(LOCAL_PATH)/android \
$(LOCAL_PATH)/../../frameworks/base/core/java/org/apache
[/CODE]

And the problem went away! So, I thought I’d share in case any of my readers had a similar issue.

Linux – keep it simple.

Insert an explicit cast to silence issue…

In the continuing saga of compiling AOSP 7 for the Samsung Galaxy S4, T-Mobile variant (SGH-M919, JFLTETMO) I ran into an interesting problem. While this used to be a non-issue for building Marshmallow and earlier, libcopybit seems to now have a problem in Nougat. Let’s take a look:

[CODE]
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1390:40: note: insert an explicit cast to silence this issue
struct copybit_rect_t dr = { 0, 0, dst->w, dst->h };
^~~~~~
static_cast<int>( )
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1390:48: error: non-constant-expression cannot be narrowed from type ‘uint32_t’ (aka ‘unsigned int’) to ‘int’ in initializer list [-Wc++11-narrowing]
struct copybit_rect_t dr = { 0, 0, dst->w, dst->h };
^~~~~~
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1390:48: note: insert an explicit cast to silence this issue
struct copybit_rect_t dr = { 0, 0, dst->w, dst->h };
^~~~~~
static_cast<int>( )
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1391:40: error: non-constant-expression cannot be narrowed from type ‘uint32_t’ (aka ‘unsigned int’) to ‘int’ in initializer list [-Wc++11-narrowing]
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
^~~~~~
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1391:40: note: insert an explicit cast to silence this issue
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
^~~~~~
static_cast<int>( )
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1391:48: error: non-constant-expression cannot be narrowed from type ‘uint32_t’ (aka ‘unsigned int’) to ‘int’ in initializer list [-Wc++11-narrowing]
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
^~~~~~
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1391:48: note: insert an explicit cast to silence this issue
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
^~~~~~
static_cast<int>( )
4 errors generated.
ninja: build stopped: subcommand failed.
make: *** [ninja_wrapper] Error 1
[/CODE]

So, I changed hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp from this:

[CODE]
struct copybit_rect_t dr = { 0, 0, dst->w, dst->h };
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
[/CODE]

To this:

[CODE]
struct copybit_rect_t dr = { 0, 0, (int)dst->w, (int)dst->h };
struct copybit_rect_t sr = { 0, 0, (int)src->w, (int)src->h };
[/CODE]

And it compiled sucessfully. Unfortunately, I don’t know how well that fixed the problem (or, if at all), since the AOSP 7 will currently not boot on my S4. But I’ll keep at it!

Linux – keep it simple.

Device configurations are no longer allowed to change the global flags… error bailing…

Sometimes Android does stuff that is probably a good idea, but is really annoying to the compiler. By compiler, I mean guys or gals like you and I who really want to compile AOSP 7.0, but can’t because all of our old device trees have cflags set. Without warning, AOSP institues the ninja build system, and then declares all cflags to be illegal. Bummer.

Bummer that is, unless we disable the bailout.

Open up ./build/core/config.mk, and scroll down to line 630, where you should see the below.

[CODE]
# ###############################################################
# Set up final options.
# ###############################################################

ifneq ($(COMMON_GLOBAL_CFLAGS)$(COMMON_GLOBAL_CPPFLAGS),)
$(warning COMMON_GLOBAL_C(PP)FLAGS changed)
$(info *** Device configurations are no longer allowed to change the global flags.)
$(info *** COMMON_GLOBAL_CFLAGS: $(COMMON_GLOBAL_CFLAGS))
$(info *** COMMON_GLOBAL_CPPFLAGS: $(COMMON_GLOBAL_CPPFLAGS))
$(error bailing…)
endif
[/CODE]

Which I changed to this:

[CODE]
# ###############################################################
# Set up final options.
# ###############################################################
#I disagree with your cflags policy. So there. (Go ahead and tell AOSP how you really feel.)
#ifneq ($(COMMON_GLOBAL_CFLAGS)$(COMMON_GLOBAL_CPPFLAGS),)
#$(warning COMMON_GLOBAL_C(PP)FLAGS changed)
#$(info *** Device configurations are no longer allowed to change the global flags.)
#$(info *** COMMON_GLOBAL_CFLAGS: $(COMMON_GLOBAL_CFLAGS))
#$(info *** COMMON_GLOBAL_CPPFLAGS: $(COMMON_GLOBAL_CPPFLAGS))
#$(error bailing…)
#endif
[/CODE]

Problem solved. you may now use your good ol’ cflags. Carry on.

Linux – keep it simple.