diff options
| author | Winson Chung <winsonc@google.com> | 2011-12-05 14:56:29 -0800 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2011-12-06 14:21:10 -0800 |
| commit | c3f581b0474a216938810885f4f606e0db1f21ff (patch) | |
| tree | 065a4f8a4c8598c43dd92da25d7416ce114a233c /services/java/com/android/server/AppWidgetService.java | |
| parent | 3124e6f9e96b730cdfbbf068f15c41b6d5c8a819 (diff) | |
| download | frameworks_base-c3f581b0474a216938810885f4f606e0db1f21ff.zip frameworks_base-c3f581b0474a216938810885f4f606e0db1f21ff.tar.gz frameworks_base-c3f581b0474a216938810885f4f606e0db1f21ff.tar.bz2 | |
Workaround for issue where the notifyDatasetChanged call chain is broken when Launcher is killed. (Bug 5703782)
Change-Id: Ic57a7ce85f41d58cd40b7d30eef4a1bf685182e5
Diffstat (limited to 'services/java/com/android/server/AppWidgetService.java')
| -rw-r--r-- | services/java/com/android/server/AppWidgetService.java | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java index 2af5103..4f81178 100644 --- a/services/java/com/android/server/AppWidgetService.java +++ b/services/java/com/android/server/AppWidgetService.java @@ -24,9 +24,9 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.Intent.FilterComparison; import android.content.IntentFilter; import android.content.ServiceConnection; -import android.content.Intent.FilterComparison; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; @@ -39,6 +39,8 @@ import android.content.res.XmlResourceParser; import android.net.Uri; import android.os.Binder; import android.os.Bundle; +import android.os.Handler; +import android.os.HandlerThread; import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; @@ -74,6 +76,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.Set; class AppWidgetService extends IAppWidgetService.Stub { @@ -805,6 +808,45 @@ class AppWidgetService extends IAppWidgetService.Stub id.host.callbacks = null; } } + + // If the host is unavailable, then we call the associated + // RemoteViewsFactory.onDataSetChanged() directly + if (id.host.callbacks == null) { + Set<FilterComparison> keys = mRemoteViewsServicesAppWidgets.keySet(); + for (FilterComparison key : keys) { + if (mRemoteViewsServicesAppWidgets.get(key).contains(id.appWidgetId)) { + Intent intent = key.getIntent(); + + final ServiceConnection conn = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + IRemoteViewsFactory cb = + IRemoteViewsFactory.Stub.asInterface(service); + try { + cb.onDataSetChangedAsync(); + } catch (RemoteException e) { + e.printStackTrace(); + } catch (RuntimeException e) { + e.printStackTrace(); + } + mContext.unbindService(this); + } + @Override + public void onServiceDisconnected(android.content.ComponentName name) { + // Do nothing + } + }; + + // Bind to the service and call onDataSetChanged() + final long token = Binder.clearCallingIdentity(); + try { + mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE); + } finally { + Binder.restoreCallingIdentity(token); + } + } + } + } } } |
