Bug 1081597: Refactor some branches. r=rnewman
authorChris Kitching <chriskitching@linux.com>
Sun, 12 Oct 2014 01:41:42 +0100
changeset 233213 0fcf464736d797534db58fbd5266f350c3ef42cf
parent 233212 cd62bf9df675aaf25be1170459cbb0e7d504c81a
child 233214 0dc0ff9bb484b2782786bdc4ee73be80f5048ab6
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)
reviewersrnewman
bugs1081597
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 1081597: Refactor some branches. r=rnewman * * * Bug 1081597: Refactor some branches. r=rnewman
mobile/android/base/ANRReporter.java
mobile/android/base/AndroidGamepadManager.java
mobile/android/base/ContactService.java
mobile/android/base/GeckoNetworkManager.java
mobile/android/base/GeckoScreenOrientation.java
mobile/android/base/favicons/cache/FaviconCacheElement.java
mobile/android/base/fxa/activities/FxAccountStatusActivity.java
mobile/android/base/home/BrowserSearch.java
mobile/android/base/home/RemoteTabsExpandableListFragment.java
mobile/android/base/mozglue/DirectBufferAllocator.java
mobile/android/base/preferences/MultiChoicePreference.java
mobile/android/base/prompts/PromptInput.java
mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
mobile/android/base/tabs/TabStripItemView.java
mobile/android/base/tests/helpers/JavascriptBridge.java
mobile/android/base/toolbar/ToolbarEditText.java
mobile/android/base/webapp/InstallListener.java
mobile/android/base/webapp/WebappImpl.java
mobile/android/base/widget/TwoWayView.java
mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/Reporter.java
--- a/mobile/android/base/ANRReporter.java
+++ b/mobile/android/base/ANRReporter.java
@@ -245,17 +245,18 @@ public final class ANRReporter extends B
 
         long uptimeMins = (new File("/proc/self/stat")).lastModified();
         if (uptimeMins != 0L) {
             uptimeMins = (System.currentTimeMillis() - uptimeMins) / 1000L / 60L;
             if (DEBUG) {
                 Log.d(LOGTAG, "uptime " + String.valueOf(uptimeMins));
             }
             return uptimeMins;
-        } else if (DEBUG) {
+        }
+        if (DEBUG) {
             Log.d(LOGTAG, "could not get uptime");
         }
         return 0L;
     }
 
     /*
         a saved telemetry ping file consists of JSON in the following format,
             {
--- a/mobile/android/base/AndroidGamepadManager.java
+++ b/mobile/android/base/AndroidGamepadManager.java
@@ -253,17 +253,19 @@ public class AndroidGamepadManager {
             return false;
         }
 
         int deviceId = ev.getDeviceId();
         if (sPendingGamepads.containsKey(deviceId)) {
             // Queue up key events for pending devices.
             sPendingGamepads.get(deviceId).add(ev);
             return true;
-        } else if (!sGamepads.containsKey(deviceId)) {
+        }
+
+        if (!sGamepads.containsKey(deviceId)) {
             InputDevice device = ev.getDevice();
             if (device != null &&
                 (device.getSources() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
                 // This is a gamepad we haven't seen yet.
                 addGamepad(device);
                 sPendingGamepads.get(deviceId).add(ev);
                 return true;
             }
--- a/mobile/android/base/ContactService.java
+++ b/mobile/android/base/ContactService.java
@@ -397,51 +397,57 @@ public class ContactService implements G
 
         if (databaseValue == null) {
             return false;
         }
 
         filterValue = filterValue.toLowerCase();
         databaseValue = databaseValue.toLowerCase();
 
-        if ("match".equals(filterOp)) {
-            // If substring matching is a positive number, only pay attention to the last X characters
-            // of both the filter and database values
-            if (substringMatching > 0) {
-                databaseValue = substringStartFromEnd(cleanPhoneNumber(databaseValue), substringMatching);
-                filterValue = substringStartFromEnd(cleanPhoneNumber(filterValue), substringMatching);
-                return databaseValue.startsWith(filterValue);
-            }
-            return databaseValue.equals(filterValue);
-        } else if ("equals".equals(filterOp)) {
-            if (isPhone) {
-                return PhoneNumberUtils.compare(filterValue, databaseValue);
-            }
-            return databaseValue.equals(filterValue);
-        } else if ("contains".equals(filterOp)) {
-            if (isPhone) {
-                filterValue = cleanPhoneNumber(filterValue);
-                databaseValue = cleanPhoneNumber(databaseValue);
-            }
-            return databaseValue.contains(filterValue);
-        } else if ("startsWith".equals(filterOp)) {
-            // If a phone number, remove non-dialable characters and then only pay attention to
-            // the last X digits given by the substring matching values (see bug 877302)
-            if (isPhone) {
-                String cleanedDatabasePhone = cleanPhoneNumber(databaseValue);
+        switch (filterOp) {
+            case "match":
+                // If substring matching is a positive number, only pay attention to the last X characters
+                // of both the filter and database values
                 if (substringMatching > 0) {
-                    cleanedDatabasePhone = substringStartFromEnd(cleanedDatabasePhone, substringMatching);
+                    databaseValue = substringStartFromEnd(cleanPhoneNumber(databaseValue), substringMatching);
+                    filterValue = substringStartFromEnd(cleanPhoneNumber(filterValue), substringMatching);
+                    return databaseValue.startsWith(filterValue);
+                }
+
+                return databaseValue.equals(filterValue);
+            case "equals":
+                if (isPhone) {
+                    return PhoneNumberUtils.compare(filterValue, databaseValue);
                 }
 
-                if (cleanedDatabasePhone.startsWith(filterValue)) {
-                    return true;
+                return databaseValue.equals(filterValue);
+            case "contains":
+                if (isPhone) {
+                    filterValue = cleanPhoneNumber(filterValue);
+                    databaseValue = cleanPhoneNumber(databaseValue);
                 }
-            }
-            return databaseValue.startsWith(filterValue);
+
+                return databaseValue.contains(filterValue);
+            case "startsWith":
+                // If a phone number, remove non-dialable characters and then only pay attention to
+                // the last X digits given by the substring matching values (see bug 877302)
+                if (isPhone) {
+                    String cleanedDatabasePhone = cleanPhoneNumber(databaseValue);
+                    if (substringMatching > 0) {
+                        cleanedDatabasePhone = substringStartFromEnd(cleanedDatabasePhone, substringMatching);
+                    }
+
+                    if (cleanedDatabasePhone.startsWith(filterValue)) {
+                        return true;
+                    }
+                }
+
+                return databaseValue.startsWith(filterValue);
         }
+
         return false;
     }
 
     private static String cleanPhoneNumber(String phone) {
         return phone.replace(" ", "").replace("(", "").replace(")", "").replace("-", "");
     }
 
     private static String substringStartFromEnd(final String string, final int distanceFromEnd) {
--- a/mobile/android/base/GeckoNetworkManager.java
+++ b/mobile/android/base/GeckoNetworkManager.java
@@ -275,19 +275,22 @@ public class GeckoNetworkManager extends
             Log.e(LOGTAG, "Telephony service does not exist");
             return -1;
         }
 
         String networkOperator = tel.getNetworkOperator();
         if (networkOperator == null || networkOperator.length() <= 3) {
             return -1;
         }
+
         if (type == InfoType.MNC) {
             return Integer.parseInt(networkOperator.substring(3));
-        } else if (type == InfoType.MCC) {
+        }
+
+        if (type == InfoType.MCC) {
             return Integer.parseInt(networkOperator.substring(0, 3));
         }
 
         return -1;
     }
 
     /**
      * These are called from JavaScript ctypes. Avoid letting ProGuard delete them.
--- a/mobile/android/base/GeckoScreenOrientation.java
+++ b/mobile/android/base/GeckoScreenOrientation.java
@@ -293,34 +293,31 @@ public class GeckoScreenOrientation {
      * Retrieve the scren orientation from a string.
      *
      * @param aStr
      *        String hopefully containing a screen orientation name.
      * @return Gecko screen orientation if matched, DEFAULT_SCREEN_ORIENTATION
      *         otherwise.
      */
     public static ScreenOrientation screenOrientationFromString(String aStr) {
-        if ("portrait".equals(aStr)) {
-            return ScreenOrientation.PORTRAIT_PRIMARY;
-        }
-        else if ("landscape".equals(aStr)) {
-            return ScreenOrientation.LANDSCAPE_PRIMARY;
-        }
-        else if ("portrait-primary".equals(aStr)) {
-            return ScreenOrientation.PORTRAIT_PRIMARY;
+        switch (aStr) {
+            case "portrait":
+                return ScreenOrientation.PORTRAIT_PRIMARY;
+            case "landscape":
+                return ScreenOrientation.LANDSCAPE_PRIMARY;
+            case "portrait-primary":
+                return ScreenOrientation.PORTRAIT_PRIMARY;
+            case "portrait-secondary":
+                return ScreenOrientation.PORTRAIT_SECONDARY;
+            case "landscape-primary":
+                return ScreenOrientation.LANDSCAPE_PRIMARY;
+            case "landscape-secondary":
+                return ScreenOrientation.LANDSCAPE_SECONDARY;
         }
-        else if ("portrait-secondary".equals(aStr)) {
-            return ScreenOrientation.PORTRAIT_SECONDARY;
-        }
-        else if ("landscape-primary".equals(aStr)) {
-            return ScreenOrientation.LANDSCAPE_PRIMARY;
-        }
-        else if ("landscape-secondary".equals(aStr)) {
-            return ScreenOrientation.LANDSCAPE_SECONDARY;
-        }
+
         Log.w(LOGTAG, "screenOrientationFromString: unknown orientation string");
         return DEFAULT_SCREEN_ORIENTATION;
     }
 
     /*
      * Convert Gecko screen orientation to Android orientation.
      *
      * @param aScreenOrientation
--- a/mobile/android/base/favicons/cache/FaviconCacheElement.java
+++ b/mobile/android/base/favicons/cache/FaviconCacheElement.java
@@ -79,17 +79,19 @@ public class FaviconCacheElement impleme
         if (invalidated) {
             return 0;
         }
 
         final int w1 = imageSize;
         final int w2 = another.imageSize;
         if (w1 > w2) {
             return 1;
-        } else if (w2 > w1) {
+        }
+
+        if (w2 > w1) {
             return -1;
         }
         return 0;
     }
 
     /**
      * Called when this element is evicted from the cache.
      *
--- a/mobile/android/base/fxa/activities/FxAccountStatusActivity.java
+++ b/mobile/android/base/fxa/activities/FxAccountStatusActivity.java
@@ -166,17 +166,19 @@ public class FxAccountStatusActivity ext
   }
 
   @Override
   public boolean onOptionsItemSelected(MenuItem item) {
     int itemId = item.getItemId();
     if (itemId == android.R.id.home) {
       finish();
       return true;
-    } else if (itemId == R.id.remove_account) {
+    }
+
+    if (itemId == R.id.remove_account) {
       maybeDeleteAndroidAccount(FirefoxAccounts.getFirefoxAccount(this));
       return true;
     }
 
     return super.onOptionsItemSelected(item);
   }
 
   @Override
--- a/mobile/android/base/home/BrowserSearch.java
+++ b/mobile/android/base/home/BrowserSearch.java
@@ -817,17 +817,19 @@ public class BrowserSearch extends HomeF
         }
 
         @Override
         public int getItemViewType(int position) {
             final int engine = getEngineIndex(position);
 
             if (engine == -1) {
                 return ROW_STANDARD;
-            } else if (engine == 0 && mSuggestionsEnabled) {
+            }
+
+            if (engine == 0 && mSuggestionsEnabled) {
                 // Give suggestion views their own type to prevent them from
                 // sharing other recycled search engine views. Using other
                 // recycled views for the suggestion row can break animations
                 // (bug 815937).
                 return ROW_SUGGEST;
             }
 
             return ROW_SEARCH;
--- a/mobile/android/base/home/RemoteTabsExpandableListFragment.java
+++ b/mobile/android/base/home/RemoteTabsExpandableListFragment.java
@@ -163,17 +163,19 @@ public class RemoteTabsExpandableListFra
                 final int type = ExpandableListView.getPackedPositionType(packedPosition);
                 if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
                     final int childPosition = ExpandableListView.getPackedPositionChild(packedPosition);
                     final RemoteTab tab = (RemoteTab) adapter.getChild(groupPosition, childPosition);
                     final HomeContextMenuInfo info = new HomeContextMenuInfo(view, position, id);
                     info.url = tab.url;
                     info.title = tab.title;
                     return info;
-                } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
+                }
+
+                if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
                     final RemoteClient client = (RemoteClient) adapter.getGroup(groupPosition);
                     final RemoteTabsClientContextMenuInfo info = new RemoteTabsClientContextMenuInfo(view, position, id, client);
                     return info;
                 }
                 return null;
             }
         });
 
@@ -283,21 +285,24 @@ public class RemoteTabsExpandableListFra
 
         final RemoteTabsClientContextMenuInfo info = (RemoteTabsClientContextMenuInfo) menuInfo;
 
         final int itemId = item.getItemId();
         if (itemId == R.id.home_remote_tabs_hide_client) {
             sState.setClientHidden(info.client.guid, true);
             getLoaderManager().restartLoader(LOADER_ID_REMOTE_TABS, null, mCursorLoaderCallbacks);
             return true;
-        } else if (itemId == R.id.home_remote_tabs_show_client) {
+        }
+
+        if (itemId == R.id.home_remote_tabs_show_client) {
             sState.setClientHidden(info.client.guid, false);
             getLoaderManager().restartLoader(LOADER_ID_REMOTE_TABS, null, mCursorLoaderCallbacks);
             return true;
         }
+
         return false;
     }
 
     private void updateUiFromClients(List<RemoteClient> clients, List<RemoteClient> hiddenClients) {
         // We have three states: no clients (including hidden clients) at all;
         // all clients hidden; some clients hidden. We want to show the empty
         // list view only when we have no clients at all. This flag
         // differentiates the first from the latter two states.
--- a/mobile/android/base/mozglue/DirectBufferAllocator.java
+++ b/mobile/android/base/mozglue/DirectBufferAllocator.java
@@ -19,17 +19,19 @@ public final class DirectBufferAllocator
     public static ByteBuffer allocate(int size) {
         if (size <= 0) {
             throw new IllegalArgumentException("Invalid size " + size);
         }
 
         ByteBuffer directBuffer = nativeAllocateDirectBuffer(size);
         if (directBuffer == null) {
             throw new OutOfMemoryError("allocateDirectBuffer() returned null");
-        } else if (!directBuffer.isDirect()) {
+        }
+
+        if (!directBuffer.isDirect()) {
             throw new AssertionError("allocateDirectBuffer() did not return a direct buffer");
         }
 
         return directBuffer;
     }
 
     public static ByteBuffer free(ByteBuffer buffer) {
         if (buffer == null) {
--- a/mobile/android/base/preferences/MultiChoicePreference.java
+++ b/mobile/android/base/preferences/MultiChoicePreference.java
@@ -187,20 +187,20 @@ class MultiChoicePreference extends Dial
             // have been set before the dialog was closed.
             return;
         }
 
         if (!positiveResult) {
             // user cancelled; reset checkbox values to their previous state
             mValues = mPrevValues.clone();
             return;
-        } else {
-            mPrevValues = mValues.clone();
         }
 
+        mPrevValues = mValues.clone();
+
         if (!callChangeListener(getValues())) {
             return;
         }
 
         persist();
     }
 
     /* Persists the current data stored by this pref to SharedPreferences. */
--- a/mobile/android/base/prompts/PromptInput.java
+++ b/mobile/android/base/prompts/PromptInput.java
@@ -342,41 +342,45 @@ public class PromptInput {
         mType = obj.optString("type");
         String id = obj.optString("id");
         mId = TextUtils.isEmpty(id) ? mType : id;
         mValue = obj.optString("value");
     }
 
     public static PromptInput getInput(JSONObject obj) {
         String type = obj.optString("type");
-        if (EditInput.INPUT_TYPE.equals(type)) {
-            return new EditInput(obj);
-        } else if (NumberInput.INPUT_TYPE.equals(type)) {
-            return new NumberInput(obj);
-        } else if (PasswordInput.INPUT_TYPE.equals(type)) {
-            return new PasswordInput(obj);
-        } else if (CheckboxInput.INPUT_TYPE.equals(type)) {
-            return new CheckboxInput(obj);
-        } else if (MenulistInput.INPUT_TYPE.equals(type)) {
-            return new MenulistInput(obj);
-        } else if (LabelInput.INPUT_TYPE.equals(type)) {
-            return new LabelInput(obj);
-        } else if (IconGridInput.INPUT_TYPE.equals(type)) {
-            return new IconGridInput(obj);
-        } else if (ColorPickerInput.INPUT_TYPE.equals(type)) {
-            return new ColorPickerInput(obj);
-        } else if (TabInput.INPUT_TYPE.equals(type)) {
-            return new TabInput(obj);
-        } else {
-            for (String dtType : DateTimeInput.INPUT_TYPES) {
-                if (dtType.equals(type)) {
-                    return new DateTimeInput(obj);
+        switch (type) {
+            case EditInput.INPUT_TYPE:
+                return new EditInput(obj);
+            case NumberInput.INPUT_TYPE:
+                return new NumberInput(obj);
+            case PasswordInput.INPUT_TYPE:
+                return new PasswordInput(obj);
+            case CheckboxInput.INPUT_TYPE:
+                return new CheckboxInput(obj);
+            case MenulistInput.INPUT_TYPE:
+                return new MenulistInput(obj);
+            case LabelInput.INPUT_TYPE:
+                return new LabelInput(obj);
+            case IconGridInput.INPUT_TYPE:
+                return new IconGridInput(obj);
+            case ColorPickerInput.INPUT_TYPE:
+                return new ColorPickerInput(obj);
+            case TabInput.INPUT_TYPE:
+                return new TabInput(obj);
+            default:
+                for (String dtType : DateTimeInput.INPUT_TYPES) {
+                    if (dtType.equals(type)) {
+                        return new DateTimeInput(obj);
+                    }
                 }
-            }
+
+                break;
         }
+
         return null;
     }
 
     public View getView(Context context) throws UnsupportedOperationException {
         return null;
     }
 
     public String getId() {
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
@@ -1081,20 +1081,20 @@ public class AndroidBrowserBookmarksRepo
     }
 
     int rowType = getTypeFromCursor(cur);
     String typeString = BrowserContractHelpers.typeStringForCode(rowType);
 
     if (typeString == null) {
       Logger.warn(LOG_TAG, "Unsupported type code " + rowType);
       return null;
-    } else {
-      Logger.trace(LOG_TAG, "Record " + guid + " has type " + typeString);
     }
 
+    Logger.trace(LOG_TAG, "Record " + guid + " has type " + typeString);
+
     rec.type = typeString;
     rec.title = RepoUtils.getStringFromCursor(cur, BrowserContract.Bookmarks.TITLE);
     rec.bookmarkURI = RepoUtils.getStringFromCursor(cur, BrowserContract.Bookmarks.URL);
     rec.description = RepoUtils.getStringFromCursor(cur, BrowserContract.Bookmarks.DESCRIPTION);
     rec.tags = RepoUtils.getJSONArrayFromCursor(cur, BrowserContract.Bookmarks.TAGS);
     rec.keyword = RepoUtils.getStringFromCursor(cur, BrowserContract.Bookmarks.KEYWORD);
 
     rec.androidID = RepoUtils.getLongFromCursor(cur, BrowserContract.Bookmarks._ID);
--- a/mobile/android/base/tabs/TabStripItemView.java
+++ b/mobile/android/base/tabs/TabStripItemView.java
@@ -202,17 +202,18 @@ public class TabStripItemView extends Th
         setPrivateMode(tab.isPrivate());
     }
 
     private void updateFavicon(final Bitmap favicon) {
         if (favicon == null) {
             lastFavicon = null;
             faviconView.setImageResource(R.drawable.new_tablet_default_favicon);
             return;
-        } else if (favicon == lastFavicon) {
+        }
+        if (favicon == lastFavicon) {
             return;
         }
 
         // Cache the original so we can debounce without scaling.
         lastFavicon = favicon;
 
         final Bitmap scaledFavicon =
                 Bitmap.createScaledBitmap(favicon, faviconSize, faviconSize, false);
--- a/mobile/android/base/tests/helpers/JavascriptBridge.java
+++ b/mobile/android/base/tests/helpers/JavascriptBridge.java
@@ -251,62 +251,65 @@ public final class JavascriptBridge {
         final JSONArray argsArray;
         final Object[] args;
         try {
             if (!EVENT_TYPE.equals(message.getString("type"))) {
                 throw new IllegalStateException("Message type is not " + EVENT_TYPE);
             }
             type = message.getString("innerType");
 
-            if ("progress".equals(type)) {
-                // Javascript harness message
-                mLogParser.logMessage(message.getString("message"));
-                return MessageStatus.PROCESSED;
+            switch (type) {
+                case "progress":
+                    // Javascript harness message
+                    mLogParser.logMessage(message.getString("message"));
+                    return MessageStatus.PROCESSED;
 
-            } else if ("notify-loaded".equals(type)) {
-                mJavaBridgeLoaded = true;
-                return MessageStatus.PROCESSED;
+                case "notify-loaded":
+                    mJavaBridgeLoaded = true;
+                    return MessageStatus.PROCESSED;
 
-            } else if ("sync-reply".equals(type)) {
-                // Reply to Java-to-Javascript sync call
-                return MessageStatus.REPLIED;
+                case "sync-reply":
+                    // Reply to Java-to-Javascript sync call
+                    return MessageStatus.REPLIED;
 
-            } else if ("sync-call".equals(type) || "async-call".equals(type)) {
+                case "sync-call":
+                case "async-call":
 
-                if ("async-call".equals(type)) {
-                    // Save this async message until another async message arrives, then we
-                    // process the saved message and save the new one. This is done as a
-                    // form of tail call optimization, by making sync-replies come before
-                    // async-calls. On the other hand, if (message == mSavedAsyncMessage),
-                    // it means we're currently processing the saved message and should clear
-                    // mSavedAsyncMessage.
-                    final JSONObject newSavedMessage =
-                        (message != mSavedAsyncMessage ? message : null);
-                    message = mSavedAsyncMessage;
-                    mSavedAsyncMessage = newSavedMessage;
-                    if (message == null) {
-                        // Saved current message and there wasn't an already saved one.
-                        return MessageStatus.SAVED;
+                    if ("async-call".equals(type)) {
+                        // Save this async message until another async message arrives, then we
+                        // process the saved message and save the new one. This is done as a
+                        // form of tail call optimization, by making sync-replies come before
+                        // async-calls. On the other hand, if (message == mSavedAsyncMessage),
+                        // it means we're currently processing the saved message and should clear
+                        // mSavedAsyncMessage.
+                        final JSONObject newSavedMessage =
+                                (message != mSavedAsyncMessage ? message : null);
+                        message = mSavedAsyncMessage;
+                        mSavedAsyncMessage = newSavedMessage;
+                        if (message == null) {
+                            // Saved current message and there wasn't an already saved one.
+                            return MessageStatus.SAVED;
+                        }
                     }
-                }
 
-                methodName = message.getString("method");
-                argsArray = message.getJSONArray("args");
-                args = new Object[argsArray.length()];
-                for (int i = 0; i < args.length; i++) {
-                    args[i] = convertFromJSONValue(argsArray.get(i));
-                }
-                invokeMethod(methodName, args);
+                    methodName = message.getString("method");
+                    argsArray = message.getJSONArray("args");
+                    args = new Object[argsArray.length()];
+                    for (int i = 0; i < args.length; i++) {
+                        args[i] = convertFromJSONValue(argsArray.get(i));
+                    }
+                    invokeMethod(methodName, args);
 
-                if ("sync-call".equals(type)) {
-                    // Reply for sync messages
-                    sendMessage("sync-reply", methodName, null);
-                }
-                return MessageStatus.PROCESSED;
+                    if ("sync-call".equals(type)) {
+                        // Reply for sync messages
+                        sendMessage("sync-reply", methodName, null);
+                    }
+                    return MessageStatus.PROCESSED;
             }
+
             throw new IllegalStateException("Message type is unexpected");
 
         } catch (final JSONException e) {
             throw new IllegalStateException("Unable to retrieve JSON message", e);
         }
     }
 
     /**
--- a/mobile/android/base/toolbar/ToolbarEditText.java
+++ b/mobile/android/base/toolbar/ToolbarEditText.java
@@ -551,17 +551,19 @@ public class ToolbarEditText extends Cus
                     return true;
                 }
 
                 if (mCommitListener != null) {
                     mCommitListener.onCommit();
                 }
 
                 return true;
-            } else if (GamepadUtils.isBackKey(event)) {
+            }
+
+            if (GamepadUtils.isBackKey(event)) {
                 if (mDismissListener != null) {
                     mDismissListener.onDismiss();
                 }
 
                 return true;
             }
 
             if ((keyCode == KeyEvent.KEYCODE_DEL ||
--- a/mobile/android/base/webapp/InstallListener.java
+++ b/mobile/android/base/webapp/InstallListener.java
@@ -56,17 +56,18 @@ public class InstallListener extends Bro
             Log.e(LOGTAG, "Can't find package that's just been installed");
             return;
         }
 
         String manifestUrl = apkResources.getManifestUrl();
         if (TextUtils.isEmpty(manifestUrl)) {
             Log.i(LOGTAG, "No manifest URL present in metadata");
             return;
-        } else if (!isCorrectManifest(manifestUrl)) {
+        }
+        if (!isCorrectManifest(manifestUrl)) {
             // This happens when the updater triggers installation of multiple
             // APK updates simultaneously.  If we're the receiver for another
             // update, then simply ignore this intent by returning early.
             Log.i(LOGTAG, "Manifest URL is for a different install; ignoring");
             return;
         }
 
         // If we're here then everything is looking good and installation can continue.
--- a/mobile/android/base/webapp/WebappImpl.java
+++ b/mobile/android/base/webapp/WebappImpl.java
@@ -144,20 +144,20 @@ public class WebappImpl extends GeckoApp
                     Log.e(LOGTAG, "Couldn't install packaged app", e);
                 }
             } else {
                 // an install is already happening, so we should let it complete.
                 Log.i(LOGTAG, "Waiting for existing install to complete");
                 installHelper.registerGeckoListener();
             }
             return;
-        } else {
-            launchWebapp(origin);
         }
 
+        launchWebapp(origin);
+
         setTitle(mAppName);
     }
 
     @Override
     protected String getURIFromIntent(Intent intent) {
         String uri = super.getURIFromIntent(intent);
         if (uri != null) {
             return uri;
--- a/mobile/android/base/widget/TwoWayView.java
+++ b/mobile/android/base/widget/TwoWayView.java
@@ -1271,17 +1271,19 @@ public class TwoWayView extends AdapterV
 
             final int motionPosition = findMotionRowOrColumn((int) mLastTouchPos);
 
             mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
             mTouchRemainderPos = 0;
 
             if (mTouchMode == TOUCH_MODE_FLINGING) {
                 return true;
-            } else if (motionPosition >= 0) {
+            }
+
+            if (motionPosition >= 0) {
                 mMotionPosition = motionPosition;
                 mTouchMode = TOUCH_MODE_DOWN;
             }
 
             break;
 
         case MotionEvent.ACTION_MOVE: {
             if (mTouchMode != TOUCH_MODE_DOWN) {
@@ -1371,17 +1373,19 @@ public class TwoWayView extends AdapterV
                 break;
             }
 
             if (mTouchMode == TOUCH_MODE_FLINGING) {
                 mTouchMode = TOUCH_MODE_DRAGGING;
                 reportScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
                 motionPosition = findMotionRowOrColumn((int) mLastTouchPos);
                 return true;
-            } else if (mMotionPosition >= 0 && mAdapter.isEnabled(mMotionPosition)) {
+            }
+
+            if (mMotionPosition >= 0 && mAdapter.isEnabled(mMotionPosition)) {
                 mTouchMode = TOUCH_MODE_DOWN;
                 triggerCheckForTap();
             }
 
             mMotionPosition = motionPosition;
 
             break;
         }
@@ -3844,17 +3848,19 @@ public class TwoWayView extends AdapterV
                 handleDataChanged();
             }
 
             // Handle the empty set by removing all views that are visible
             // and calling it a day
             if (mItemCount == 0) {
                 resetState();
                 return;
-            } else if (mItemCount != mAdapter.getCount()) {
+            }
+
+            if (mItemCount != mAdapter.getCount()) {
                 throw new IllegalStateException("The content of the adapter has changed but "
                         + "TwoWayView did not receive a notification. Make sure the content of "
                         + "your adapter is not modified from a background thread, but only "
                         + "from the UI thread. [in TwoWayView(" + getId() + ", " + getClass()
                         + ") with Adapter(" + mAdapter.getClass() + ")]");
             }
 
             setSelectedPositionInt(mNextSelectedPosition);
@@ -4269,41 +4275,40 @@ public class TwoWayView extends AdapterV
                         // We saved our state when not in touch mode. (We know this because
                         // mSyncMode is SYNC_SELECTED_POSITION.) Now we are trying to
                         // restore in touch mode. Just leave mSyncPosition as it is (possibly
                         // adjusting if the available range changed) and return.
                         mLayoutMode = LAYOUT_SYNC;
                         mSyncPosition = Math.min(Math.max(0, mSyncPosition), itemCount - 1);
 
                         return;
-                    } else {
-                        // See if we can find a position in the new data with the same
-                        // id as the old selection. This will change mSyncPosition.
-                        newPos = findSyncPosition();
-                        if (newPos >= 0) {
-                            // Found it. Now verify that new selection is still selectable
-                            selectablePos = lookForSelectablePosition(newPos, true);
-                            if (selectablePos == newPos) {
-                                // Same row id is selected
-                                mSyncPosition = newPos;
-
-                                if (mSyncHeight == getHeight()) {
-                                    // If we are at the same height as when we saved state, try
-                                    // to restore the scroll position too.
-                                    mLayoutMode = LAYOUT_SYNC;
-                                } else {
-                                    // We are not the same height as when the selection was saved, so
-                                    // don't try to restore the exact position
-                                    mLayoutMode = LAYOUT_SET_SELECTION;
-                                }
-
-                                // Restore selection
-                                setNextSelectedPositionInt(newPos);
-                                return;
+                    }
+                    // See if we can find a position in the new data with the same
+                    // id as the old selection. This will change mSyncPosition.
+                    newPos = findSyncPosition();
+                    if (newPos >= 0) {
+                        // Found it. Now verify that new selection is still selectable
+                        selectablePos = lookForSelectablePosition(newPos, true);
+                        if (selectablePos == newPos) {
+                            // Same row id is selected
+                            mSyncPosition = newPos;
+
+                            if (mSyncHeight == getHeight()) {
+                                // If we are at the same height as when we saved state, try
+                                // to restore the scroll position too.
+                                mLayoutMode = LAYOUT_SYNC;
+                            } else {
+                                // We are not the same height as when the selection was saved, so
+                                // don't try to restore the exact position
+                                mLayoutMode = LAYOUT_SET_SELECTION;
                             }
+
+                            // Restore selection
+                            setNextSelectedPositionInt(newPos);
+                            return;
                         }
                     }
                     break;
 
                 case SYNC_FIRST_POSITION:
                     // Leave mSyncPosition as it is -- just pin to available range
                     mLayoutMode = LAYOUT_SYNC;
                     mSyncPosition = Math.min(Math.max(0, mSyncPosition), itemCount - 1);
@@ -5782,21 +5787,20 @@ public class TwoWayView extends AdapterV
             if (mTransientStateViews != null) {
                 mTransientStateViews.clear();
             }
         }
 
         View getScrapView(int position) {
             if (mViewTypeCount == 1) {
                 return retrieveFromScrap(mCurrentScrap, position);
-            } else {
-                int whichScrap = mAdapter.getItemViewType(position);
-                if (whichScrap >= 0 && whichScrap < mScrapViews.length) {
-                    return retrieveFromScrap(mScrapViews[whichScrap], position);
-                }
+            }
+            int whichScrap = mAdapter.getItemViewType(position);
+            if (whichScrap >= 0 && whichScrap < mScrapViews.length) {
+                return retrieveFromScrap(mScrapViews[whichScrap], position);
             }
 
             return null;
         }
 
         @TargetApi(14)
         void addScrapView(View scrap, int position) {
             LayoutParams lp = (LayoutParams) scrap.getLayoutParams();
--- a/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/Reporter.java
+++ b/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/Reporter.java
@@ -106,26 +106,30 @@ public final class Reporter extends Broa
             mBundle = (newPosition != null) ? new StumblerBundle(newPosition, mPhoneType) : mBundle;
         }
     }
 
     @Override
     public void onReceive(Context context, Intent intent) {
         String action = intent.getAction();
 
-        if (action.equals(ACTION_FLUSH_TO_BUNDLE)) {
-            flush();
-            return;
-        } else if (action.equals(WifiScanner.ACTION_WIFIS_SCANNED)) {
-            receivedWifiMessage(intent);
-        } else if (action.equals(CellScanner.ACTION_CELLS_SCANNED)) {
-            receivedCellMessage(intent);
-        } else if (action.equals(GPSScanner.ACTION_GPS_UPDATED)) {
-            // Calls reportCollectedLocation, this is the ideal case
-            receivedGpsMessage(intent);
+        switch (action) {
+            case ACTION_FLUSH_TO_BUNDLE:
+                flush();
+                return;
+            case WifiScanner.ACTION_WIFIS_SCANNED:
+                receivedWifiMessage(intent);
+                break;
+            case CellScanner.ACTION_CELLS_SCANNED:
+                receivedCellMessage(intent);
+                break;
+            case GPSScanner.ACTION_GPS_UPDATED:
+                // Calls reportCollectedLocation, this is the ideal case
+                receivedGpsMessage(intent);
+                break;
         }
 
         if (mBundle != null &&
             (mBundle.getWifiData().size() > MAX_WIFIS_PER_LOCATION ||
              mBundle.getCellData().size() > MAX_CELLS_PER_LOCATION)) {
             // no gps for a while, have too much data, just bundle it
             reportCollectedLocation();
         }