summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2012-08-31 14:47:34 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-31 14:47:35 -0700
commit176d105d2f71198966b566d36d4e856a797695c7 (patch)
treef08abe97af820cd47f8e457ae5464cf1e1f3f73c
parent58a2950b66f049c0d9e9f1a9fce16884f0b50e19 (diff)
parent897798225d9c48bd3424757059318ed1eb3207de (diff)
downloadframeworks_base-176d105d2f71198966b566d36d4e856a797695c7.zip
frameworks_base-176d105d2f71198966b566d36d4e856a797695c7.tar.gz
frameworks_base-176d105d2f71198966b566d36d4e856a797695c7.tar.bz2
Merge "Don't set the time zone under the caller's identity" into jb-mr1-dev
-rw-r--r--services/java/com/android/server/AlarmManagerService.java55
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);
}
}