Android emulator time synchronization

Is there a way to synchronize emulator time and system time to the nearest millisecond? So calling System.currentTimeMillis() will return the same time as calling gettimeofday() in C?

+4
source share
2 answers

I am not sure that I understand the question 100%.

If you look in dalvik/vm/native/java_lang_System.c , you will see:

 static void Dalvik_java_lang_System_currentTimeMillis(const u4* args, JValue* pResult) { struct timeval tv; UNUSED_PARAMETER(args); gettimeofday(&tv, (struct timezone *) NULL); long long when = tv.tv_sec * 1000LL + tv.tv_usec / 1000; RETURN_LONG(when); } 

So, System.currentTimeMillis () calls gettimeofday () - at least in the dalvik implementation I'm looking at.

How about using an application like ClockSync to set the time on the emulator. It uses the ntp protocol, which you can also use on your PC.

0
source

Unfortunately, Android does not allow time to install the application without root. Thus, you can set the time only if you are a root emulator .

0
source

Source: https://habr.com/ru/post/1337861/


All Articles