summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/AppWidgetService.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-06-15 17:40:44 -0700
committerDianne Hackborn <hackbod@google.com>2011-06-15 17:40:44 -0700
commit4912f160875441927d012fc17b04fe7cc6567ef8 (patch)
treec07ff47723b1ce99136f36018bf26fa36d879ad5 /services/java/com/android/server/AppWidgetService.java
parent576715c75987b64eff120f8800862815753b0c8a (diff)
downloadframeworks_base-4912f160875441927d012fc17b04fe7cc6567ef8.zip
frameworks_base-4912f160875441927d012fc17b04fe7cc6567ef8.tar.gz
frameworks_base-4912f160875441927d012fc17b04fe7cc6567ef8.tar.bz2
Fix to clear calling identity when binding a widget.
Change-Id: Id66abc50ec9ee69317b9838f302c4153995664f7
Diffstat (limited to 'services/java/com/android/server/AppWidgetService.java')
-rw-r--r--services/java/com/android/server/AppWidgetService.java74
1 files changed, 40 insertions, 34 deletions
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java
index fd502d8..158c778 100644
--- a/services/java/com/android/server/AppWidgetService.java
+++ b/services/java/com/android/server/AppWidgetService.java
@@ -395,41 +395,47 @@ class AppWidgetService extends IAppWidgetService.Stub
public void bindAppWidgetId(int appWidgetId, ComponentName provider) {
mContext.enforceCallingPermission(android.Manifest.permission.BIND_APPWIDGET,
"bindGagetId appWidgetId=" + appWidgetId + " provider=" + provider);
- synchronized (mAppWidgetIds) {
- AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
- if (id == null) {
- throw new IllegalArgumentException("bad appWidgetId");
- }
- if (id.provider != null) {
- throw new IllegalArgumentException("appWidgetId " + appWidgetId + " already bound to "
- + id.provider.info.provider);
- }
- Provider p = lookupProviderLocked(provider);
- if (p == null) {
- throw new IllegalArgumentException("not a appwidget provider: " + provider);
- }
- if (p.zombie) {
- throw new IllegalArgumentException("can't bind to a 3rd party provider in"
- + " safe mode: " + provider);
- }
-
- id.provider = p;
- p.instances.add(id);
- int instancesSize = p.instances.size();
- if (instancesSize == 1) {
- // tell the provider that it's ready
- sendEnableIntentLocked(p);
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mAppWidgetIds) {
+ AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
+ if (id == null) {
+ throw new IllegalArgumentException("bad appWidgetId");
+ }
+ if (id.provider != null) {
+ throw new IllegalArgumentException("appWidgetId " + appWidgetId + " already bound to "
+ + id.provider.info.provider);
+ }
+ Provider p = lookupProviderLocked(provider);
+ if (p == null) {
+ throw new IllegalArgumentException("not a appwidget provider: " + provider);
+ }
+ if (p.zombie) {
+ throw new IllegalArgumentException("can't bind to a 3rd party provider in"
+ + " safe mode: " + provider);
+ }
+
+ id.provider = p;
+ p.instances.add(id);
+ int instancesSize = p.instances.size();
+ if (instancesSize == 1) {
+ // tell the provider that it's ready
+ sendEnableIntentLocked(p);
+ }
+
+ // send an update now -- We need this update now, and just for this appWidgetId.
+ // It's less critical when the next one happens, so when we schdule the next one,
+ // we add updatePeriodMillis to its start time. That time will have some slop,
+ // but that's okay.
+ sendUpdateIntentLocked(p, new int[] { appWidgetId });
+
+ // schedule the future updates
+ registerForBroadcastsLocked(p, getAppWidgetIds(p));
+ saveStateLocked();
}
-
- // send an update now -- We need this update now, and just for this appWidgetId.
- // It's less critical when the next one happens, so when we schdule the next one,
- // we add updatePeriodMillis to its start time. That time will have some slop,
- // but that's okay.
- sendUpdateIntentLocked(p, new int[] { appWidgetId });
-
- // schedule the future updates
- registerForBroadcastsLocked(p, getAppWidgetIds(p));
- saveStateLocked();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
}