Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

object X {
 private val startTime = Clock.System.now()
 private val androidBootTime = startTime - SystemClock.elapsedRealtime().toDuration(DurationUnit.MILLISECONDS)

CoclusionsConclusions October 29 22024

To claim that this is shitty and dumb and idiotic is an understatement. It’s Google trying to make Android safe without a plan

The way to set Android time December 1 2024

Android receives time from a host computer connected via adb

  1. Time accuracy can be checked via Internet-ntp or a gps-fix
  2. Plug in the device to adb, Settings — System — Date & time — Set time automatically: Off—On
  3. If a failed ntp attempt was not made within preceding 18 hours and other conditions above, time will update to that of the host. It appears Android adb time has less restrictions compared to ntp time. Maybe time is always updated?
  4. logcat will show:
2024年12月01日 06:55:37.715566 1000 1900 1945 D
AlarmManagerService: Setting time of day to sec=1733064917
2024年12月01日 06:55:17.423629 1000 1900 1900 D
ConditionProviders.SCP: onReceive android.intent.action.TIME_SET
2024年12月01日 06:55:17.423826 1000 1900 1900 D
ConditionProviders.SCP: evaluateSubscriptionLocked
cal=ScheduleCalendar[mDays={1, 2, 3, 4, 5, 6, 7},
mSchedule=ScheduleInfo{days=[1, 2, 3, 4, 5, 6, 7],
startHour=22, startMinute=0, endHour=7, endMinute=0,
exitAtAlarm=true,
nextAlarm=Wed Dec 31 16:00:00 PST 1969 (0)}],
now=Sun Dec 01 06:55:17 PST 2024 (1733064917423),
nextUserAlarmTime=Wed Dec 31 16:00:00 PST 1969 (0)
2024年12月01日 06:55:17.433269 1000 1900 1957 I
UsageStatsService: User[0] Time changed in by -20 seconds
2024年12月01日 06:55:17.548695 1000 1900 1957 I
UsageStatsDatabase: Time changed by -20s313ms. files deleted: 0 files moved: 19
2024年12月01日 06:55:18.072561 10197 26701 26701 D
WM-RescheduleReceiver: Received intent Intent {
act=android.intent.action.TIME_SET flg=0x25200010
cmp=com.google.android.apps.messaging/
androidx.work.impl.background.systemalarm.RescheduleReceiver }
2024年12月01日 06:55:18.090800 1000 1900 1957 I
UsageStatsService: Time changed in by -20 seconds
2024年12月01日 06:55:19.499607 10144 3084 3206 W
UsageSyncManager: <DWB> Last (TimeDelta{
wallTime=2024年11月30日T19:32:34.447Z,
elapsedSinceBoot=PT52.836S},
boot count 30) and current (TimeDelta{
wallTime=2024年12月01日T14:55:19.482Z,
elapsedSinceBoot=PT19H23M58.184S},
boot count 30) deltas are different.
Increase event shift by PT-20.313S.

To check device time, on macOS host do:

date "+%F %T%z" && adb shell date -In 
2024年12月01日 07:38:26-0800
2024年12月01日T07:38:26,172221743-08:00

or, since macOS BSD cannot do nanoseconds:

python3 -c 'import datetime; print(datetime.datetime.now().astimezone())';
adb shell date -In
2024年12月01日 08:05:00.108809-08:00
2024年12月01日T08:05:00,252027835-08:00
object X {
 private val startTime = Clock.System.now()
 private val androidBootTime = startTime - SystemClock.elapsedRealtime().toDuration(DurationUnit.MILLISECONDS)

Coclusions October 29 22024

To claim that this is shitty and dumb and idiotic is an understatement. It’s Google trying to make Android safe without a plan

object X {
 private val startTime = Clock.System.now()
 private val androidBootTime = startTime - SystemClock.elapsedRealtime().toDuration(DurationUnit.MILLISECONDS)

Conclusions October 29 22024

To claim that this is shitty and dumb and idiotic is an understatement. It’s Google trying to make Android safe without a plan

The way to set Android time December 1 2024

Android receives time from a host computer connected via adb

