TeamWin / Team-Win-Recovery-Project

Core recovery files for the Team Win Recovery Project (T.W.R.P) - this is not up to date, please see https://github.com/TeamWin/android_bootable_recovery/
http://twrp.me
1.97k stars 740 forks source link

No time offset. Apparently it's 1970 #1581

Closed Tekaoh closed 4 years ago

Tekaoh commented 4 years ago

Device codename: marlin TWRP version: 3.4.0-0

WHAT STEPS WILL REPRODUCE THE PROBLEM?

Boot into TWRP

WHAT IS THE EXPECTED RESULT?

The time and date should be correct

WHAT HAPPENS INSTEAD?

The time and date are incorrect

ADDITIONAL INFORMATION

A snippet from recovery.log:

I:TWFunc::Fixup_Time: Pre-fix date and time: 1970-02-04--14-23-16
I:TWFunc::Fixup_Time: Setting time offset from file /sys/class/rtc/rtc0/since_epoch
I:TWFunc::Fixup_Time: will attempt to use the ats files now.
I:TWFunc::Fixup_Time: no ats files found, leaving untouched!
I:TWFunc::Fixup_Time: Setting time offset from twrp setting file, offset 0
I:TWFunc::Fixup_Time: Date and time corrected: 1970-02-04--14-23-15

I tried investigating /sys/class/rtc/rtc0/since_epoch but rtc0 is a file, not a directory. I tried copying it out to sdcard to read it, but the copy operation failed. I don't want to monkey too much in directories I don't fully understand, so I left it there for now

CaptainThrowback commented 4 years ago

Where is the full recovery log?

Tekaoh commented 4 years ago

Where is the full recovery log?

I thought if I isolated the part that was relevant to what I was asking about, I could save you from sifting through the whole log. But you're right, I guess I should just provide the whole thing.

https://paste.omnirom.org/view/c396665f

CaptainThrowback commented 4 years ago

Where is the full recovery log?

I thought if I isolated the part that was relevant to what I was asking about, I could save you from sifting through the whole log. But you're right, I guess I should just provide the whole thing.

https://paste.omnirom.org/view/c396665f

The lines you provided only tell part of the story, which is why posting the full log is important.

First, TWRP looks at the /persist partition for ats files to adjust the time offset. Looking at your log, the persist partition is empty, which is why that initial check fails.

/persist | /dev/block/sdd3 | Size: 27MB **Used: 0MB** Free: 26MB Backup Size: 0MB

Then, once /data is decrypted, it updates the time offset again (if needed) from the ats files in /data. In your case, it appears those files haven't been properly initialized, or are storing old data for some reason, as indicated later in the log:

I:TWFunc::Fixup_Time: Pre-fix date and time: 1970-02-04--14-23-57
I:TWFunc::Fixup_Time: Setting time offset from file /sys/class/rtc/rtc0/since_epoch
I:TWFunc::Fixup_Time: will attempt to use the ats files now.
I:TWFunc::Fixup_Time: Setting time offset from file /data/time/ats_2, offset 0
I:TWFunc::Fixup_Time: Date and time corrected: 1970-02-04--14-23-58

So my first question would be, have you booted up a ROM and set the time in it so TWRP has somewhere from which to get a proper offset? And if you have, you may want to delete you ats files in /data/time since they have old data. This seems more like an Android issue rather than a TWRP one.

Tekaoh commented 4 years ago

Ah ok, perhaps I'm beginning to understand a little better...

The settings in my ROM have always been set to use network-provided time. Just for fun, I turned that off and booted into TWRP and now the time offset is working correctly. Perhaps Android doesn't make an ats file if it's just using network time? In any case, that would be an Android issue and not a TWRP issue, like you say.