Bug 1078394 - Remove AppConstants.SEARCH_PACKAGE_NAME. r=margaret
authorRichard Newman <rnewman@mozilla.com>
Mon, 06 Oct 2014 12:01:51 -0700
changeset 232539 ec19d8282465016ddd24295b448003dc63f29c03
parent 232538 2c435535573d73ab43116c88200c3eab28a89600
child 232540 3af0a07adc4940f3ffb0f570ac3834f4986ed050
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1078394
milestone35.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 1078394 - Remove AppConstants.SEARCH_PACKAGE_NAME. r=margaret
mobile/android/base/AppConstants.java.in
mobile/android/search/java/org/mozilla/search/SearchWidget.java
--- a/mobile/android/base/AppConstants.java.in
+++ b/mobile/android/base/AppConstants.java.in
@@ -17,18 +17,16 @@ import android.os.Build;
  * other things.
  *
  * See also SysInfo.java, which includes some of the values available from
  * nsSystemInfo inside Gecko.
  */
 @RobocopTarget
 public class AppConstants {
     public static final String ANDROID_PACKAGE_NAME = "@ANDROID_PACKAGE_NAME@";
-    // Maintain a separate search package name so that we can speciailize it in the standalone search project
-    public static final String SEARCH_PACKAGE_NAME = "@ANDROID_PACKAGE_NAME@";
     public static final String MANGLED_ANDROID_PACKAGE_NAME = "@MANGLED_ANDROID_PACKAGE_NAME@";
 
     /**
      * Encapsulates access to compile-time version definitions, allowing
      * for dead code removal for particular APKs.
      */
     public static final class Versions {
         public static final int MIN_SDK_VERSION = @MOZ_ANDROID_MIN_SDK_VERSION@;
--- a/mobile/android/search/java/org/mozilla/search/SearchWidget.java
+++ b/mobile/android/search/java/org/mozilla/search/SearchWidget.java
@@ -56,52 +56,49 @@ public class SearchWidget extends AppWid
         addView(manager, context, id, options);
         if (AppConstants.Versions.feature16Plus) {
             super.onAppWidgetOptionsChanged(context, manager, id, options);
         }
     }
 
     @Override
     public void onReceive(final Context context, final Intent intent) {
-        // This will hold the intent to redispatch
+        // This will hold the intent to redispatch.
         final Intent redirect;
-        if (intent.getAction().equals(ACTION_LAUNCH_BROWSER)) {
-            redirect = buildRedirectIntent(Intent.ACTION_MAIN,
-                    AppConstants.ANDROID_PACKAGE_NAME,
-                    AppConstants.BROWSER_INTENT_CLASS_NAME,
-                    intent);
-            Telemetry.sendUIEvent(TelemetryContract.Event.LAUNCH,
-                    TelemetryContract.Method.WIDGET, "browser");
-        } else if (intent.getAction().equals(ACTION_LAUNCH_NEW_TAB)) {
+        switch (intent.getAction()) {
+            case ACTION_LAUNCH_BROWSER:
+                redirect = buildRedirectIntent(Intent.ACTION_MAIN,
+                                               AppConstants.ANDROID_PACKAGE_NAME,
+                                               AppConstants.BROWSER_INTENT_CLASS_NAME,
+                                               intent);
+                Telemetry.sendUIEvent(TelemetryContract.Event.LAUNCH,
+                                      TelemetryContract.Method.WIDGET, "browser");
+                break;
+            case ACTION_LAUNCH_NEW_TAB:
                 redirect = buildRedirectIntent(Intent.ACTION_VIEW,
-                        AppConstants.ANDROID_PACKAGE_NAME,
-                        AppConstants.BROWSER_INTENT_CLASS_NAME,
-                        intent);
-            Telemetry.sendUIEvent(TelemetryContract.Event.LAUNCH,
-                    TelemetryContract.Method.WIDGET, "new-tab");
-        } else if (intent.getAction().equals(ACTION_LAUNCH_SEARCH)) {
-            redirect = buildRedirectIntent(Intent.ACTION_VIEW,
-                    AppConstants.SEARCH_PACKAGE_NAME,
-                    AppConstants.SEARCH_INTENT_CLASS_NAME,
-                    intent);
-            Telemetry.sendUIEvent(TelemetryContract.Event.LAUNCH,
-                    TelemetryContract.Method.WIDGET, "search");
-        } else {
-            redirect = null;
+                                               AppConstants.ANDROID_PACKAGE_NAME,
+                                               AppConstants.BROWSER_INTENT_CLASS_NAME,
+                                               intent);
+                Telemetry.sendUIEvent(TelemetryContract.Event.LAUNCH,
+                                      TelemetryContract.Method.WIDGET, "new-tab");
+                break;
+            case ACTION_LAUNCH_SEARCH:
+                redirect = buildRedirectIntent(Intent.ACTION_VIEW,
+                                               AppConstants.ANDROID_PACKAGE_NAME,
+                                               AppConstants.SEARCH_INTENT_CLASS_NAME,
+                                               intent);
+                Telemetry.sendUIEvent(TelemetryContract.Event.LAUNCH,
+                                      TelemetryContract.Method.WIDGET, "search");
+                break;
+            default:
+                redirect = null;
         }
 
         if (redirect != null) {
-            try {
-                context.startActivity(redirect);
-            } catch(Exception ex) {
-                // When this is built stand alone, its hardcoded to try and launch nightly.
-                // If that fails, just fire a generic VIEW intent.
-                Intent redirect2 = buildRedirectIntent(Intent.ACTION_VIEW, null, null, intent);
-                context.startActivity(redirect2);
-            }
+            context.startActivity(redirect);
         }
 
         super.onReceive(context, intent);
     }
 
     // Utility to create the view for this widget and attach any event listeners to it
     private void addView(final AppWidgetManager manager, final Context context, final int id, final Bundle options) {
         final int category = options.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
@@ -137,9 +134,9 @@ public class SearchWidget extends AppWid
         if (pkg != null && className != null) {
             activity.setClassName(pkg, className);
         }
         activity.setData(source.getData());
         activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         return activity;
     }
 
-}
\ No newline at end of file
+}