  1. Time accuracy can be checked via Internet-ntp or a gps-fix
  2. Plug in the device to adb, Settings — System — Date & time — Set time automatically: Off—On
  3. If a failed ntp attempt was not made within preceding 18 hours and other conditions above, time will update to that of the host. It appears Android adb time has less restrictions compared to ntp time. Maybe time is always updated?
  4. logcat will show:
2024年12月01日 06:55:37.715566 1000 1900 1945 D
AlarmManagerService: Setting time of day to sec=1733064917
2024年12月01日 06:55:17.423629 1000 1900 1900 D
ConditionProviders.SCP: onReceive android.intent.action.TIME_SET
2024年12月01日 06:55:17.423826 1000 1900 1900 D
ConditionProviders.SCP: evaluateSubscriptionLocked
cal=ScheduleCalendar[mDays={1, 2, 3, 4, 5, 6, 7},
mSchedule=ScheduleInfo{days=[1, 2, 3, 4, 5, 6, 7],
startHour=22, startMinute=0, endHour=7, endMinute=0,
exitAtAlarm=true,
nextAlarm=Wed Dec 31 16:00:00 PST 1969 (0)}],
now=Sun Dec 01 06:55:17 PST 2024 (1733064917423),
nextUserAlarmTime=Wed Dec 31 16:00:00 PST 1969 (0)
2024年12月01日 06:55:17.433269 1000 1900 1957 I
UsageStatsService: User[0] Time changed in by -20 seconds
2024年12月01日 06:55:17.548695 1000 1900 1957 I
UsageStatsDatabase: Time changed by -20s313ms. files deleted: 0 files moved: 19
2024年12月01日 06:55:18.072561 10197 26701 26701 D
WM-RescheduleReceiver: Received intent Intent {
act=android.intent.action.TIME_SET flg=0x25200010
cmp=com.google.android.apps.messaging/
androidx.work.impl.background.systemalarm.RescheduleReceiver }
2024年12月01日 06:55:18.090800 1000 1900 1957 I
UsageStatsService: Time changed in by -20 seconds
2024年12月01日 06:55:19.499607 10144 3084 3206 W
UsageSyncManager: <DWB> Last (TimeDelta{
wallTime=2024年11月30日T19:32:34.447Z,
elapsedSinceBoot=PT52.836S},
boot count 30) and current (TimeDelta{
wallTime=2024年12月01日T14:55:19.482Z,
elapsedSinceBoot=PT19H23M58.184S},
boot count 30) deltas are different.
Increase event shift by PT-20.313S.

To check device time, on macOS host do:

date "+%F %T%z" && adb shell date -In 
2024年12月01日 07:38:26-0800
2024年12月01日T07:38:26,172221743-08:00

or, since macOS BSD cannot do nanoseconds:

python3 -c 'import datetime; print(datetime.datetime.now().astimezone())';
adb shell date -In
2024年12月01日 08:05:00.108809-08:00
2024年12月01日T08:05:00,252027835-08:00
added 307 characters in body
Source Link
Keith
  • 119
  • 1
  • 8
  • Impact is a user-perceivable time error of ±5 seconds that is completely unnecessary. This is why Android does not show seconds: It’s a Pentagon-papers cover-up
  • Impact is that any timestamp reported by Android is ±10 seconds
  • If time error is allowed greater than 100 ms, users will notice, Google?
  • Impact is a user-perceivable time error of ±5 seconds that is completely unnecessary. This is why Android does not show seconds: It’s a Pentagon-papers cover-up
  • Impact is that any timestamp reported by Android is ±10 seconds
  • If time error is allowed greater than 100 ms, users will notice, Google?
added 261 characters in body
Source Link
Keith
  • 119
  • 1
  • 8
  • is only attempted every 18 hours
  • only corrects if time deviation more than 5 seconds
  • if NTP cannot be read within 3 minutes, Android waits another 18 hours
  • time update can be attempted within Android limitations by Settings — System — Date & time — Set time automatically to Off to On
    • if a recent NTP request somehow failed, it’s wait 18 hours or set time manually per the dumb Googlers’ design
  • it is not possible to force a time update other than Settings — System — Date & time
    • need to be signed by Google or system app
  • Note that if time is off 2 minutes or more, certificates will not work as in VPN may fail. Android connectivity check may then fail, so Android cannot connect to the Internet at all
    • Android with bad backup battery may start with time set to 1969
    • Then, the build-time of the operating system is used which may be 2022 or so
    • It is not until a timestamp can be obtained from a mobile system or the Internet that time is corrected
  • is only attempted every 18 hours
  • only corrects if time deviation more than 5 seconds
  • if NTP cannot be read within 3 minutes, Android waits another 18 hours
  • can be attempted within Android limitations by Settings — System — Date & time — Set time automatically to Off to On
    • if a recent NTP request somehow failed, it’s wait 18 hours or set time manually per the dumb Googlers’ design
  • it is not possible to force a time update other than Settings — System — Date & time
    • need to be signed by Google or system app
  • Note that if time is off 2 minutes or more, certificates will not work as in VPN may fail. Android connectivity check may then fail, so Android cannot connect to the Internet at all
  • is only attempted every 18 hours
  • only corrects if time deviation more than 5 seconds
  • if NTP cannot be read within 3 minutes, Android waits another 18 hours
  • time update can be attempted within Android limitations by Settings — System — Date & time — Set time automatically to Off to On
    • if a recent NTP request somehow failed, it’s wait 18 hours or set time manually per the dumb Googlers’ design
  • it is not possible to force a time update other than Settings — System — Date & time
    • need to be signed by Google or system app
  • Note that if time is off 2 minutes or more, certificates will not work as in VPN may fail. Android connectivity check may then fail, so Android cannot connect to the Internet at all
    • Android with bad backup battery may start with time set to 1969
    • Then, the build-time of the operating system is used which may be 2022 or so
    • It is not until a timestamp can be obtained from a mobile system or the Internet that time is corrected
added 292 characters in body
Source Link
Keith
  • 119
  • 1
  • 8
Loading
added 120 characters in body
Source Link
Keith
  • 119
  • 1
  • 8
Loading
deleted 1 character in body
Source Link
Keith
  • 119
  • 1
  • 8
Loading
added 335 characters in body
Source Link
Keith
  • 119
  • 1
  • 8
Loading
added 588 characters in body
Source Link
Keith
  • 119
  • 1
  • 8
Loading
added 354 characters in body
Source Link
Keith
  • 119
  • 1
  • 8
Loading
added 335 characters in body
Source Link
Keith
  • 119
  • 1
  • 8
Loading
added 968 characters in body
Source Link
Keith
  • 119
  • 1
  • 8
Loading
Source Link
Keith
  • 119
  • 1
  • 8
Loading
lang-kotlin

AltStyle によって変換されたページ (->オリジナル) /