Bug 776223 - Catch NullPointerException from Samsung's buggy clipboard API. r=blassey a=akeybl
authorChris Peterson <cpeterson@mozilla.com>
Tue, 28 May 2013 11:30:49 -0700
changeset 142759 63b7121fc7e2fb15776a0b06a3c1f46b0e86df8f
parent 142758 edbdb962f5fe0ff1f014388a71cb1fb1ffc73142
child 142760 521002836cdff98fb00997f84214dd2fa6618d73
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, akeybl
bugs776223
milestone23.0a2
Bug 776223 - Catch NullPointerException from Samsung's buggy clipboard API. r=blassey a=akeybl
mobile/android/base/GeckoAppShell.java
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -1228,17 +1228,24 @@ public class GeckoAppShell
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
             @SuppressWarnings("deprecation")
             public void run() {
                 Context context = GeckoApp.mAppContext;
                 if (android.os.Build.VERSION.SDK_INT >= 11) {
                     android.content.ClipboardManager cm = (android.content.ClipboardManager)
                         context.getSystemService(Context.CLIPBOARD_SERVICE);
-                    cm.setPrimaryClip(ClipData.newPlainText("Text", text));
+                    ClipData clip = ClipData.newPlainText("Text", text);
+                    try {
+                        cm.setPrimaryClip(clip);
+                    } catch (NullPointerException e) {
+                        // Bug 776223: This is a Samsung clipboard bug. setPrimaryClip() can throw
+                        // a NullPointerException if Samsung's /data/clipboard directory is full.
+                        // Fortunately, the text is still successfully copied to the clipboard.
+                    }
                 } else {
                     android.text.ClipboardManager cm = (android.text.ClipboardManager)
                         context.getSystemService(Context.CLIPBOARD_SERVICE);
                     cm.setText(text);
                 }
             }
         });
     }