field designator ‘suspend’ does not refer to any field in type ‘struct early_suspend’

Lately I’ve been going through the Xperia XA2 Ultra kernel (sdm660) and trying to add new features. Today I was adding in some governors, and several of them had the same underlying issues. Part of the problem was that I got the governors from a 3.10 kernel and put them into a 4.4 kernel, so understandably some things have changed.

I received a series of errors while compiling, complaining about early suspend. Here are some examples:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass2.c: undefined reference to `register_early_suspend’

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass.c:739: undefined reference to `register_early_suspend’

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_interactivex.c:641: undefined reference to `register_early_suspend’
/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_interactivex.c:670: undefined reference to `unregister_early_suspend’

 

field designator ‘suspend’ does not refer to any field in type ‘struct early_suspend’

All of these errors came after I had received an error about the compiler being unable to find linux/early_suspend.h. So I downloaded that file from the internet and put it in the include directory, only to realize that I needed the c file as well! Again, I downloaded the c file and put it in, only to find that the header and code file didn’t match. They were from different kernels and didn’t match up. Anyhow, once I found the most up to date version of the file, then I could actually use it! Here’s my commit if you want to check it out.

Either way, if you run into a similar message, make sure you have set “CONFIG_HAS_EARLYSUSPEND=Y” in your defconfig, or when you compile your kernel, it wont actually get turned on or built!

Linux – keep it simple.

cpufreq_interactivex.c:239:9: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]

Lately I’ve been going through the Xperia XA2 Ultra kernel (sdm660) and trying to add new features. Today I was adding in some governors, specific to this post, is the interactiveX governor.

That’s when I ran into this error:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_interactivex.c:239:9: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]
return strict_strtoul(buf, 0, &min_sample_time);

It took me a while to find an answer for it, but once I did, I saw it over and over again as I added more govs to the kernel:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_brazilianwax.c:406:15: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]
res = strict_strtoul(buf, 0, &input);

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_skywalker.c:723:5: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]
if(strict_strtoul(buf, 0, &inc_cpu_load)==-EINVAL) return -EINVAL;

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass2.c: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]
if(strict_strtoul(buf, 0, &inc_cpu_load)==-EINVAL) return -EINVAL;

 

etc…..

With about half of the governors that I added, this error popped up, mainly because I was taking the govs from an older 3.10 kernel and trying to apply them to a 4.4 kernel. That’s a pretty big jump, and several parts of the code gave me interesting errors to hunt down, but this one was so simple to fix, just hard to find. I can’t take the credit, though, since I found this thread where a guy had a similar issue and fixed it.

According to Vasiliy Tolstov:

strict_strtoul() was just a redefinition of kstrtoul() for a long
time. From kernel version of 3.18, strict_strtoul() will not be
defined at all. A compile time kernel version check is needed to
decide which function or macro can be used for a specific version of
kernel.

Fortunately, the fix was pretty simple. Using gedit, I replaced every instance of “strict_strtoul” with “kstrtoul” in each of these governors. After that, the error not only went away, but the govs actually worked!

Linux – keep it simple.

E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.android.systemui.keyguard.KeyguardService

Oh boy! I finally got AOKP to boot up in an Engineering build for the XA2 Ultra (discovery). However, once you get through the setup pages, it crashes at the home screen. Here’s the logcat output:

