Bug 1457255 - 2. Fix Java warnings; r=me
☠☠ backed out by 258fa1eb49c9 ☠ ☠
authorJim Chen <nchen@mozilla.com>
Tue, 01 May 2018 00:22:54 -0400
changeset 416419 a49833bfd519d024618c7c7f1c10c27b63474166
parent 416418 4eccde5dfbef9f3c2eb8e274f5a3c55514664d03
child 416420 524a0f9fb9788b5fc7c7ed3aefe41a981bb546f3
push id33926
push userapavel@mozilla.com
push dateTue, 01 May 2018 10:13:46 +0000
treeherdermozilla-central@d2a4720d1c33 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1457255
milestone61.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 1457255 - 2. Fix Java warnings; r=me Fix all Java warnings in the Android codebase except deprecation and serial warnings, and warnings in third-party code. There is one required change to exoplayer2 code under thirdparty, because that code is included directly in the geckoview project, instead of the thirdparty project. I think I'll just make a pull-request to upstream the change, instead of separating exoplayer2 into a gv-thirdparty project.
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/Tabs.java
mobile/android/base/java/org/mozilla/gecko/activitystream/ActivityStreamTelemetry.java
mobile/android/base/java/org/mozilla/gecko/db/BrowserProvider.java
mobile/android/base/java/org/mozilla/gecko/db/TabsProvider.java
mobile/android/base/java/org/mozilla/gecko/dlc/BaseAction.java
mobile/android/base/java/org/mozilla/gecko/dlc/DownloadAction.java
mobile/android/base/java/org/mozilla/gecko/tabs/TabStrip.java
mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/PanZoomController.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSessionSettings.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionAccessibility.java
mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java
mobile/android/geckoview_example/src/androidTest/java/org/mozilla/geckoview_example/GeckoViewActivityTest.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/BaseRobocopTest.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/MediaPlaybackTest.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/SessionTest.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/StringHelper.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/helpers/WaitHelper.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAudioFocus.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -443,16 +443,17 @@ public class BrowserApp extends GeckoApp
             view = TabsPanel.createTabsLayout(context, attrs);
         } else {
             view = super.onCreateView(name, context, attrs);
         }
         return view;
     }
 
     @Override
+    @SuppressWarnings("fallthrough")
     public void onTabChanged(Tab tab, TabEvents msg, String data) {
         if (!mInitialized) {
             super.onTabChanged(tab, msg, data);
             return;
         }
 
         if (tab == null) {
             // Only RESTORED is allowed a null tab: it's the only event that
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -824,16 +824,18 @@ public class Tabs implements BundleEvent
             // for ADDED/CLOSED events.
             case SELECTED:
                 if (mGeckoView != null) {
                     final int color = getTabColor(tab);
                     mGeckoView.getSession().getCompositorController().setClearColor(color);
                     mGeckoView.coverUntilFirstPaint(color);
                 }
                 queuePersistAllTabs();
+                tab.onChange();
+                break;
             case UNSELECTED:
                 tab.onChange();
                 break;
             default:
                 break;
         }
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/ActivityStreamTelemetry.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/ActivityStreamTelemetry.java
@@ -212,17 +212,17 @@ public class ActivityStreamTelemetry {
                     case BrowserContract.TopSites.TYPE_SUGGESTED:
                         this.set(Contract.SOURCE_SUBTYPE, Contract.SUBTYPE_SUGGESTED);
                         break;
                     case BrowserContract.TopSites.TYPE_TOP:
                         this.set(Contract.SOURCE_SUBTYPE, Contract.SUBTYPE_TOP);
                         break;
                     // While we also have a "blank" type, it is not used by Activity Stream.
                     case BrowserContract.TopSites.TYPE_BLANK:
-                        throw new IllegalStateException("Unknown top site type :" + (int) topSite.getType());
+                        throw new IllegalStateException("Unknown top site type :" + topSite.getType());
                 }
 
                 return this;
             }
 
             public String build() {
                 return data.toString();
             }
--- a/mobile/android/base/java/org/mozilla/gecko/db/BrowserProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/BrowserProvider.java
@@ -1257,16 +1257,17 @@ public class BrowserProvider extends Sha
         if (cursor != null && context != null) {
             cursor.setNotificationUri(context.getContentResolver(), BrowserContract.AUTHORITY_URI);
         }
 
         return cursor;
     }
 
     @Override
+    @SuppressWarnings("fallthrough")
     public Cursor query(Uri uri, String[] projection, String selection,
             String[] selectionArgs, String sortOrder) {
         final int match = URI_MATCHER.match(uri);
 
         // Handle only queries requiring a writable DB connection here: most queries need only a readable
         // connection, hence we can get a readable DB once, and then handle most queries within a switch.
         // TopSites requires a writable connection (because of the temporary tables it uses), hence
         // we handle that separately, i.e. before retrieving a readable connection.
--- a/mobile/android/base/java/org/mozilla/gecko/db/TabsProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/TabsProvider.java
@@ -219,16 +219,17 @@ public class TabsProvider extends Shared
 
         if (id >= 0)
             return ContentUris.withAppendedId(uri, id);
 
         return null;
     }
 
     @Override
