Upgrade LineageOS from 15.1 to 16.0

I am not particularly keen on upgrading my phone to 16.0, LineageOS' newest, Android-9-based version. They claim that 15.1 is still supported in general, but upon closer inspection this holds true only for a few devices, and not for mine. Sneaky.

This post documents the process of upgrading an Android device from LineageOS 15.1. to 16.0.
There's no actual upgrade process; I need to flash the 16.0 ROM. The device has no SDcard, only internal shared memory or whatever it's called. I have no idea if this will be preserved when flashing a new ROM.

Everything in this article happens between a Oneplus 3 and an ArchLinux desktop machine, connected via USB cable.

Backup

adb backup -apk -shared -all -f <filepath>/backup.ab

On the Android device's screen you will be prompted to acknowledge the action (If you want you can also encrypt your backup) and it displays some status information.
I found no way to verify the backup after it completed, or to look inside it.
This backup is huge (10GB) and could only be restored as a whole. Will I need this when the new install is finished? I don't think so.

What I'd need is a list of all my installed applications to backup individually, along with their current settings.
I used Adebar to make a more finegrained backup, but I'm not sure it fits that bill. It also seems buggy, but at least it's one more layer of backups.

I also made a backup from within TWRP recovery as described on LineageOS' upgrade page.

In the end I made backups/exports of all important applications that offer that feature, stored them on the /sdcard (it's not really an SDcard), and then I just pulled the whole /sdcard:

adb pull /sdcard

Upgrade TWRP

It is possible to upgrade TWRP with fastboot.

Installation

Mostly just following the upgrade instructions. Download the latest nightly from here. They're all nightlies, there's no stable release, but they have been stable enough for me.

On the device, fire up TWRP recovery, go to "Advanced" and "ADB Sideload", then swipe to begin sideload. On the host machine, sideload the package using: adb sideload filename.zip

...aaand we have an error. The flashing failed because this image requires an upgraded modem firmware 5.0.8 from OxygenOS. A quick search found this and this download. I sideloaded it in the same manner as described above, then sideloaded the OS image again. No errors this time.

Aftermath

First reboot - yes, it's LineageOS 16.0!
Everything is still there, all applications are still installed, all personal settings and data are intact (almost).

As ever so often, the two SIM cards are jumbled, I have to go into the settings and choose one for calls, one for internet.

Root is still missing (required for AFWall+ and AdAway). I download this package and sideload it in the already described manner.

Unfortunately AFWall+ is acting up. It recognizes my old rules & settings, but I cannot connect to the internet at all. I could not find any hint on the internet, and I could not fix it myself. In the end I completely uninstalled it, then reinstalled. Fortunately I had previously exported not only the rules, but also profile settings and preferences, so I can just import them now, right? No, I'm greated with a nag screen: This feature is only available when you donate and get some key to unlock it. I can still import the rules only, but the export I made is not compatible with that! I think I should have been told this when I made the export, and not now when it's too late. Certainly doesn't inspire me to donate.

So I start AFWall+ with a blank slate

...

Installation-2

I decided to completely wipe the device after all, not wanting to contaminate my new install with old, possibly wrong settings.

In TWRP I chose Wipe -> Advanced Wipe, checked ALL the boxes and swiped to wipe. Also choose Wipe -> Format Data.

Then also fastboot flashall and adb shell recovery --wipe_data from your computer.

I did not get the same firware error anymore as previously; apparently it is enough to flash it once.

Remove all SIM cards before rebooting.

Reboot-2

Disable Wifi and all networking stuff.

Install AFWall+ first of all with adb: adb install AFWall+_nnnnn.apk
Found this invaluable resource for AFWall+: https://www.kuketz-blog.de/afwall-digitaler-tuervorsteher-take-back-control-teil4/
https://dismail.de/info.html#dns

still no internet in afwall!
https://forum.xda-developers.com/showpost.php?p=78930502&postcount=5241

If you face issues in Pie whitelist mode, you need make sure you allow "Android system - UID 1000" to access internet. If you don't want to give access to uid 1000, then you need to disable captive portal using adb.

adb settings list global and adb getprop are very useful commands to get information about all sorts of stuff. Probably requires (or gives more info with) root.