Bug 776223 - Don't paste null text to Android's clipboard. r=blassey a=akeybl
authorChris Peterson <cpeterson@mozilla.com>
Fri, 17 May 2013 17:16:38 -0700
changeset 138530 2432964bf0be5f3d6c05f20f3e5b1bad81d7ec60
parent 138529 7c7e6e87fe7675aa4c4c4ec78cbaef9eb6511aa1
child 138531 0309cdbeeb00e117e16d4cd32238766f776a820e
push id3780
push usercpeterson@mozilla.com
push dateWed, 22 May 2013 19:32:26 +0000
treeherdermozilla-aurora@2432964bf0be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, akeybl
bugs776223
milestone23.0a2
Bug 776223 - Don't paste null text to Android's clipboard. r=blassey a=akeybl
mobile/android/base/GeckoAppShell.java
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -1215,17 +1215,21 @@ public class GeckoAppShell
         });
         try {
             return sClipboardQueue.take();
         } catch (InterruptedException ie) {
             return "";
         }
     }
 
-    static void setClipboardText(final String text) {
+    static void setClipboardText(String copiedText) {
+        // Copy an empty string instead of null to avoid clipboard crashes.
+        // AndroidBridge::EmptyClipboard() passes null to clear the clipboard's current contents.
+        final String text = (copiedText != null) ? copiedText : "";
+
         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);