diff options
author | Christopher Tate <ctate@google.com> | 2012-08-31 14:40:03 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2012-08-31 14:44:25 -0700 |
commit | 897798225d9c48bd3424757059318ed1eb3207de (patch) | |
tree | b2dff460a81e2dcd051f8c3de9846fcaa818cd16 /services/java | |
parent | 8c890f8a69ea1e6f8f7fe989a610ffe738e91866 (diff) | |
download | frameworks_base-897798225d9c48bd3424757059318ed1eb3207de.zip frameworks_base-897798225d9c48bd3424757059318ed1eb3207de.tar.gz frameworks_base-897798225d9c48bd3424757059318ed1eb3207de.tar.bz2 |
Don't set the time zone under the caller's identity
...otherwise you crash trying to send a broadcast to all users.
Change-Id: If627eeb3eadb1052242c986fe24482d87c8fc093
Diffstat (limited to 'services/java')
-rw-r--r-- | services/java/com/android/server/AlarmManagerService.java | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java index ac8a514..f4ad756 100644 --- a/services/java/com/android/server/AlarmManagerService.java +++ b/services/java/com/android/server/AlarmManagerService.java @@ -243,32 +243,39 @@ class AlarmManagerService extends IAlarmManager.Stub { "android.permission.SET_TIME_ZONE", "setTimeZone"); - if (TextUtils.isEmpty(tz)) return; - TimeZone zone = TimeZone.getTimeZone(tz); - // Prevent reentrant calls from stepping on each other when writing - // the time zone property - boolean timeZoneWasChanged = false; - synchronized (this) { - String current = SystemProperties.get(TIMEZONE_PROPERTY); - if (current == null || !current.equals(zone.getID())) { - if (localLOGV) Slog.v(TAG, "timezone changed: " + current + ", new=" + zone.getID()); - timeZoneWasChanged = true; - SystemProperties.set(TIMEZONE_PROPERTY, zone.getID()); + long oldId = Binder.clearCallingIdentity(); + try { + if (TextUtils.isEmpty(tz)) return; + TimeZone zone = TimeZone.getTimeZone(tz); + // Prevent reentrant calls from stepping on each other when writing + // the time zone property + boolean timeZoneWasChanged = false; + synchronized (this) { + String current = SystemProperties.get(TIMEZONE_PROPERTY); + if (current == null || !current.equals(zone.getID())) { + if (localLOGV) { + Slog.v(TAG, "timezone changed: " + current + ", new=" + zone.getID()); + } + timeZoneWasChanged = true; + SystemProperties.set(TIMEZONE_PROPERTY, zone.getID()); + } + + // Update the kernel timezone information + // Kernel tracks time offsets as 'minutes west of GMT' + int gmtOffset = zone.getOffset(System.currentTimeMillis()); + setKernelTimezone(mDescriptor, -(gmtOffset / 60000)); } - - // Update the kernel timezone information - // Kernel tracks time offsets as 'minutes west of GMT' - int gmtOffset = zone.getOffset(System.currentTimeMillis()); - setKernelTimezone(mDescriptor, -(gmtOffset / 60000)); - } - 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); + 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); } } |