The default date method for high-speed Android system changes
On Android devices, there is a default start date, see a lot of devices, some devices are not connected to the system when the time is not synchronized, the default is the 1970 date. I've seen some devices by default to January 1, 2000, so it's a relatively advanced step. But it's not enough.
The author of the following very simple introduction of a super simple method:
/*****************************************************************************************************/
Disclaimer: The content of this blog is by http://blog.csdn.net/edsam49 original, reproduced please indicate the source, thank you!
/*****************************************************************************************************/
It is very good to be familiar with Systemserver. There are good things in systemserver, first, or from main, we can be sure that the original code is written like this:
public static void Main (string[] args) {
1141
1142 /*
1143 * The runtime switched since last boot (such as when
1144 * The old runtime is removed in an OTA), set the system
P=android/platform/frameworks/base.git;a=blob;f=services/java/com/android/server/systemserver.java;h= e55e2766226a5031f40ac5c4cde5535712392898;hb=e55e2766226a5031f40ac5c4cde5535712392898#l1145 ">1145 * Property So, it's in sync. We can ' t do this in
1146 * libnativehelper ' s jniinvocation::init code where we already
1147 * had to fallback to a different runtime because it's
1148 * Running as root and we need to is the system user to set
P=android/platform/frameworks/base.git;a=blob;f=services/java/com/android/server/systemserver.java;h= e55e2766226a5031f40ac5c4cde5535712392898;hb=e55e2766226a5031f40ac5c4cde5535712392898#l1149 ">1149 * The property. http://b/11463182
1150 * *
P=android/platform/frameworks/base.git;a=blob;f=services/java/com/android/server/systemserver.java;h= e55e2766226a5031f40ac5c4cde5535712392898;hb=e55e2766226a5031f40ac5c4cde5535712392898#l1151 ">1151 Systemproperties.set ("Persist.sys.dalvik.vm.lib",
1152 vmruntime.getruntime (). Vmlibrary ());
1153
1154 if (System.currenttimemillis () < Earliest_supported_time) {
1155 //If a device ' s clock is before 1970 (before 0), a lot of
1156 //APIs crash dealing with negative numbers, notably
1157 //java.io.file#setlastmodified, so instead we fake it and
1158 //hope that time from cell towers or NTP fixes it
1159 //shortly.
P=android/platform/frameworks/base.git;a=blob;f=services/java/com/android/server/systemserver.java;h= e55e2766226a5031f40ac5c4cde5535712392898;hb=e55e2766226a5031f40ac5c4cde5535712392898#l1160 ">1160 Sl OG.W (TAG, "System clock is before 1970; Setting to 1970. ");
1161 Systemclock.setcurrenttimemillis (earliest_supported_time);
P=android/platform/frameworks/base.git;a=blob;f=services/java/com/android/server/systemserver.java;h= e55e2766226a5031f40ac5c4cde5535712392898;hb=e55e2766226a5031f40ac5c4cde5535712392898#l1162 ">1162 }
Obviously there is an inference of course time. It is easy to make the most of this point by comparing it to a preset point in time, assuming that it is later than the preset time. In this way, just move the preset time point. In fact, just to change the line is not code code can be, the author changes such as the following:
- private static final Long Earliest_supported_time = 86400 * 1000;-+ //private static final long Earliest_support Ed_time = 86400 * 1000;+ //default 2014-07-01-12:00+ private static final long Earliest_supported_time = 14041872 00000l;+ /** * Called to initialize native system services. */@@ -1157,7 +1159,8 @@ public class Systemserver { //java.io.file#setlastmodified, so instead we fake it and // Hope that time from cell towers or NTP fixes it //shortly.- SLOG.W (TAG, "System clock is before 1970; Setting to 1970. "); + //SLOG.W (TAG, "System clock is before 1970; Setting to 1970. "); + SLOG.W (TAG, "System clock is before 20140701; setting to 20140701. "); Systemclock.setcurrenttimemillis (Earliest_supported_time); }
See is not feel very think, change this is simple, know here can change is not simple, refueling!
The default date method for high-speed Android system changes