Bug 982461 - Support launching an intent to the current application package. r=wesj
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 12 Mar 2014 08:57:29 -0700
changeset 190470 8de8e275a35bb7c6946780cf82063445bc390a4d
parent 190469 e6636696d6de5f4b2f32812eeff731aae7341c96
child 190471 e1328db7d97bbeb67e260a9ab5351a1acbf8db0b
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs982461
milestone30.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 982461 - Support launching an intent to the current application package. r=wesj
mobile/android/base/GeckoAppShell.java
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -1116,20 +1116,23 @@ public class GeckoAppShell
             }
         }
         return true;
     }
 
     /**
      * Given the inputs to <code>getOpenURIIntent</code>, plus an optional
      * package name and class name, create and fire an intent to open the
-     * provided URI.
+     * provided URI. If a class name is specified but a package name is not,
+     * we will default to using the current fennec package.
      *
      * @param targetURI the string spec of the URI to open.
      * @param mimeType an optional MIME type string.
+     * @param packageName an optional app package name.
+     * @param className an optional intent class name.
      * @param action an Android action specifier, such as
      *               <code>Intent.ACTION_SEND</code>.
      * @param title the title to use in <code>ACTION_SEND</code> intents.
      * @return true if the activity started successfully; false otherwise.
      */
     @WrapElementForJNI
     public static boolean openUriExternal(String targetURI,
                                           String mimeType,
@@ -1140,18 +1143,23 @@ public class GeckoAppShell
         final Context context = getContext();
         final Intent intent = getOpenURIIntent(context, targetURI,
                                                mimeType, action, title);
 
         if (intent == null) {
             return false;
         }
 
-        if (packageName.length() > 0 && className.length() > 0) {
-            intent.setClassName(packageName, className);
+        if (!TextUtils.isEmpty(className)) {
+            if (!TextUtils.isEmpty(packageName)) {
+                intent.setClassName(packageName, className);
+            } else {
+                // Default to using the fennec app context.
+                intent.setClassName(context, className);
+            }
         }
 
         intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         try {
             context.startActivity(intent);
             return true;
         } catch (ActivityNotFoundException e) {
             return false;