Merge "Don't set the time zone under the caller's identity" into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
176d105d2f
@ -243,32 +243,39 @@ class AlarmManagerService extends IAlarmManager.Stub {
|
|||||||
"android.permission.SET_TIME_ZONE",
|
"android.permission.SET_TIME_ZONE",
|
||||||
"setTimeZone");
|
"setTimeZone");
|
||||||
|
|
||||||
if (TextUtils.isEmpty(tz)) return;
|
long oldId = Binder.clearCallingIdentity();
|
||||||
TimeZone zone = TimeZone.getTimeZone(tz);
|
try {
|
||||||
// Prevent reentrant calls from stepping on each other when writing
|
if (TextUtils.isEmpty(tz)) return;
|
||||||
// the time zone property
|
TimeZone zone = TimeZone.getTimeZone(tz);
|
||||||
boolean timeZoneWasChanged = false;
|
// Prevent reentrant calls from stepping on each other when writing
|
||||||
synchronized (this) {
|
// the time zone property
|
||||||
String current = SystemProperties.get(TIMEZONE_PROPERTY);
|
boolean timeZoneWasChanged = false;
|
||||||
if (current == null || !current.equals(zone.getID())) {
|
synchronized (this) {
|
||||||
if (localLOGV) Slog.v(TAG, "timezone changed: " + current + ", new=" + zone.getID());
|
String current = SystemProperties.get(TIMEZONE_PROPERTY);
|
||||||
timeZoneWasChanged = true;
|
if (current == null || !current.equals(zone.getID())) {
|
||||||
SystemProperties.set(TIMEZONE_PROPERTY, zone.getID());
|
if (localLOGV) {
|
||||||
}
|
Slog.v(TAG, "timezone changed: " + current + ", new=" + zone.getID());
|
||||||
|
}
|
||||||
// Update the kernel timezone information
|
timeZoneWasChanged = true;
|
||||||
// Kernel tracks time offsets as 'minutes west of GMT'
|
SystemProperties.set(TIMEZONE_PROPERTY, zone.getID());
|
||||||
int gmtOffset = zone.getOffset(System.currentTimeMillis());
|
}
|
||||||
setKernelTimezone(mDescriptor, -(gmtOffset / 60000));
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeZone.setDefault(null);
|
// Update the kernel timezone information
|
||||||
|
// Kernel tracks time offsets as 'minutes west of GMT'
|
||||||
if (timeZoneWasChanged) {
|
int gmtOffset = zone.getOffset(System.currentTimeMillis());
|
||||||
Intent intent = new Intent(Intent.ACTION_TIMEZONE_CHANGED);
|
setKernelTimezone(mDescriptor, -(gmtOffset / 60000));
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
}
|
||||||
intent.putExtra("time-zone", zone.getID());
|
|
||||||
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
|
TimeZone.setDefault(null);
|
||||||
|
|
||||||
|
if (timeZoneWasChanged) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_TIMEZONE_CHANGED);
|
||||||
|
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
||||||
|
intent.putExtra("time-zone", zone.getID());
|
||||||
|
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(oldId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user