——— beginning of crash
08-21 04:12:30.094 3050 3050 E AndroidRuntime: FATAL EXCEPTION: main
08-21 04:12:30.094 3050 3050 E AndroidRuntime: Process: com.android.systemui, PID: 3050
08-21 04:12:30.094 3050 3050 E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.android.systemui.keyguard.KeyguardService: java.lang.NullPointerException: Attempt to invoke interface method ‘android.service.gesture.IEdgeGestureHostCallback android.service.gesture.IEdgeGestureService.registerEdgeGestureActivationListener(android.service.gesture.IEdgeGestureActivationListener)’ on a null object reference
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:3582)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:200)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1672)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6718)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke interface method ‘android.service.gesture.IEdgeGestureHostCallback android.service.gesture.IEdgeGestureService.registerEdgeGestureActivationListener(android.service.gesture.IEdgeGestureActivationListener)’ on a null object reference
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.service.gesture.EdgeGestureManager.setEdgeGestureActivationListener(EdgeGestureManager.java:178)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.statusbar.pie.PieController.init(PieController.java:126)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar.updatePieControls(StatusBar.java:6201)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar$19.onChange(StatusBar.java:5464)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar.start(StatusBar.java:886)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.SystemBars.createStatusBarFromConfig(SystemBars.java:71)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.SystemBars.start(SystemBars.java:42)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.SystemUIApplication.startServicesIfNeeded(SystemUIApplication.java:185)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.SystemUIApplication.startServicesIfNeeded(SystemUIApplication.java:129)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.keyguard.KeyguardService.onCreate(KeyguardService.java:48)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:3570)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: … 8 more
08-21 04:12:30.100 1445 1478 V RescueParty: Disabled because of eng build

There is a lot in there, but here is the important part:

Caused by: java.lang.NullPointerException: Attempt to invoke interface method ‘android.service.gesture.IEdgeGestureHostCallback android.service.gesture.IEdgeGestureService.registerEdgeGestureActivationListener(android.service.gesture.IEdgeGestureActivationListener)’ on a null object reference

08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.service.gesture.EdgeGestureManager.setEdgeGestureActivationListener(EdgeGestureManager.java:178)

So, I took a look at EdgeGestureManager.java, around line 178, which is reportedly the problem:

public boolean setEdgeGestureActivationListener(EdgeGestureActivationListener listener) {
if (DEBUG) {
Slog.d(TAG, “Set edge gesture activation listener”);
}
try {
IEdgeGestureHostCallback callback = mPs.registerEdgeGestureActivationListener(listener.mDelegator);
listener.setHostCallback(callback);
return true;
} catch (RemoteException e) {
Slog.e(TAG, “Failed to set edge gesture activation listener: ” + e.getMessage());
return false;
}
}

I took a look at Lineage and RR, and ended up adding new code to my files to fix it. Here’s what I put in, based on what I saw in the other working ROMs:

public void updateEdgeGestureActivationListener(EdgeGestureActivationListener listener, int positions) {
if (DEBUG) {
Slog.d(TAG, “Update edge gesture activation listener: 0x” + Integer.toHexString(positions));
}
if (mPs == null) {
Slog.e(TAG, “Failed to update edge gesture activation listener: Service not present”);
return;
}
try {
mPs.updateEdgeGestureActivationListener(listener.mDelegator.asBinder(), positions);
} catch (RemoteException e) {
Slog.e(TAG, “Failed to update edge gesture activation listener: ” + e.getMessage());
}
}

So now it will check if it is “null” or empty before trying to use it. If it is empty, it exits rather than crashing because it is empty. If it’s not empty, it will use it instead. Praise God! This even worked! After fixing this last piece of the puzzle, AOKP Pie finally booted and worked on my XA2 Ultra!

Linux – keep it simple.

system/bt/stack/btu/btu_hcif.cc:729:22: error: no member named ‘BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED’ in namespace ‘android::util’

Several Bluetooth issues were really giving me the run around while trying to compile AOKP for the Xperia XA2 Ultra. Let’s take a look:

system/bt/stack/btu/btu_hcif.cc:729:22: error: no member named ‘BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED’ in namespace ‘android::util’
android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, “”, handle,
~~~~~~~~~~~~~~~^
system/bt/stack/btu/btu_hcif.cc:1698:22: error: no member named ‘BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED’ in namespace ‘android::util’
android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, “”, handle,
~~~~~~~~~~~~~~~^
2 errors generated.

I made several changes to the system/bt/stack/btu/btu_hcif.cc file:

