Bug 1021443 - java.lang.IllegalStateException: Already registered Webapps:Postinstall under a different type. r=jchen
authorRichard Newman <rnewman@mozilla.com>
Thu, 05 Jun 2014 19:38:01 -0700
changeset 206482 7331dd991a5c084a1ae6b85f44a3ed60dcdff724
parent 206481 fa54ecd90c6be37f03aa1200f45f4921c2d7aaef
child 206483 ee2320d65148fb218321c7f706597493a3555aac
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1021443
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1021443 - java.lang.IllegalStateException: Already registered Webapps:Postinstall under a different type. r=jchen
mobile/android/base/webapp/InstallHelper.java
mobile/android/base/webapp/WebappImpl.java
--- a/mobile/android/base/webapp/InstallHelper.java
+++ b/mobile/android/base/webapp/InstallHelper.java
@@ -14,34 +14,36 @@ import java.io.OutputStream;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.gfx.BitmapUtils;
-import org.mozilla.gecko.util.GeckoEventListener;
+import org.mozilla.gecko.util.EventCallback;
+import org.mozilla.gecko.util.NativeEventListener;
+import org.mozilla.gecko.util.NativeJSObject;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.net.Uri;
 import android.util.Log;
 
-public class InstallHelper implements GeckoEventListener {
+public class InstallHelper implements NativeEventListener {
     private static final String LOGTAG = "GeckoWebappInstallHelper";
     private static final String[] INSTALL_EVENT_NAMES = new String[] {"Webapps:Postinstall"};
     private final Context mContext;
     private final InstallCallback mCallback;
     private final ApkResources mApkResources;
 
     public static interface InstallCallback {
         // on the GeckoThread
-        void installCompleted(InstallHelper installHelper, String event, JSONObject message);
+        void installCompleted(InstallHelper installHelper, String event, NativeJSObject message);
 
         // on the GeckoBackgroundThread
         void installErrored(InstallHelper installHelper, Exception exception);
     }
 
     public InstallHelper(Context context, ApkResources apkResources, InstallCallback cb) {
         mContext = context;
         mCallback = cb;
@@ -157,16 +159,16 @@ public class InstallHelper implements Ge
         ThreadUtils.assertOnBackgroundThread();
         Allocator slots = Allocator.getInstance(mContext);
         int index = slots.getIndexForApp(mApkResources.getPackageName());
         Bitmap bitmap = BitmapUtils.getBitmapFromDrawable(mApkResources.getAppIcon());
         slots.updateColor(index, BitmapUtils.getDominantColor(bitmap));
     }
 
     @Override
-    public void handleMessage(String event, JSONObject message) {
+    public void handleMessage(String event, NativeJSObject message, EventCallback callback) {
         EventDispatcher.getInstance().unregisterGeckoThreadListener(this, INSTALL_EVENT_NAMES);
 
         if (mCallback != null) {
             mCallback.installCompleted(this, event, message);
         }
     }
 }
--- a/mobile/android/base/webapp/WebappImpl.java
+++ b/mobile/android/base/webapp/WebappImpl.java
@@ -13,16 +13,17 @@ import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.GeckoThread;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
+import org.mozilla.gecko.util.NativeJSObject;
 import org.mozilla.gecko.webapp.InstallHelper.InstallCallback;
 
 import android.content.Intent;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.graphics.Color;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.GradientDrawable;
 import android.net.Uri;
@@ -320,23 +321,23 @@ public class WebappImpl extends GeckoApp
                 @Override
                 public void onAnimationStart(Animation animation) { }
             });
             mSplashscreen.startAnimation(fadeout);
         }
     }
 
     @Override
-    public void installCompleted(InstallHelper installHelper, String event, JSONObject message) {
+    public void installCompleted(InstallHelper installHelper, String event, NativeJSObject message) {
         if (event == null) {
             return;
         }
 
         if (event.equals("Webapps:Postinstall")) {
-            String origin = message.optString("origin");
+            String origin = message.optString("origin", null);
             launchWebapp(origin);
         }
     }
 
     @Override
     public void installErrored(InstallHelper installHelper, Exception exception) {
         Log.e(LOGTAG, "Install errored", exception);
     }