+    @SuppressWarnings("fallthrough")
     public int updateInTransaction(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
         trace("Calling update in transaction on URI: " + uri);
 
         int match = URI_MATCHER.match(uri);
         int updated = 0;
 
         switch (match) {
             case CLIENTS_ID:
--- a/mobile/android/base/java/org/mozilla/gecko/dlc/BaseAction.java
+++ b/mobile/android/base/java/org/mozilla/gecko/dlc/BaseAction.java
@@ -96,17 +96,17 @@ public abstract class BaseAction {
     protected File getDestinationFile(Context context, DownloadContent content)
             throws UnrecoverableDownloadContentException, RecoverableDownloadContentException {
         File destinationDirectory;
         if (content.isFont()) {
             destinationDirectory = new File(context.getApplicationInfo().dataDir, "fonts");
         } else if (content.isHyphenationDictionary()) {
             destinationDirectory = new File(context.getApplicationInfo().dataDir, "hyphenation");
         } else {
-            throw new UnrecoverableDownloadContentException("Can't determine destination for kind: " + (String) content.getKind());
+            throw new UnrecoverableDownloadContentException("Can't determine destination for kind: " + content.getKind());
         }
 
         if (!destinationDirectory.exists() && !destinationDirectory.mkdirs()) {
             throw new RecoverableDownloadContentException(RecoverableDownloadContentException.DISK_IO,
                     "Destination directory does not exist and cannot be created");
         }
 
         return new File(destinationDirectory, content.getFilename());
--- a/mobile/android/base/java/org/mozilla/gecko/dlc/DownloadAction.java
+++ b/mobile/android/base/java/org/mozilla/gecko/dlc/DownloadAction.java
@@ -102,17 +102,17 @@ public class DownloadAction extends Base
                 if (!verify(temporaryFile, content.getDownloadChecksum())) {
                     Log.w(LOGTAG, "Wrong checksum after download, content=" + content.getId());
                     temporaryFile.delete();
                     DownloadContentTelemetry.eventDownloadFailure(content, DownloadContentTelemetry.ERROR_CHECKSUM);
                     continue;
                 }
 
                 if (!content.isAssetArchive()) {
-                    Log.e(LOGTAG, "Downloaded content is not of type 'asset-archive': " + (String) content.getType());
+                    Log.e(LOGTAG, "Downloaded content is not of type 'asset-archive': " + content.getType());
                     temporaryFile.delete();
                     DownloadContentTelemetry.eventDownloadFailure(content, DownloadContentTelemetry.ERROR_LOGIC);
                     continue;
                 }
 
                 extract(temporaryFile, destinationFile, content.getChecksum());
 
                 catalog.markAsDownloaded(content);
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabStrip.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabStrip.java
@@ -134,19 +134,22 @@ public class TabStrip extends ThemedLine
                 case CLOSED:
                     tabStripView.removeTab(tab);
                     if (tabChangedListener != null) {
                         tabChangedListener.onTabChanged();
                     }
                     break;
 
                 case SELECTED:
-                    // Update the selected position, then fall through...
+                    // Update the selected position.
                     tabStripView.selectTab(tab);
                     setPrivateMode(tab.isPrivate());
+                    tabStripView.updateTab(tab);
+                    break;
+
                 case UNSELECTED:
                     // We just need to update the style for the unselected tab...
                 case TITLE:
                 case FAVICON:
                 case RECORDING_CHANGE:
                 case AUDIO_PLAYING_CHANGE:
                     tabStripView.updateTab(tab);
                     break;
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
@@ -430,16 +430,17 @@ public abstract class BrowserToolbar ext
         if (!isEditing()) {
             throw new IllegalStateException("Expected to be editing");
         }
 
         urlEditLayout.restoreTabEditingState(editingState);
     }
 
     @Override
+    @SuppressWarnings("fallthrough")
     public void onTabChanged(@Nullable Tab tab, Tabs.TabEvents msg, String data) {
         Log.d(LOGTAG, "onTabChanged: " + msg);
         final Tabs tabs = Tabs.getInstance();
 
         // These conditions are split into three phases:
         // * Always do first
         // * Handling specific to the selected tab
         // * Always do afterwards.
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
@@ -357,16 +357,21 @@ public class GeckoSessionTestRule extend
                         session == otherCall.session) &&
                         methodsEqual(method, ((MethodCall) other).method);
             } else if (other instanceof Method) {
                 return methodsEqual(method, (Method) other);
             }
             return false;
         }
 
+        @Override
+        public int hashCode() {
+            return method.hashCode();
+        }
+
         /* package */ int getOrder() {
             if (requirement == null || currentCount == 0) {
                 return 0;
             }
 
             final int[] order = requirement.order;
             if (order == null || order.length == 0) {
                 return 0;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -650,16 +650,17 @@ public class GeckoAppShell
     public static HapticFeedbackDelegate getHapticFeedbackDelegate() {
         return sHapticFeedbackDelegate;
     }
 
     public static void setHapticFeedbackDelegate(final HapticFeedbackDelegate delegate) {
         sHapticFeedbackDelegate = (delegate != null) ? delegate : DEFAULT_LISTENERS;
     }
 
+    @SuppressWarnings("fallthrough")
     @WrapForJNI(calledFrom = "gecko")
     private static void enableSensor(int aSensortype) {
         final SensorManager sm = (SensorManager)
             getApplicationContext().getSystemService(Context.SENSOR_SERVICE);
 
         switch (aSensortype) {
         case GeckoHalDefines.SENSOR_GAME_ROTATION_VECTOR:
             if (gGameRotationVectorSensor == null) {
@@ -761,16 +762,17 @@ public class GeckoAppShell
             break;
 
         default:
             Log.w(LOGTAG, "Error! Can't enable unknown SENSOR type " +
                   aSensortype);
         }
     }
 
+    @SuppressWarnings("fallthrough")
     @WrapForJNI(calledFrom = "gecko")
     private static void disableSensor(int aSensortype) {
         final SensorManager sm = (SensorManager)
             getApplicationContext().getSystemService(Context.SENSOR_SERVICE);
 
         switch (aSensortype) {
         case GeckoHalDefines.SENSOR_GAME_ROTATION_VECTOR:
             if (gGameRotationVectorSensor != null) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/PanZoomController.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/PanZoomController.java
@@ -48,17 +48,17 @@ public final class PanZoomController ext
 
     @WrapForJNI(calledFrom = "ui")
     private native boolean handleMouseEvent(
             int action, long time, int metaState,
             float x, float y, int buttons);
 
     private boolean handleMotionEvent(MotionEvent event) {
         if (!mAttached) {
-            mQueuedEvents.add(new Pair(EVENT_SOURCE_MOTION, event));
+            mQueuedEvents.add(new Pair<>(EVENT_SOURCE_MOTION, event));
             return false;
         }
 
         final int action = event.getActionMasked();
         final int count = event.getPointerCount();
 
         if (action == MotionEvent.ACTION_DOWN) {
             mLastDownTime = event.getDownTime();
@@ -93,17 +93,17 @@ public final class PanZoomController ext
 
         return handleMotionEvent(action, event.getActionIndex(), event.getEventTime(),
                 event.getMetaState(), pointerId, x, y, orientation, pressure,
                 toolMajor, toolMinor);
     }
 
     private boolean handleScrollEvent(MotionEvent event) {
         if (!mAttached) {
-            mQueuedEvents.add(new Pair(EVENT_SOURCE_SCROLL, event));
+            mQueuedEvents.add(new Pair<>(EVENT_SOURCE_SCROLL, event));
             return false;
         }
 
         final int count = event.getPointerCount();
 
         if (count <= 0) {
             return false;
         }
@@ -122,17 +122,17 @@ public final class PanZoomController ext
                               mPointerScrollFactor;
 
         return handleScrollEvent(event.getEventTime(), event.getMetaState(), x, y,
                                  hScroll, vScroll);
     }
 
     private boolean handleMouseEvent(MotionEvent event) {
         if (!mAttached) {
-            mQueuedEvents.add(new Pair(EVENT_SOURCE_MOUSE, event));
+            mQueuedEvents.add(new Pair<>(EVENT_SOURCE_MOUSE, event));
             return false;
         }
 
         final int count = event.getPointerCount();
 
         if (count <= 0) {
             return false;
         }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSessionSettings.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSessionSettings.java
@@ -175,16 +175,21 @@ public final class GeckoSessionSettings 
     }
 
     @Override
     public boolean equals(final Object other) {
         return other instanceof GeckoSessionSettings &&
                 mBundle.equals(((GeckoSessionSettings) other).mBundle);
     }
 
+    @Override
+    public int hashCode() {
+        return mBundle.hashCode();
+    }
+
     private <T> boolean valueChangedLocked(final Key<T> key, T value) {
         if (key.initOnly && mSession != null && mSession.isOpen()) {
             throw new IllegalStateException("Read-only property");
         } else if (key.values != null && !key.values.contains(value)) {
             throw new IllegalArgumentException("Invalid value");
         }
 
         final Object old = mBundle.get(key.name);
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionAccessibility.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionAccessibility.java
@@ -164,16 +164,17 @@ public class SessionAccessibility {
                             data.putBoolean("gainFocus", action == AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
                             mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityViewFocused", data);
                             return true;
                         }
 
                         return mView.performAccessibilityAction(action, arguments);
                     }
 
+                    @SuppressWarnings("fallthrough")
                     private boolean performContentAction(int action, Bundle arguments) {
                         final GeckoBundle data;
                         switch (action) {
                         case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS:
                             final AccessibilityEvent event = obtainEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED, VIRTUAL_CONTENT_ID);
                             ((ViewParent) mView).requestSendAccessibilityEvent(mView, event);
                             return true;
                         case AccessibilityNodeInfo.ACTION_CLICK:
@@ -187,16 +188,17 @@ public class SessionAccessibility {
                             return true;
                         case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
                             mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityScrollBackward", null);
                             return true;
                         case AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT:
                             if (mLastItem) {
                                 return false;
                             }
+                            // fall-through
                         case AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT:
                             if (arguments != null) {
                                 data = new GeckoBundle(1);
                                 data.putString("rule", arguments.getString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING));
                             } else {
                                 data = null;
                             }
                             mSession.getEventDispatcher().dispatch(action == AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT ?
--- a/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java
+++ b/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java
@@ -71,16 +71,17 @@ import java.io.IOException;
       totalGranules = firstPayloadPageGranulePosition;
       state = STATE_IDLE;
     } else {
       state = STATE_SEEK_TO_END;
     }
   }
 
   @Override
+  @SuppressWarnings("fallthrough")
   public long read(ExtractorInput input) throws IOException, InterruptedException {
     switch (state) {
       case STATE_IDLE:
         return -1;
       case STATE_SEEK_TO_END:
         positionBeforeSeekToEnd = input.getPosition();
         state = STATE_READ_LAST_PAGE;
         // Seek to the end just before the last page of stream to get the duration.
--- a/mobile/android/geckoview_example/src/androidTest/java/org/mozilla/geckoview_example/GeckoViewActivityTest.java
+++ b/mobile/android/geckoview_example/src/androidTest/java/org/mozilla/geckoview_example/GeckoViewActivityTest.java
@@ -17,16 +17,16 @@ import static android.support.test.espre
 import static android.support.test.espresso.assertion.ViewAssertions.matches;
 import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
 import static android.support.test.espresso.matcher.ViewMatchers.withId;
 
 @RunWith(AndroidJUnit4.class)
 public class GeckoViewActivityTest {
 
     @Rule
-    public ActivityTestRule<GeckoViewActivity> mActivityRule = new ActivityTestRule(GeckoViewActivity.class);
+    public ActivityTestRule<GeckoViewActivity> mActivityRule = new ActivityTestRule<>(GeckoViewActivity.class);
 
     @Test
     public void testA() throws InterruptedException {
         onView(withId(R.id.gecko_view))
                 .check(matches(isDisplayed()));
     }
 }
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/BaseRobocopTest.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/BaseRobocopTest.java
@@ -244,17 +244,17 @@ public abstract class BaseRobocopTest ex
     public void throwIfHttpGetFails() {
         if (getTestType() == Type.TALOS) {
             return;
         }
 
         // rawURL to test fetching from. This should be a raw (IP) URL, not an alias
         // (like mochi.test). We can't (easily) test fetching from the aliases, since
         // those are managed by Fennec's proxy settings.
-        final String rawUrl = ((String) mConfig.get("rawhost")).replaceAll("(/$)", "");
+        final String rawUrl = mConfig.get("rawhost").replaceAll("(/$)", "");
 
         HttpURLConnection urlConnection = null;
 
         try {
             urlConnection = (HttpURLConnection) new URL(rawUrl).openConnection();
 
             final int statusCode = urlConnection.getResponseCode();
             if (200 != statusCode) {
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/MediaPlaybackTest.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/MediaPlaybackTest.java
@@ -270,26 +270,26 @@ abstract class MediaPlaybackTest extends
         }
     }
 
     protected final AudioFocusAgent getAudioFocusAgent() {
         return AudioFocusAgent.getInstance();
     }
 
     protected final void requestAudioFocus() {
-        getAudioFocusAgent().notifyStartedPlaying();
+        AudioFocusAgent.notifyStartedPlaying();
         if (getAudioFocusAgent().getAudioFocusState() == State.OWN_FOCUS) {
             return;
         }
 
         // Request audio focus might fail, depend on the andriod's audio mode.
         waitForCondition(new Condition() {
             @Override
             public boolean isSatisfied() {
-                getAudioFocusAgent().notifyStartedPlaying();
+                AudioFocusAgent.notifyStartedPlaying();
                 return getAudioFocusAgent().getAudioFocusState() == State.OWN_FOCUS;
             }
         }, MAX_WAIT_MS);
     }
 
     /**
      * The method NotificationManager.getActiveNotifications() is only avaiable
      * after version 23, so we need to check version ensure running the test on
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/SessionTest.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/SessionTest.java
@@ -34,16 +34,17 @@ public abstract class SessionTest extend
     /**
      * A generic session object representing a collection of items that has a
      * selected index.
      */
     protected abstract class SessionObject<T> {
         private final int mIndex;
         private final T[] mItems;
 
+        @SuppressWarnings({"unchecked", "varargs"})
         public SessionObject(int index, T... items) {
             mIndex = index;
             mItems = items;
         }
 
         public int getIndex() {
             return mIndex;
         }
@@ -132,17 +133,17 @@ public abstract class SessionTest extend
 
         /**
          * Callback executed for each forward step of the walk.
          */
         public void goForward() {}
     }
 
     protected Session createTestSession(int selectedTabIndex) {
-        PageInfo home = new PageInfo(StringHelper.STATIC_ABOUT_HOME_URL);
+        PageInfo home = new PageInfo(mStringHelper.STATIC_ABOUT_HOME_URL);
         PageInfo page1 = new PageInfo("page1");
         PageInfo page2 = new PageInfo("page2");
         PageInfo page3 = new PageInfo("page3");
         PageInfo page4 = new PageInfo("page4");
         PageInfo page5 = new PageInfo("page5");
         PageInfo page6 = new PageInfo("page6");
 
         SessionTab tab1 = new SessionTab(0, home, page1, page2);
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/StringHelper.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/StringHelper.java
@@ -8,51 +8,51 @@ package org.mozilla.gecko.tests;
 import android.content.res.Resources;
 
 import org.mozilla.gecko.R;
 
 public class StringHelper {
     private static StringHelper instance;
 
     // This needs to be accessed statically, before an instance of StringHelper can be created.
-    public static final String STATIC_ABOUT_HOME_URL = "about:home";
+    public final String STATIC_ABOUT_HOME_URL = "about:home";
 
     public final String OK;
     public final String CANCEL;
     public final String CLEAR;
 
     // Note: DEFAULT_BOOKMARKS_TITLES.length == DEFAULT_BOOKMARKS_URLS.length
     public final String[] DEFAULT_BOOKMARKS_TITLES;
     public final String[] DEFAULT_BOOKMARKS_URLS;
     public final int DEFAULT_BOOKMARKS_COUNT;
 
     // About pages
-    public static final String ABOUT_BLANK_URL = "about:blank";
+    public final String ABOUT_BLANK_URL = "about:blank";
     public final String ABOUT_FIREFOX_URL;
-    public static final String ABOUT_HOME_URL = "about:home";
-    public static final String ABOUT_ADDONS_URL = "about:addons";
-    public static final String ABOUT_SCHEME = "about:";
+    public final String ABOUT_HOME_URL = "about:home";
+    public final String ABOUT_ADDONS_URL = "about:addons";
+    public final String ABOUT_SCHEME = "about:";
 
     // About pages' titles
-    public static final String ABOUT_HOME_TITLE = "";
+    public final String ABOUT_HOME_TITLE = "";
 
     // Context Menu item strings
-    public static final String CONTEXT_MENU_BOOKMARK_LINK = "Bookmark Link";
-    public static final String CONTEXT_MENU_OPEN_LINK_IN_NEW_TAB = "Open Link in New Tab";
+    public final String CONTEXT_MENU_BOOKMARK_LINK = "Bookmark Link";
+    public final String CONTEXT_MENU_OPEN_LINK_IN_NEW_TAB = "Open Link in New Tab";
     public final String CONTEXT_MENU_OPEN_IN_NEW_TAB;
-    public static final String CONTEXT_MENU_OPEN_LINK_IN_PRIVATE_TAB = "Open Link in Private Tab";
+    public final String CONTEXT_MENU_OPEN_LINK_IN_PRIVATE_TAB = "Open Link in Private Tab";
     public final String CONTEXT_MENU_OPEN_IN_PRIVATE_TAB;
-    public static final String CONTEXT_MENU_COPY_LINK = "Copy Link";
-    public static final String CONTEXT_MENU_SHARE_LINK = "Share Link";
+    public final String CONTEXT_MENU_COPY_LINK = "Copy Link";
+    public final String CONTEXT_MENU_SHARE_LINK = "Share Link";
     public final String CONTEXT_MENU_EDIT;
     public final String CONTEXT_MENU_SHARE;
     public final String CONTEXT_MENU_REMOVE;
     public final String CONTEXT_MENU_COPY_ADDRESS;
     public final String CONTEXT_MENU_EDIT_SITE_SETTINGS;
-    public static final String CONTEXT_MENU_SITE_SETTINGS_SAVE_PASSWORD = "Save Password";
+    public final String CONTEXT_MENU_SITE_SETTINGS_SAVE_PASSWORD = "Save Password";
     public final String CONTEXT_MENU_ADD_TO_HOME_SCREEN;
     public final String CONTEXT_MENU_PIN_SITE;
     public final String CONTEXT_MENU_UNPIN_SITE;
 
     // Context Menu menu items
     public final String[] CONTEXT_MENU_ITEMS_IN_PRIVATE_TAB;
 
     public final String[] CONTEXT_MENU_ITEMS_IN_NORMAL_TAB;
@@ -60,71 +60,71 @@ public class StringHelper {
     public final String[] BOOKMARK_CONTEXT_MENU_ITEMS;
 
     public final String[] CONTEXT_MENU_ITEMS_IN_URL_BAR;
 
     public final String TITLE_PLACE_HOLDER;
 
     // Robocop page urls
     // Note: please use getAbsoluteUrl(String url) on each robocop url to get the correct url
-    public static final String ROBOCOP_BIG_LINK_URL = "/robocop/robocop_big_link.html";
-    public static final String ROBOCOP_BIG_MAILTO_URL = "/robocop/robocop_big_mailto.html";
-    public static final String ROBOCOP_BLANK_PAGE_01_URL = "/robocop/robocop_blank_01.html";
-    public static final String ROBOCOP_BLANK_PAGE_02_URL = "/robocop/robocop_blank_02.html";
-    public static final String ROBOCOP_BLANK_PAGE_03_URL = "/robocop/robocop_blank_03.html";
-    public static final String ROBOCOP_BLANK_PAGE_04_URL = "/robocop/robocop_blank_04.html";
-    public static final String ROBOCOP_BLANK_PAGE_05_URL = "/robocop/robocop_blank_05.html";
-    public static final String ROBOCOP_BOXES_URL = "/robocop/robocop_boxes.html";
-    public static final String ROBOCOP_GEOLOCATION_URL = "/robocop/robocop_geolocation.html";
-    public static final String ROBOCOP_LOGIN_01_URL= "/robocop/robocop_login_01.html";
-    public static final String ROBOCOP_LOGIN_02_URL= "/robocop/robocop_login_02.html";
-    public static final String ROBOCOP_POPUP_URL = "/robocop/robocop_popup.html";
-    public static final String ROBOCOP_OFFLINE_STORAGE_URL = "/robocop/robocop_offline_storage.html";
-    public static final String ROBOCOP_PICTURE_LINK_URL = "/robocop/robocop_picture_link.html";
-    public static final String ROBOCOP_SEARCH_URL = "/robocop/robocop_search.html";
-    public static final String ROBOCOP_TEXT_PAGE_URL = "/robocop/robocop_text_page.html";
-    public static final String ROBOCOP_INPUT_URL = "/robocop/robocop_input.html";
-    public static final String ROBOCOP_READER_MODE_BASIC_ARTICLE = "/robocop/reader_mode_pages/basic_article.html";
-    public static final String ROBOCOP_LINK_TO_SLOW_LOADING = "/robocop/robocop_link_to_slow_loading.html";
-    public static final String ROBOCOP_MEDIA_PLAYBACK_JS_URL = "/robocop/robocop_media_playback_js.html";
-    public static final String ROBOCOP_MEDIA_PLAYBACK_LOOP_URL = "/robocop/robocop_media_playback_loop.html";
+    public final String ROBOCOP_BIG_LINK_URL = "/robocop/robocop_big_link.html";
+    public final String ROBOCOP_BIG_MAILTO_URL = "/robocop/robocop_big_mailto.html";
+    public final String ROBOCOP_BLANK_PAGE_01_URL = "/robocop/robocop_blank_01.html";
+    public final String ROBOCOP_BLANK_PAGE_02_URL = "/robocop/robocop_blank_02.html";
+    public final String ROBOCOP_BLANK_PAGE_03_URL = "/robocop/robocop_blank_03.html";
+    public final String ROBOCOP_BLANK_PAGE_04_URL = "/robocop/robocop_blank_04.html";
+    public final String ROBOCOP_BLANK_PAGE_05_URL = "/robocop/robocop_blank_05.html";
+    public final String ROBOCOP_BOXES_URL = "/robocop/robocop_boxes.html";
+    public final String ROBOCOP_GEOLOCATION_URL = "/robocop/robocop_geolocation.html";
+    public final String ROBOCOP_LOGIN_01_URL= "/robocop/robocop_login_01.html";
+    public final String ROBOCOP_LOGIN_02_URL= "/robocop/robocop_login_02.html";
+    public final String ROBOCOP_POPUP_URL = "/robocop/robocop_popup.html";
+    public final String ROBOCOP_OFFLINE_STORAGE_URL = "/robocop/robocop_offline_storage.html";
+    public final String ROBOCOP_PICTURE_LINK_URL = "/robocop/robocop_picture_link.html";
+    public final String ROBOCOP_SEARCH_URL = "/robocop/robocop_search.html";
+    public final String ROBOCOP_TEXT_PAGE_URL = "/robocop/robocop_text_page.html";
+    public final String ROBOCOP_INPUT_URL = "/robocop/robocop_input.html";
+    public final String ROBOCOP_READER_MODE_BASIC_ARTICLE = "/robocop/reader_mode_pages/basic_article.html";
+    public final String ROBOCOP_LINK_TO_SLOW_LOADING = "/robocop/robocop_link_to_slow_loading.html";
+    public final String ROBOCOP_MEDIA_PLAYBACK_JS_URL = "/robocop/robocop_media_playback_js.html";
+    public final String ROBOCOP_MEDIA_PLAYBACK_LOOP_URL = "/robocop/robocop_media_playback_loop.html";
 
-    private static final String ROBOCOP_JS_HARNESS_URL = "/robocop/robocop_javascript.html";
+    private final String ROBOCOP_JS_HARNESS_URL = "/robocop/robocop_javascript.html";
 
     // Robocop page images
-    public static final String ROBOCOP_PICTURE_URL = "/robocop/Firefox.jpg";
+    public final String ROBOCOP_PICTURE_URL = "/robocop/Firefox.jpg";
 
     // Robocop page titles
-    public static final String ROBOCOP_BIG_LINK_TITLE = "Big Link";
-    public static final String ROBOCOP_BIG_MAILTO_TITLE = "Big Mailto";
-    public static final String ROBOCOP_BLANK_PAGE_01_TITLE = "Browser Blank Page 01";
-    public static final String ROBOCOP_BLANK_PAGE_02_TITLE = "Browser Blank Page 02";
-    public static final String ROBOCOP_GEOLOCATION_TITLE = "Geolocation Test Page";
-    public static final String ROBOCOP_PICTURE_LINK_TITLE = "Picture Link";
-    public static final String ROBOCOP_SEARCH_TITLE = "Robocop Search Engine";
+    public final String ROBOCOP_BIG_LINK_TITLE = "Big Link";
+    public final String ROBOCOP_BIG_MAILTO_TITLE = "Big Mailto";
+    public final String ROBOCOP_BLANK_PAGE_01_TITLE = "Browser Blank Page 01";
+    public final String ROBOCOP_BLANK_PAGE_02_TITLE = "Browser Blank Page 02";
+    public final String ROBOCOP_GEOLOCATION_TITLE = "Geolocation Test Page";
+    public final String ROBOCOP_PICTURE_LINK_TITLE = "Picture Link";
+    public final String ROBOCOP_SEARCH_TITLE = "Robocop Search Engine";
 
     // Distribution tile labels
-    public static final String DISTRIBUTION1_LABEL = "Distribution 1";
-    public static final String DISTRIBUTION2_LABEL = "Distribution 2";
+    public final String DISTRIBUTION1_LABEL = "Distribution 1";
+    public final String DISTRIBUTION2_LABEL = "Distribution 2";
 
     // Settings menu strings
     public final String GENERAL_SECTION_LABEL;
     public final String SEARCH_SECTION_LABEL;
     public final String PRIVACY_SECTION_LABEL;
     public final String ACCESSIBILITY_SECTION_LABEL;
     public final String NOTIFICATIONS_SECTION_LABEL;
     public final String ADVANCED_SECTION_LABEL;
     public final String CLEAR_PRIVATE_DATA_SECTION_LABEL;
     public final String DEFAULT_BROWSER_SECTION_LABEL;
     public final String MOZILLA_SECTION_LABEL;
 
     // Mozilla
-    public static final String BRAND_NAME = "(Fennec|Nightly|Firefox Aurora|Firefox Beta|Firefox)";
-    public static final String ABOUT_LABEL = "About " + BRAND_NAME ;
-    public static final String LOCATION_SERVICES_LABEL = "Mozilla Location Service";
+    public final String BRAND_NAME = "(Fennec|Nightly|Firefox Aurora|Firefox Beta|Firefox)";
+    public final String ABOUT_LABEL = "About " + BRAND_NAME ;
+    public final String LOCATION_SERVICES_LABEL = "Mozilla Location Service";
 
     // Labels for the about:home tabs
     public final String HISTORY_LABEL;
     public final String TOP_SITES_LABEL;
     public final String BOOKMARKS_LABEL;
     public final String TODAY_LABEL;
 
     // Desktop default bookmarks folders
@@ -150,49 +150,49 @@ public class StringHelper {
     public final String TAB_QUEUE_LABEL;
     public final String TAB_QUEUE_SUMMARY;
 
     // Android 3.0+
     public final String TOOLS_LABEL;
     public final String PAGE_LABEL;
 
     // Android 2.3 and lower only
-    public static final String MORE_LABEL = "More";
+    public final String MORE_LABEL = "More";
     public final String RELOAD_LABEL;
     public final String FORWARD_LABEL;
     public final String BOOKMARK_LABEL;
 
     // Bookmark Toast Notification
     public final String BOOKMARK_ADDED_LABEL;
     public final String BOOKMARK_REMOVED_LABEL;
     public final String BOOKMARK_UPDATED_LABEL;
     public final String BOOKMARK_OPTIONS_LABEL;
 
     // Edit Bookmark screen
     public final String EDIT_BOOKMARK;
 
     // Strings used in doorhanger messages and buttons
-    public static final String GEO_MESSAGE = "Share your location with";
+    public final String GEO_MESSAGE = "Share your location with";
     public final String GEO_ALLOW;
-    public static final String GEO_DENY = "Don't share";
+    public final String GEO_DENY = "Don't share";
 
-    public static final String OFFLINE_MESSAGE = "to store data on your device for offline use";
-    public static final String OFFLINE_ALLOW = "Allow";
-    public static final String OFFLINE_DENY = "Don't allow";
+    public final String OFFLINE_MESSAGE = "to store data on your device for offline use";
+    public final String OFFLINE_ALLOW = "Allow";
+    public final String OFFLINE_DENY = "Don't allow";
 
-    public static final String LOGIN_MESSAGE = "Would you like " + BRAND_NAME + " to remember this login?";
-    public static final String LOGIN_ALLOW = "Remember";
-    public static final String LOGIN_DENY = "Never";
+    public final String LOGIN_MESSAGE = "Would you like " + BRAND_NAME + " to remember this login?";
+    public final String LOGIN_ALLOW = "Remember";
+    public final String LOGIN_DENY = "Never";
 
-    public static final String POPUP_MESSAGE = "prevented this site from opening";
+    public final String POPUP_MESSAGE = "prevented this site from opening";
     public final String POPUP_ALLOW;
-    public static final String POPUP_DENY = "Don't show";
+    public final String POPUP_DENY = "Don't show";
 
     // Strings used as content description, e.g. for ImageButtons
-    public static final String CONTENT_DESCRIPTION_READER_MODE_BUTTON = "Enter Reader View";
+    public final String CONTENT_DESCRIPTION_READER_MODE_BUTTON = "Enter Reader View";
 
     // Home Panel Settings
     public final String CUSTOMIZE_HOME;
     public final String ENABLED;
     public final String HISTORY;
     public final String PANELS;
 
     // General Settings
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/helpers/WaitHelper.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/helpers/WaitHelper.java
@@ -77,34 +77,35 @@ public final class WaitHelper {
      * duration; will throw an AssertionError if the duration is elapsed and the callable has not
      * returned a non-null object.
      *
      * @return the value returned by the Callable. Or null if the duration has elapsed.
      */
     public static <V> V waitFor(String message, final Callable<V> callable, int waitMillis) {
         sContext.dumpLog("WaitHelper", "Waiting for " + message + " with timeout " + waitMillis + ".");
 
-        final Object[] value = new Object[1];
+        @SuppressWarnings("unchecked")
+        final V[] value = (V[]) new Object[1];
 
         Condition condition = new Condition() {
             @Override
             public boolean isSatisfied() {
                 try {
                     V result = callable.call();
                     value[0] = result;
                     return result != null;
                 } catch (Exception e) {
                     return false;
                 }
             }
         };
 
         sSolo.waitForCondition(condition, waitMillis);
 
-        return (V) value[0];
+        return value[0];
     }
 
     /**
      * Waits for the Gecko event declaring the page has loaded. Takes in and runs a Runnable
      * that will perform the action that will cause the page to load.
      */
     public static void waitForPageLoad(final Runnable initiatingAction) {
         fAssertNotNull("initiatingAction is not null", initiatingAction);
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAudioFocus.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAudioFocus.java
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.tests;
 
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
+import org.mozilla.gecko.media.AudioFocusAgent;
 import org.mozilla.gecko.media.AudioFocusAgent.State;
 
 import android.media.AudioManager;
 
 public class testAudioFocus extends MediaPlaybackTest {
     public void testAudioFocus() {
         info("- wait for gecko ready -");
         blockForGeckoReady();
@@ -78,17 +79,17 @@ public class testAudioFocus extends Medi
 
         info("- request audio focus -");
         requestAudioFocus();
         mAsserter.is(getAudioFocusAgent().getAudioFocusState(),
                      State.OWN_FOCUS,
                      "Should own audio focus.");
 
         info("- abandon audio focus -");
-        getAudioFocusAgent().notifyStoppedPlaying();
+        AudioFocusAgent.notifyStoppedPlaying();
         mAsserter.is(getAudioFocusAgent().getAudioFocusState(),
                      State.LOST_FOCUS,
                      "Should lose audio focus.");
     }
 
     private void testAudioFocusChanged() {
         info("- check audio focus in the beginning -");
         mAsserter.is(getAudioFocusAgent().getAudioFocusState(),