Changed: Line 729
static void read_encryption_key_size_complete_after_encryption_change(
uint8_t status, uint16_t handle, uint8_t key_size) {
int ret = 0;
//WJH int ret = android::util::stats_write(
//WJH android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, “”, handle,
//WJH HCI_READ_ENCR_KEY_SIZE, HCI_COMMAND_COMPLETE_EVT, status, 0, key_size);
if (ret < 0) {
LOG(WARNING) << __func__ << “: failed to log encryption key size ”
<< std::to_string(key_size);
}

changed line 1698
static void read_encryption_key_size_complete_after_key_refresh(
uint8_t status, uint16_t handle, uint8_t key_size) {
int ret = 0;
//WJH int ret = android::util::stats_write(
//WJH android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, “”, handle,
//WJH HCI_READ_ENCR_KEY_SIZE, HCI_COMMAND_COMPLETE_EVT, status, 0, key_size);
if (ret < 0) {
LOG(WARNING) << __func__ << “: failed to log encryption key size ”
<< std::to_string(key_size);
}

At first I was really worried about the outcome of these changes, but the Bluetooth still seems to work properly in all my tests. So I’m not sure what it is that I “removed”. Hopefully it’s nothing important, but it does beg the question: when are we cutting something out that we actually need? How do we know when we get there?

This did “fix” the issue during compile, and since the Bluetooth works, I’m going to go with it is okay…..

Linux – keep it simple.

error: vendor/qcom/opensource/cryptfs_hw/Android.bp:27:37: unrecognized property “product_variables.lineage.uses_metadata_as_fde_key”

Another random error while compiling AOKP pie for the XA2 Ultra. These calls work properly when compiling Lineage, but don’t work in the AOKP source tree, so I did some digging.

error: vendor/qcom/opensource/cryptfs_hw/Android.bp:27:37: unrecognized property “product_variables.lineage.uses_metadata_as_fde_key”

In the end, I found that the only way around it was to remove the unrecognized property, since this isn’t LineageOS, it isn’t declared anywhere in AOKP. So, I edited vendor/qcom/opensource/cryptfs_hw/Android.bp at line 27, like so:

//WJH uses_metadata_as_fde_key: {
//WJH cflags: [“-DUSE_METADATA_FOR_KEY”],
//WJH },

By commenting them out, they are basically deleted. This seemed to work well, and so far, hasn’t hampered any of the rom functions.

Linux – keep it simple.

system.com/vold/Ext4Crypt.cpp:204:12: error: use of undeclared identifier ‘fs_mgr_is_wrapped_key_supported’

Another strange set of errors while compiling AOKP. It seems like they are in the middle of merging some Lineage commits, but didn’t finish them. Either way, I ran into this problem with Ext3Crypt:

compile system.com/vold/Ext4Crypt.cpp:204:12: error: use of undeclared identifier ‘fs_mgr_is_wrapped_key_supported’

So, I took a look at line 204 from system.com/vold/Ext4Crypt.cpp, and this is what I saw:

bool is_wrapped_key_supported() {
return fs_mgr_is_wrapped_key_supported(
fs_mgr_get_entry_for_mount_point(fstab_default, DATA_MNT_POINT));
}

This didn’t make sense to me, since the call is for a bool, the answer must be true or false, zero or one. Instead it is trying to grab some information and determine if it is true or false based on that. I spent hours trying to crack down on it, but I couldn’t find how this all washed out. In the end, I made this edit to get through this error:

bool is_wrapped_key_supported() {
//return fs_mgr_is_wrapped_key_supported(
// fs_mgr_get_entry_for_mount_point(fstab_default, DATA_MNT_POINT)); //WJH
return false; //WJH
}

Essentially, I returned false. I debated about what to return, but I don’t want it to use it, since I can’t correctly fix it, so I decided false was my best bet. Sure enough, that worked.

Linux – keep it simple.

Resurrection Remix Pie for the XA2 Ultra!

To God be the glory, I finally finished a XA2 Ultra build of Resurrection Remix! It’s Resurrection Remix, Pie flavored! You can check it out on XDA if you would like, but here is my post from there:

Here’s a quote from RR:

We work to make your android experience elegant. Handpicked features beautifully packed into one ROM.

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

A huge thanks to the Resurrection Remix team! Another huge thanks goes out to XDA developer LuK1337 for all of the great development that he did on the Sony Xperia XA2 Ultra! He did most of the heavy lifting by making a great LineageOS build, upon which this RR is based. Please note, this is an UNOFFICIAL ROM.

Disclaimer: Resurrection Remix is not responsible for any damages to your device.
All of my work is completely available for any who wish to use or modify it. I didn’t make Resurrection Remix, the device trees, or vendor blobs. I simply used and edited existing material. A huge thanks should go to those who actually created this stuff.

This Unofficial Resurrection Remix Pie ROM was built for H3223 (discovery), but may work on some of the other variants, please try at your own risk. However, if you do try it on another variant, please be sure to let me know in the comments how it worked.

Downloads:
Rom Download link:
WARNING: This is only for those on firmware versions 50.1.xxxxxx, not for those who are on firmware versions 50.2.xxxx and up. I plan on working on updated firmware versions later.
http://www.mediafire.com/folder/6ni8bw8ansajf/pie
There is an ENGINEERING and USERDEBUG build. The ENG build is marked “ENG” for testing purposes only. You can install anything you want, but I recommend not installing the ENG build.

Gapps link:
[url]http://opengapps.org/[/url]
If desired. Personally, I’ve gone Gapp-less.

Installation instructions:
-Download ROM and gapps, and put them on your removable sdcard storage. (Or leave on your computer and flash with adb sideload.)
-Reboot into the bootloader.
-Fastboot boot your TWRP.
-Backup what you had. (Just to be safe.)
-Wipe everything and format data.
-Install Rom. (Either from adb sideload or from your removable sdcard storage.)
-Reboot to system and enjoy!
If you also want Gapps:
-Reboot again into the bootloader.
-Fastboot boot your TWRP.
-Install Gapps. – Optional
If you plan to install magisk (good idea), then let the rom boot the first time, then go back to TWRP and flash magisk. This is optional, of course.

What works:

So far everything that I have tried works, such as

Camera for pictures and video, Phone calls, Data 3g/LTE, Bluetooth, WiFi, MTP, etc….

What doesn’t: Nothing that I know of, but if you find something, please let me know so we can try to fix it!

Source Code:
https://github.com/ResurrectionRemix
Official website:
http://www.resurrectionremix.com/
My device trees, vendor blobs, and kernel source:
https://gitlab.com/alaskalinuxuser

ROM OS Version: 9.0 Pie
RR version: 7.0.2
ROM Kernel: Linux 4.4.153
Based On: The best of every ROM, but particularly based on LineageOS.

Created 2019-08-16

Linux – keep it simple

 

Engineering Pie Build for the Sony Xperia XA2 Ultra!

So it’s been a rough start for me, stepping into the modern world with a modern phone that has a/b partitioning and was Android 8.0+. I’ve built dozens of roms for dozens of phones, some that were even unsupported, and to God be the glory, I was moderately successful, but these modern phones have been a different story. My first attempt with the Xperia XA2 Ultra ended up hard bricked. Then, I built a pie version of AOKP, which did boot, but would immediately crash after getting to the home screen.

Today, however, was off to a much better start. I successfully tested my engineering build of LineageOS 16.0 (pie) for my XA2 Ultra (discovery). Everything seems to work well, and you are welcome to try it out. Keep in mind, though, it is an engineering build as opposed to a user build. Also note that this is for the 50.1.x firmware variants.

Granted, a lineage build is already available, and most of the work was done by Luke. I like to compile a build on my own, though, to make sure my system is set up properly and that the source material does work before I get started on my own roms.

Now to get back to that AOKP build…. Or should I start on a Resurrection Remix build instead?

Linux – keep it simple.

Beginning AOKP Pie for the Xperia XA2 Ultra

I knew I couldn’t keep away from Android forever. It was only a matter of time before I jumped back into development. A lot has changed since my old rom building days. Back then everything was pre-treble, and there were no A/B partitions. That all changed for me with an Xperia XA2 Ultra.

It seems harder than I remember, and a lot more time intensive than it used to be. But, to kick things off, I started by building AOKP Pie for my new phone. To God be the glory, it does boot, but it doesn’t work right. Something is causing a pretty big hang up as soon as you are done with the setup. It locks up graphically once you get to the home screen for the first time.

Initial thoughts are perhaps tiles or menu item problems, but we will see.

Under the hood, though, everything is still running, even though the screen doesn’t update. If you use ADB, you can connect and do all the usual ADB command line stuff. But that doesn’t make for a very handy cell phone if you have to bring your computer everywhere so you can use it!

It’s also a bit harder as I had to switch to a nano sim card to be able to use the XA2. This is a problem because all of my other phones are not nano. It makes it difficult to switch to another phone while I test this out. Using a phone as your daily driver and for developing is a bit cumbersome and does slow me down quite a bit, but hopefully I’ll be able to work on it more later.

If you want to try out the “alpha” of my rom, you can download it on my MediaFire account. I will warn you, though, it doesn’t work very well.

Linux – keep it simple.

Fixing my bricked Sony Xperia XA2 Ultra

a

The photo above is not a mirrored image, it is actually two distinct Sony Xperia XA2 Ultra phones.

Whether it is fishing or phones, it all has to start with a story. Unlike fishing, though, this phone story really does start out as a big whopper! I guess I should back track to the beginning….

I was researching a new phone for Mom, and found that the Xperia XA2 Ultra is a really, really great phone. Sure, there are reviewers that were not enthusiastic, and some that were ecstatic, but I really felt that this would be a great phone for my mom. And I think it is. In fact, I liked it so much, that I picked up a slightly used one for myself. All was well.

Then, I decided to ditch the stock rom and start working on some custom stuff, as usual. The first thing I needed to do was test a current custom rom someone else made to make sure things work, and that I understand what’s going on under the hood. That is where things went horribly wrong.

I was following a guide on XDA. Several users had a similar guide, so I figure it must be right. Unfortunately, it not only didn’t work, but following the guide to a “T” bricked my phone. Here’s where I got hung up:

1. Download latest firmware with XperiFirm.
NOTE: When using mono XperiFirm will fail to unpack the firmware, you can do it manually using following commands:

Code:
for f in FILE_*; do unzip $f; done
unzip boot.zip -d boot

2. Go to the directory where the firmware got downloaded to and remove following files:
– kernel_X-FLASH-ALL-18AE_0x00.hash
– kernel_X-FLASH-ALL-18AE.sin
– persist_X-FLASH-ALL-18AE_0x00.hash
– persist_X-FLASH-ALL-18AE.sin
– system_other_X-FLASH-ALL-18AE_0x00.hash
– system_other_X-FLASH-ALL-18AE.sin
– system_other_X-FLASH-ALL-9B8D_0x00.hash
– system_X-FLASH-ALL-18AE_0x00.hash
– system_X-FLASH-ALL-18AE.sin
– system_X-FLASH-ALL-9B8D_0x00.hash
– userdata_X-FLASH-CUST-18AE.sin
– vendor_X-FLASH-ALL-18AE_0x00.hash
– vendor_X-FLASH-ALL-18AE.sin
– vendor_X-FLASH-ALL-9B8D_0x00.hash
3. Turn off your phone, hold vol dn and plug in the USB cable, the screen should be off and green LED lit.
4. Run Newflasher, it’ll flash entire FW to your current slot then unplug the USB cable and power on your phone.
5. Turn off your phone, hold vol up and plug in the USB cable, the screen should be off and blue LED lit.
6. Enter this command: `fastboot getvar current-slot`, it should return something like this:
current-slot: _b
Finished. Total time: 0.001s
7. Now switch to the opposite slot by entering command: `fastboot set_active a` if the current slot is `_b` or `fastboot set_active b` if its `_a`, you should see this:
Setting current slot to ‘a’…
OKAY [ 0.012s]
Finished. Total time: 0.014s
or
Setting current slot to ‘b’…
OKAY [ 0.012s]
Finished. Total time: 0.014s
8. Unplug usb cable and repeat steps: 3, 4
9. Profit?

At step 7, I was supposed to switch to the other slot. So I did, but when I unplugged the USB cable and repeat steps 3 and 4, it bricked the phone on the repeat of step 4. After that, it never booted up. All that happened when plugging it in or pressing any button combo was a triple blink of the green LED, and nothing else.

So, I made a post on the thread asking for help. But there was none to be found. Shortly after my post, others started posting as well. They all had the same issue. So, I take comfort in my misery loving company. Although I wish other’s phones had not also bricked, I was somewhat glad that I didn’t “mess up”, since several others following the instructions had the same results. What went wrong? I really don’t know.

The big question became, how do I fix it? I had about $100 invested in this useless paperweight, so I really wanted to turn a positive result. Thus enter ebay. I started bidding on phones with broken screens. I really just wanted to buy another main board, or motherboard for the phone, but I couldn’t find any suppliers. Eventually, I won a phone with a shattered screen.

The screen may have been shattered, but the phone still turned on and worked, so I simply disassembled the two phones (my brick and the one with the shattered screen) and swapped the main board! Now I had a working phone with the good screen, and I was back in business!

Next, I went about the process of installing Lineage 16 (pie) on the phone. According to the instructions, you have to update your phone to 50.1.A.13.123 to use this version of Lineage, but my phone was already 50.1.A.13.83, so I decided to try it as is, without updating the firmware. Praise God, it worked! So I was able to unlock the bootloader, boot TWRP, and flash LineageOS 16!

WARNING: This worked for me on software 50.1.A.13.83, but I don’t think it works if your software version is 50.2+! Try this at your own risk. I can’t promise that it won’t brick your phone.

Here’s what I did:

  • Went to Sony’s Unlock Bootloader section of their website and followed the specific instructions there to unlock the bootloader. You have to input your IMEI to generate a code that you use to unlock it in fastboot.
  • Downloaded TWRP for “discovery” (the nickname for XA2 Ultra).
  • Turned off my phone, held Volume up and plugged in the USB cable, which turned it on and put it in fastboot mode.
  • Typed fastboot boot ./twrp-3.2.3-0-discovery.img

fastboot boot ./twrp-3.2.3-0-discovery.img
downloading ‘boot.img’…
OKAY [ 1.431s]
booting…
OKAY [ 5.131s]
finished. total time: 6.562s

  • The phone rebooted into TWRP. I suggest making a backup at this point. I did, and copied it to my computer.
  • Download the latest LineageOS 16 (pie) rom for your XA2 Ultra. I used the 20190621 nightly, and it worked great for me.
  • Then, since I was ready to install LineageOS, select wipe, advanced, and wipe everything, then format data! Really important, if you don’t format data, you can’t boot lineageOS, as it will hang trying to unencrypt the data directory.
  • Still in TWRP, go to advanced, and select sideload.
  • On the computer, type:

adb sideload <name_of_lineage_zip.zip>

  • It will show a type of progress bar, and then will tell you when it is done. Don’t be alarmed if it “hangs” for a few minutes at the end, that was normal for me.
  • Reboot to system and enjoy LineageOS!

So, after a test run, I went back into TWRP, from fastboot, and flashed Magisk v19.3, and that worked great as well. I didn’t try Gapps, since I am actually going Gapp-less again. But that’s another post for another time….

Hopefully this was helpful for you. It was a lengthy process for me, and not optimal to say the least. If you do go this route, I will note that the Xperia XA2 ultra has been phenomenal for me. The battery life on Pie is incredible, the camera (that everyone loves or hates) is the best I’ve ever used, and I love it so far!

Linux – keep it simple.