Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,813,079 Members 54,177 Now Online
XDA Developers Android and Mobile Development Forum

[APP/FIX] Date/Time 1970 bug workaround v2.2

Tip us?
 
dougiebee
Old
(Last edited by dougiebee; 22nd January 2014 at 10:31 PM.) Reason: Version 2.2
#1  
Member - OP
Thanks Meter 107
Posts: 70
Join Date: Sep 2007
Default [APP/FIX] Date/Time 1970 bug workaround v2.2

Hope this helps someone. I got fairly sick of the date/time bug giving me error alerts upon reboot. This fix takes the RTC date/time and applies an offset specific to your own phone to set the correct date/time at startup. I have attached an APK to make life easy. It should also give the ability to have recovery use the files it creates to set the clock correctly on startup.

The app requires root. If running AOSP, your ROM must have initscript support.

The app has 3 functions:
  • Install offset only (for use with a compatible recovery, not used by the ROM)
  • Install offset and initscript (to correct ROM clock offset, also for use with a compatible recovery)
  • Uninstall (Remove /data/local/userinit.sh /data/media/rtc_offset and /sdcard/rtc_offset)

Feel free to include the app in your own ROMs, just give me credit

As of version 2.0, the script will create /data/media/rtc_offset which can be used by recovery to correct the date/time on boot. Note this will require the recovery to specifically support this correction.

Version 2.1 uses /system/bin/toolbox for compatibility across roms (rather than relying on whatever /system/bin/date points to)

Version 2.2 places the rtc_offset file both in /sdcard/rtc_offset and also in /data/media/rtc_offset if available. The initscript will use either file that is available. This is for possible compatibility with older phones that may not have /data/media, at the request of Phil3759

Special thanks to Atze001, sniperle and Phil3759.

Hope this helps, enjoy.
Attached Files
File Type: apk Clock_Offset_Fix_1.0.apk - [Click for QR Code] (265.9 KB, 133 views)
File Type: apk Clock_Offset_Fix_1.1.apk - [Click for QR Code] (265.9 KB, 54 views)
File Type: apk Clock_Offset_Fix_2.0.apk - [Click for QR Code] (266.0 KB, 80 views)
File Type: apk Clock_Offset_Fix_2.1.apk - [Click for QR Code] (266.0 KB, 211 views)
File Type: apk Clock_Offset_Fix_2.2.apk - [Click for QR Code] (266.1 KB, 807 views)
The Following 49 Users Say Thank You to dougiebee For This Useful Post: [ Click to Expand ]
 
murdoch1
Old
#2  
murdoch1's Avatar
Senior Member
Thanks Meter 104
Posts: 551
Join Date: Jan 2010
Quote:
Originally Posted by dougiebee View Post
Hope this helps someone. I got fairly sick of the date/time bug giving me error alerts upon reboot. My solution was to get the modification date of the /data/system directory and set that as the current date at boot time. Not great, but better than 1970. This or something similar may be posted elsewhere but I haven't seen it.

I'm running CM11 - not sure whether this works on other AOSP ROMS.

1) Create a file named 01datehack with the following content:

Code:
#!/system/bin/sh
olddate=`ls -ld /data/system | awk '{print $4, $5}' | sed -e 's/-//g' -e 's/ /./g' -e 's/://g' -e 's/$/00/g'`
date -s $olddate
Then run the following commands:
Code:
adb root
adb shell "mkdir -p /data/local/userinit.d"
adb push 01datehack /data/local/userinit.d
adb shell "chmod 755 /data/local/userinit.d/01datehack"
As it lives in /data it will survive flashing an update as long as you don't wipe. It's only a couple of fairly noddy linux commands, there's quite possibly a command line switch that would negate the need for all the SED'ing - also possibly a better directory/file to look at.

Hope this helps, enjoy.
I'm on the latest cm11 nightly. Tried your code but didn't make any difference. Phone still started up in February and then changed to today's date after network/WiFi started.
 
dougiebee
Old
#3  
Member - OP
Thanks Meter 107
Posts: 70
Join Date: Sep 2007
Quote:
Originally Posted by murdoch1 View Post
I'm on the latest cm11 nightly. Tried your code but didn't make any difference. Phone still started up in February and then changed to today's date after network/WiFi started.
What do you get from "adb shell ls -ld /data/system"? Have you enabled ADB root access in developer options?
The Following User Says Thank You to dougiebee For This Useful Post: [ Click to Expand ]
 
murdoch1
Old
#4  
murdoch1's Avatar
Senior Member
Thanks Meter 104
Posts: 551
Join Date: Jan 2010
Info 2 1970

Quote:
Originally Posted by dougiebee View Post
What do you get from "adb shell ls -ld /data/system"? Have you enabled ADB root access in developer options?

Yes enabled ADB root access in Developer options. Running the command you provided results me with the following:-

drwxrwxr-x system system 2013-12-23 08:47 system

Cheers
 
dougiebee
Old
(Last edited by dougiebee; 24th December 2013 at 08:50 AM.)
#5  
Member - OP
Thanks Meter 107
Posts: 70
Join Date: Sep 2007
deleted
The Following User Says Thank You to dougiebee For This Useful Post: [ Click to Expand ]
 
Atze001
Old
(Last edited by Atze001; 23rd December 2013 at 07:35 PM.) Reason: New Link
#6  
Atze001's Avatar
Senior Member
Thanks Meter 78
Posts: 885
Join Date: Apr 2007
Location: Berlin
Try this. I have made a flashable zip for TWRP

http://forum.xda-developers.com/show...2&postcount=13

Its a userinit.sh script in data/local
The Following 13 Users Say Thank You to Atze001 For This Useful Post: [ Click to Expand ]
 
murdoch1
Old
#7  
murdoch1's Avatar
Senior Member
Thanks Meter 104
Posts: 551
Join Date: Jan 2010
Quote:
Originally Posted by Atze001 View Post
Try this. I have made a flashable zip for TWRP

[URL="https://dl.dropboxusercontent.com/u/20033515/TimeDateFix.zip"]https://dl.dropboxusercontent.com/u/20033515/TimeDateFix.zip[/U

Its a userinit.sh script in data/local
Will this work for me as I'm running philz cwm?
 
Atze001
Old
(Last edited by Atze001; 23rd December 2013 at 09:32 AM.)
#8  
Atze001's Avatar
Senior Member
Thanks Meter 78
Posts: 885
Join Date: Apr 2007
Location: Berlin
You can try it. If it dont work you get an Installation error and nothing more happens.

If you get an Error please tell me i will fix it for CWM.
The Following User Says Thank You to Atze001 For This Useful Post: [ Click to Expand ]
 
murdoch1
Old
#9  
murdoch1's Avatar
Senior Member
Thanks Meter 104
Posts: 551
Join Date: Jan 2010
Quote:
Originally Posted by Atze001 View Post
You can try it. If it dont work you get an Installation error and nothing more happens.

If you get an Error please tell me i will fix it for CWM.
Just installed. Worked perfectly phone booted up with the correct date immediately.

Many thanks. Have a good Xmas.
 
Atze001
Old
#10  
Atze001's Avatar
Senior Member
Thanks Meter 78
Posts: 885
Join Date: Apr 2007
Location: Berlin
Thanks go to dougiebee for this work.

The Following User Says Thank You to Atze001 For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes