diff options
| author | Winson Chung <winsonc@google.com> | 2010-11-01 12:14:49 -0700 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2010-11-01 14:50:20 -0700 |
| commit | ae615981315d9318edb1d8bf2a0f607f90cc77ac (patch) | |
| tree | 0365aa704dfef6950a9ca8171516873b534a72bb /core | |
| parent | 58954d299ceb9dd1c3948100af29914d6537ef0e (diff) | |
| download | frameworks_base-ae615981315d9318edb1d8bf2a0f607f90cc77ac.zip frameworks_base-ae615981315d9318edb1d8bf2a0f607f90cc77ac.tar.gz frameworks_base-ae615981315d9318edb1d8bf2a0f607f90cc77ac.tar.bz2 | |
Adding more exception handling to RemoteViews calls to startIntentSender
Change-Id: I03d7b48813aaf7f94785389c2838d68b0ba913d3
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 35c50fd..6ba7b44 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -132,6 +132,25 @@ public class RemoteViews implements Parcelable, Filter { // here return; } + + protected boolean startIntentSafely(Context context, PendingIntent pendingIntent, + Intent fillInIntent) { + try { + // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT? + context.startIntentSender( + pendingIntent.getIntentSender(), fillInIntent, + Intent.FLAG_ACTIVITY_NEW_TASK, + Intent.FLAG_ACTIVITY_NEW_TASK, 0); + } catch (IntentSender.SendIntentException e) { + android.util.Log.e(LOG_TAG, "Cannot send pending intent: ", e); + return false; + } catch (Exception e) { + android.util.Log.e(LOG_TAG, "Cannot send pending intent due to " + + "unknown exception: ", e); + return false; + } + return true; + } } private class SetEmptyView extends Action { @@ -236,15 +255,7 @@ public class RemoteViews implements Parcelable, Filter { rect.bottom = (int) ((pos[1] + v.getHeight()) * appScale + 0.5f); fillInIntent.setSourceBounds(rect); - try { - // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT? - v.getContext().startIntentSender( - pendingIntent.getIntentSender(), fillInIntent, - Intent.FLAG_ACTIVITY_NEW_TASK, - Intent.FLAG_ACTIVITY_NEW_TASK, 0); - } catch (IntentSender.SendIntentException e) { - android.util.Log.e(LOG_TAG, "Cannot send pending intent: ", e); - } + startIntentSafely(v.getContext(), pendingIntent, fillInIntent); } }; @@ -326,16 +337,7 @@ public class RemoteViews implements Parcelable, Filter { final Intent intent = new Intent(); intent.setSourceBounds(rect); intent.putExtras(extras); - - try { - // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT? - v.getContext().startIntentSender( - pendingIntent.getIntentSender(), intent, - Intent.FLAG_ACTIVITY_NEW_TASK, - Intent.FLAG_ACTIVITY_NEW_TASK, 0); - } catch (IntentSender.SendIntentException e) { - android.util.Log.e(LOG_TAG, "Cannot send pending intent: ", e); - } + startIntentSafely(v.getContext(), pendingIntent, intent); } }; @@ -441,15 +443,7 @@ public class RemoteViews implements Parcelable, Filter { final Intent intent = new Intent(); intent.setSourceBounds(rect); - try { - // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT? - v.getContext().startIntentSender( - pendingIntent.getIntentSender(), intent, - Intent.FLAG_ACTIVITY_NEW_TASK, - Intent.FLAG_ACTIVITY_NEW_TASK, 0); - } catch (IntentSender.SendIntentException e) { - android.util.Log.e(LOG_TAG, "Cannot send pending intent: ", e); - } + startIntentSafely(v.getContext(), pendingIntent, intent); } }; target.setOnClickListener(listener); |
