OSDN Git Service

DO NOT MERGE - Catching TransactionTooLargeException in AppWidgetHost#startListening
authorAdam Cohen <adamcohen@google.com>
Mon, 16 Jun 2014 22:22:56 +0000 (15:22 -0700)
committerAdam Cohen <adamcohen@google.com>
Wed, 18 Jun 2014 17:31:20 +0000 (17:31 +0000)
solution b) from issue 14255011

Change-Id: I1dc521632a132de496ff9a583b1e0b29415aacdd
(cherry picked from commit 084c31873e5d5015dac9eaac722a6d8387b6dd8d)

src/com/android/launcher3/LauncherAppWidgetHost.java

index 7b08d44..fa5e38f 100644 (file)
@@ -20,6 +20,7 @@ import android.appwidget.AppWidgetHost;
 import android.appwidget.AppWidgetHostView;
 import android.appwidget.AppWidgetProviderInfo;
 import android.content.Context;
+import android.os.TransactionTooLargeException;
 
 /**
  * Specific {@link AppWidgetHost} that creates our {@link LauncherAppWidgetHostView}
@@ -42,6 +43,22 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
     }
 
     @Override
+    public void startListening() {
+        try {
+            super.startListening();
+        } catch (Exception e) {
+            if (e.getCause() instanceof TransactionTooLargeException) {
+                // We're willing to let this slide. The exception is being caused by the list of
+                // RemoteViews which is being passed back. The startListening relationship will
+                // have been established by this point, and we will end up populating the
+                // widgets upon bind anyway. See issue 14255011 for more context.
+            } else {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+    @Override
     public void stopListening() {
         super.stopListening();
         clearViews();