如果android设备没有连接到互联网或没有sim,第一次开机时显示的时间和日期是什么?默认设置时间和日期的依据是什么?
发布于 2021-10-08 04:00:27
在第一次启动时,android会使用Build.TIME设置系统时间,而Build.TIME是从系统属性ro.build.data.rtc中获取的,也就是构建镜像的时间。一些工厂测试将在工厂中执行,因此它可能已经启动了一段时间。这可能不是第一次开机,当用户打开手机的盒子,并启动它。
这是由AlarmManagerService.java#onStart完成的。
@Override
public void onStart() {
mInjector.init();
...
synchronized (mLock) {
mHandler = new AlarmHandler();
mConstants = new Constants();
...
// We have to set current TimeZone info to kernel
// because kernel doesn't keep this after reboot
setTimeZoneImpl(SystemProperties.get(TIMEZONE_PROPERTY));
// Ensure that we're booting with a halfway sensible current time. Use the
// most recent of Build.TIME, the root file system's timestamp, and the
// value of the ro.build.date.utc system property (which is in seconds).
final long systemBuildTime = Long.max(
1000L * SystemProperties.getLong("ro.build.date.utc", -1L),
Long.max(Environment.getRootDirectory().lastModified(), Build.TIME));
if (mInjector.getCurrentTimeMillis() < systemBuildTime) {
Slog.i(TAG, "Current time only " + mInjector.getCurrentTimeMillis()
+ ", advancing to build time " + systemBuildTime);
mInjector.setKernelTime(systemBuildTime);
}https://stackoverflow.com/questions/69451340
复制相似问题