[Sony Xperia XZ2 Compact ROMs, Kernels, Recoveries,] raphidae:
Hi, one little problem: I need adoptable storage (let's not debate why, but I do).

With LOS 18 I would do the following in adb shell:

sm set-force-adoptable true

And format the SD as adoptable storage and all's well.

However, this doesn't work for 19 and 20; the format will go to 20% and then the phone will reboot and then goes into reboot loop until I physically eject the SD card.

Apparently it tries to restart the format after reboot and keeps crashing.

A workaround I've been using since 19 is to install 18, format adoptable storage and then upgrade to 19, because 19 will work fine with the adoptable storage then.

I was hoping this would be fixed in 20 but it hasn't, maybe you can take a look?

This is in logcat just before reboot:

01-24 21:31:31.990 0 0 I F2FS-fs (dm-0): Found nat_bits in checkpoint
01-24 21:31:32.119 0 0 I F2FS-fs (dm-0): Mounted with checkpoint version = 60b9a912
01-24 21:31:32.125 0 0 W init : DM_DEV_STATUS failed for system: No such device or address
01-24 21:31:32.125 0 0 W init : DM_DEV_STATUS failed for vroot: No such device or address
01-24 21:31:32.134 0 0 I selinux : SELinux: Skipping restorecon on directory(/mnt/expand/d8deae77-554b-4175-ab14-8ce492d3782c)
01-24 21:31:32.134 0 0 I selinux :
01-24 21:31:32.174 4276 4393 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: StorageManagerService
01-24 21:31:32.174 4276 4393 E AndroidRuntime: java.lang.RuntimeException: android.os.ServiceSpecificException: (code 0)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at com.android.server.StorageManagerService.prepareUserStorageInternal(StorageManagerService.java:3423)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at com.android.server.StorageManagerService.prepareUserStorageIfNeeded(StorageManagerService.java:3384)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at com.android.server.StorageManagerService.onVolumeStateChangedAsync(StorageManagerService.java:1748)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at com.android.server.StorageManagerService.-$$Nest$monVolumeStateChangedAsync(Unknown Source:0)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at com.android.server.StorageManagerService$StorageManagerServiceHandler.handleMessage(StorageManagerService.java:870)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:67)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: Caused by: android.os.ServiceSpecificException: (code 0)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at android.os.Parcel.createExceptionOrNull(Parcel.java:3025)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at android.os.Parcel.createException(Parcel.java:2995)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2978)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2920)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at android.os.IVold$Stub$Proxy.prepareUserStorage(IVold.java:2230)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: at com.android.server.StorageManagerService.prepareUserStorageInternal(StorageManagerService.java:3398)
01-24 21:31:32.174 4276 4393 E AndroidRuntime: ... 8 more

This is apparently truncated. If it helps at all, how would I get the entire trace?

Also, this appears to be unrelated, but while looking through the log I noticed some other exceptions, see the attached file. Surely that's not supposed to happen?

Now, I have zero experience with Android, but I took a peek in gpiolib.c, and it seems to me the invalid GPIO may indicate some memory issue somewhere (uninitialised, corrupted, etc.) that causes the "-517" to be picked up. It's supposed to be unsigned.

Additionally, in general the log has hundreds of messages about commands and operations that are failing in some way (files that don't exist, mounts that fail, mkdirs/create file failing b/c of read-only filesystem etc.). Is that normal? It seems like a needless waste of resources, which probably has a bigger impact on the xz2c as it's an older phone at this point.