PSA : Battery change on S20 (and likely others) needs additional work with /e/OS

I recently bought a second hand S20, as I could put /e/OS on it.

I checked with a local Samsung Service Center they could fit a new battery, and they could.

Well, today I went down to have this done and now we’re doing it the unexpected stuff starts to come out.

The phone keeps track of how many charge cycles the battery has experienced, and it seems that needs to be reset to 0 when you change battery, and that this in the Service Center is done via having some Samsung APK installed on the device.

I downloaded what looked like the APK the Service Center needed, but it would not install - threw an error, incompatible existing APK or something like that.

It seems this is stored in some sort of special store in the phone, which is outside of the usual file system and so is unchanged when you for example install /e/OS.

I’m not quite clear what the downside of not resetting the counter is - I’ll Google a bit more on that.

Also tried another APK which claimed to reset the battery count, same problem.

I’m having the battery now changed anyway, and then I’ll see about sorting it out myself at home. I’m pretty sure I can sort it out, even if it means root, or, worst, reflashing the original Android, installing the Samsung APK, and then reinstalling /e/OS.

Okay, so.

I had the battery changed.

There seems to be even more than one Samsung APK (e.g. “Self Repair Assistant” or something like that, “Galaxy Diagnostics”) which can reset the battery charge cycle count, but none of them would install on /e/OS.

Digging around I found some what seems obsolete information giving paths in /system/ which would show the cycle count - those paths for me on Android 16 did not exist.

However, there seems to be a path “/efs/factoryapp/batt_discharge_level” which has a counter of some kind indicating how many times battery has cycled.

I’ve not yet verified the value here is increasing over time in my phone. The initial value was 1249900, but apparently the value is multiplied by 100, so it’s really 12499. This seems too high - battery I guess is about five years old, so that’s 1750 days.

If the value was 1000x, then it would seem about right, but how do we account for the fact the last three digits are not 0? and anyway I’m making stuff up.

In any event, I set up adb debugging as root (activate the option in Developer Options on the phone, then “adb start-server”, then “adb root”, which restarts adb as root, I then ran “adb shell” to get in).

I’m not sure if you actually need root to write to /efs/factoryapp/batt_discharge_level, but I didn’t try it without.

I then wrote 0 into that value (“echo 0 > /efs/factoryapp/batt_discharge_level”) although now I’m wondering if I should have used -n! (emit no newline)

So problem here is all of this is not clear.

I don’t know if this is really the cycle count.

I don’t understand the value which is in there to start with.

I’m not sure I’ve written the correct new value.

My sense of it is if you’re going to change battery, best to do it before you install /e/OS, so you can use the Samsung APKs.

(Finally note “*#9900#” does not seem to work on /e/OS - maybe is Samsung Android only.)

This page has relevant info;

https://xdaforums.com/t/reset-battery-cycle-counter-on-samsung-galaxy-s7.3782807/