Bug 1359223 - Add geckoview to checkstyle and correct style issues. r?snorp draft
authorMichael Kaply <mozilla@kaply.com>
Mon, 24 Apr 2017 16:06:43 -0500
changeset 567356 dbb507564ea3b69a2ddd346f6f5309e45798031c
parent 567252 62a2d3693579fc77b1c510984ae471a860d03302
child 625621 8df18f4dabf1624d2c433f9231603b34a2da6ad6
push id55544
push usermozilla@kaply.com
push dateMon, 24 Apr 2017 21:16:44 +0000
reviewerssnorp
bugs1359223
milestone55.0a1
Bug 1359223 - Add geckoview to checkstyle and correct style issues. r?snorp MozReview-Commit-ID: AM0bdF8dZQW
mobile/android/app/build.gradle
mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerView.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoProcessManager.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -256,17 +256,17 @@ dependencies {
     androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.5.4'
 }
 
 // TODO: (bug 1261486): This impl is not robust -
 // we just wanted to land something.
 task checkstyle(type: Checkstyle) {
     configFile file("checkstyle.xml")
     // TODO: should use sourceSets from project instead of hard-coded str.
-    source '../base/java/'
+    source = ['../base/java/','../geckoview/src/main/java/']
     // TODO: This ignores our pre-processed resources.
     include '**/*.java'
     // TODO: classpath should probably be something.
     classpath = files()
 }
 
 task syncPreprocessedCode(type: Sync, dependsOn: rootProject.generateCodeAndResources) {
     into("${project.buildDir}/generated/source/preprocessed_code")
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerView.java
@@ -196,17 +196,17 @@ public class LayerView extends FrameLayo
                     LayerView.this.mDrawListeners.clear();
                     disposeNative();
                 }
             });
         }
     }
 
     /* package */ void handleToolbarAnimatorMessage(int message) {
-        switch(message) {
+        switch (message) {
             case STATIC_TOOLBAR_NEEDS_UPDATE:
                 // Send updated toolbar image to compositor.
                 Bitmap bm = mToolbarAnimator.getBitmapOfToolbarChrome();
                 if (bm == null) {
                     break;
                 }
                 final int width = bm.getWidth();
                 final int height = bm.getHeight();
@@ -237,17 +237,17 @@ public class LayerView extends FrameLayo
                 for (DrawListener listener : mDrawListeners) {
                     listener.drawFinished();
                 }
                 break;
             case COMPOSITOR_CONTROLLER_OPEN:
                 mToolbarAnimator.notifyCompositorControllerOpen();
                 break;
             default:
-                Log.e(LOGTAG,"Unhandled Toolbar Animator Message: " + message);
+                Log.e(LOGTAG, "Unhandled Toolbar Animator Message: " + message);
                 break;
         }
     }
 
     private final Compositor mCompositor = new Compositor();
 
     public boolean shouldUseTextureView() {
         // Disable TextureView support for now as it causes panning/zooming
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java
@@ -246,17 +246,17 @@ public final class CodecProxy {
             return false;
         }
         return true;
     }
 
     @WrapForJNI
     public boolean release() {
         mCallbacks.setCodecProxyReleased();
-        synchronized(this) {
+        synchronized (this) {
             if (mRemote == null) {
                 Log.w(LOGTAG, "codec already ended");
                 return true;
             }
             if (DEBUG) { Log.d(LOGTAG, "release " + this); }
 
             if (!mSurfaceOutputs.isEmpty()) {
                 // Flushing output buffers to surface may cause some frames to be skipped and
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoProcessManager.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoProcessManager.java
@@ -54,17 +54,17 @@ public final class GeckoProcessManager e
         }
 
         void prepareToWait() {
             mWait = true;
         }
 
         void waitForChild() {
             ThreadUtils.assertNotOnUiThread();
-            synchronized(this) {
+            synchronized (this) {
                 if (mWait) {
                     try {
                         this.wait(5000); // 5 seconds
                     } catch (final InterruptedException e) {
                         Log.e(LOGTAG, "Interrupted while waiting for child service", e);
                     }
                 }
             }
@@ -82,57 +82,57 @@ public final class GeckoProcessManager e
                 Log.e(LOGTAG, "Failed to link ChildConnection to death of service.", e);
             }
             mChild = IChildProcess.Stub.asInterface(service);
             try {
                 mPid = mChild.getPid();
             } catch (final RemoteException e) {
                 Log.e(LOGTAG, "Failed to get child " + mType + " process PID. Process may have died.", e);
             }
-            synchronized(this) {
+            synchronized (this) {
                 if (mWait) {
                     mWait = false;
                     this.notifyAll();
                 }
             }
         }
 
         @Override
         public void onServiceDisconnected(ComponentName name) {
-            synchronized(INSTANCE.mConnections) {
+            synchronized (INSTANCE.mConnections) {
                 INSTANCE.mConnections.remove(mType);
             }
-            synchronized(this) {
+            synchronized (this) {
                 if (mWait) {
                     mWait = false;
                     this.notifyAll();
                 }
             }
         }
 
         @Override
         public void binderDied() {
-            Log.e(LOGTAG,"Binder died. Attempt to unbind service: " + mType + " " + mPid);
+            Log.e(LOGTAG, "Binder died. Attempt to unbind service: " + mType + " " + mPid);
             try {
                 GeckoAppShell.getApplicationContext().unbindService(this);
             } catch (final java.lang.IllegalArgumentException e) {
-                Log.e(LOGTAG,"Looks like connection was already unbound", e);
+                Log.e(LOGTAG, "Looks like connection was already unbound", e);
             }
         }
     }
 
     SimpleArrayMap<String, ChildConnection> mConnections;
 
     private GeckoProcessManager() {
         mConnections = new SimpleArrayMap<String, ChildConnection>();
     }
 
     public int start(String type, String[] args, int crashFd, int ipcFd) {
         ChildConnection connection = null;
-        synchronized(mConnections) {
+        synchronized (mConnections) {
             connection = mConnections.get(type);
         }
         if (connection != null) {
             Log.w(LOGTAG, "Attempting to start a child process service that is already running. Attempting to kill existing process first");
             connection.prepareToWait();
             try {
                 connection.mChild.stop();
                 connection.waitForChild();
@@ -161,17 +161,17 @@ public final class GeckoProcessManager e
                 crashPfd = ParcelFileDescriptor.fromFd(crashFd);
             }
             ParcelFileDescriptor ipcPfd = ParcelFileDescriptor.fromFd(ipcFd);
             connection.mChild.start(this, args, crashPfd, ipcPfd);
             if (crashPfd != null) {
                 crashPfd.close();
             }
             ipcPfd.close();
-            synchronized(mConnections) {
+            synchronized (mConnections) {
                 mConnections.put(type, connection);
             }
             return connection.mPid;
         } catch (final RemoteException e) {
             Log.e(LOGTAG, "Unable to create child process for: '" + type + "'. Remote Exception:", e);
         } catch (final IOException e) {
             Log.e(LOGTAG, "Unable to create child process for: '" + type + "'. Error creating ParcelFileDescriptor needed to create intent:", e);
         }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java
@@ -106,17 +106,17 @@ public class StringUtils {
 
         if (newURL.startsWith("http://")) {
             newURL = newURL.replace("http://", "");
         } else if (newURL.startsWith("https://") && flags == UrlFlags.STRIP_HTTPS) {
             newURL = newURL.replace("https://", "");
         }
 
         if (newURL.endsWith("/")) {
-            newURL = newURL.substring(0, newURL.length()-1);
+            newURL = newURL.substring(0, newURL.length() - 1);
         }
 
         return newURL;
     }
 
     public static boolean isHttpOrHttps(String url) {
         if (TextUtils.isEmpty(url)) {
             return false;