[Xperia Z5 Android Development] someone755:
I don't want to quote the entire post, but I've found out something that is very relevant to it;

When using rootkernel on an Xperia X Compact (stock Oreo 8.0), and using munjeni's TA.img hack, there are big problems for users if/when the battery runs out completely (to 0%), and the phone shuts down. This has happened twice to me so far, but I've only just bothered with fixing the issue today.

The problem is that after draining the battery completely and the phone shutting down, the cellular radio no longer works. It finds available networks, but refuses to connect to any of them. At one point it kept saying the SIM card was locked and kept asking for the SIM PIN, every few seconds.

Looking at the logcat, the system implies an error with the 'tad' process being unable to find a `TA.img`:

07-07 15:24:44.157 2476 2476 E tad : Failed to open /data/local/tmp/TA.img (No such file or directory)

The file at `/data/local/tmp/init.ta_poc-log.txt` also says this:

cat init.ta_poc-log.txt
Executing init.ta_poc.sh:
- /data/local/tmp/TA.img not found!
- Copying /sbin/TA.img to /data/local/tmp/TA.img
cp: bad '/sbin/TA.img': Permission denied
- Wiping drm folders (credmgr, drm and mediadrm)
All done!

Executing init.ua_modem_switcher.sh:
- Removing old modem_switcher_status file
- Running /sbin/ua-modem-switcher binary
- ua-modem-switcher finished with status 255
All done!

So I used adb and pushed my own TA.img to the specified location. Now everything related to cellular networks seem to work, and the `init.ta_poc-log.txt` file also agrees:

cat init.ta_poc-log.txt
Executing init.ta_poc.sh:
- Found /data/local/tmp/TA.img
- Chown-ing /data/local/tmp/TA.img
- Chmod-ing /data/local/tmp/TA.img
All done!

Executing init.ua_modem_switcher.sh:
- Removing old modem_switcher_status file
- Running /sbin/ua-modem-switcher binary
- ua-modem-switcher finished with status 0
All done!

After this, in the logcat, a process called `tadif` complains that it cannot connect to `tad`, literally in the first line of my logcat. This error goes away some hundred lines later, when `tad` announces that it is "Accepting connections." So the problem seems to be fixed.

I have no idea why or how the TA.img gets deleted, or why `init.ta_poc.sh` doesn't have permission to copy it (because it does exist inside /sbin/), or why the TA.img is necessary for the modem to work properly.

Any answers or suggestions are of course appreciated, I just felt the need to share this bug I've found, and how I fixed it; It might help somebody in the future, thinking of flashing the system anew.

______________

EDIT (July 9th, 2019): The 'phone' Android process stops every few hours if I'm abusing my phone and using mobile data constantly. This disables mobile data and calls. Pressing "Ok" in the Android force close prompt reboots the process and mobile network functionality goes back to normal within a few seconds.

This could be a major problem, especially if it happens during a call or some such. I haven't debugged it yet, but I'm jotting it down here just in case I ever come back to this. I don't know what exactly, or why it happens, but after using exclusively mobile data for a few hours of continuous screen on time, it happens seemingly sporadically. It happened to me at least twice yesterday.

I also haven't tried draining the battery to 0% again to see if the TA.img disappears again (as one wouldn't normally try and discharge their phone completely). I also hope to update you on this if I'm ever unfortunate enough to run out of battery again (which, by my recent track record, should happen again by the end of the month, haha).

______________

EDIT (July 14th, 2019): My phone just froze after System UI became unresponsive and I was forced to reboot the device. Upon boot, the TA.img was again missing and my mobile data again broken. It's only by luck that I have my TA.img saved on Google Drive and have a laptop with me on vacation.

I've noticed that the TA.img in /sbin does exist, but it seems to be corrupt, as its size shows 0MB (my TA.img clocks in at about 2MB). It might be that fixing the TA.img inside /sbin could be a permanent fix, but as of right now, all I did was I whipped up a zip to flash my TA.img to /data/local/tmp/TA.img in recovery and saved the zip locally on my phone for any future use. Sadly I didn't manage to get any ADB logs of the SystemUI crash to figure out how and why exactly this crash affected the TA.img specifically, but I'm again just jotting ideas down for any future readers (and very likely my future self as well).

So, a total of 7 days without a mobile data crash -- I wonder if this is a coincidence? I'll of course edit this post in the future if I find any new data.