[DO NOT MERGE] Update kernel timezone if call to setTime causes DST offset to change
If AlarmManager#setTime is called with a time that has a different DST
offset than the current system time, update the kernel timezone offset
with the correct value for the time being set.
Test: Manually set time to two times with different DST offsets, ensure
kernel time zone updates properly.
Bug: 80142036
Bug: 80098370
Change-Id: I8884bce471cf4b95372d6d33a36e8c9e92bd6a96
(cherry picked from commit f5d585aec9)
This commit is contained in:
@@ -1388,7 +1388,19 @@ class AlarmManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
return setKernelTime(mNativeData, millis) == 0;
|
final long currentTimeMillis = System.currentTimeMillis();
|
||||||
|
setKernelTime(mNativeData, millis);
|
||||||
|
final TimeZone timeZone = TimeZone.getDefault();
|
||||||
|
final int currentTzOffset = timeZone.getOffset(currentTimeMillis);
|
||||||
|
final int newTzOffset = timeZone.getOffset(millis);
|
||||||
|
if (currentTzOffset != newTzOffset) {
|
||||||
|
Slog.i(TAG, "Timezone offset has changed, updating kernel timezone");
|
||||||
|
setKernelTimezone(mNativeData, -(newTzOffset / 60000));
|
||||||
|
}
|
||||||
|
// The native implementation of setKernelTime can return -1 even when the kernel
|
||||||
|
// time was set correctly, so assume setting kernel time was successful and always
|
||||||
|
// return true.
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user