From 7b17abc5553ca14f69081a2175f787d4a0550f0f Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Tue, 4 Apr 2017 13:38:40 -0700 Subject: [PATCH] Fixing linting issues --- framework/src/org/apache/cordova/CordovaActivity.java | 1 + framework/src/org/apache/cordova/CordovaBridge.java | 5 +++++ .../src/org/apache/cordova/CordovaClientCertRequest.java | 9 +++++++++ .../src/org/apache/cordova/CordovaInterfaceImpl.java | 2 ++ framework/src/org/apache/cordova/CordovaWebViewImpl.java | 2 ++ .../org/apache/cordova/engine/SystemWebViewEngine.java | 3 +++ 6 files changed, 22 insertions(+) diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 85eeb53a..e2ed1cb8 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -319,6 +319,7 @@ public class CordovaActivity extends Activity { /** * Called when view focus is changed */ + @SuppressLint("InlinedApi") @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); diff --git a/framework/src/org/apache/cordova/CordovaBridge.java b/framework/src/org/apache/cordova/CordovaBridge.java index 9459a113..28c407f3 100644 --- a/framework/src/org/apache/cordova/CordovaBridge.java +++ b/framework/src/org/apache/cordova/CordovaBridge.java @@ -18,6 +18,8 @@ */ package org.apache.cordova; +import android.annotation.SuppressLint; + import java.security.SecureRandom; import org.json.JSONArray; @@ -110,6 +112,9 @@ public class CordovaBridge { } /** Called by cordova.js to initialize the bridge. */ + //On old Androids SecureRandom isn't really secure, this is the least of your problems if + //you're running Android 4.3 and below in 2017 + @SuppressLint("TrulyRandom") int generateBridgeSecret() { SecureRandom randGen = new SecureRandom(); expectedBridgeSecret = randGen.nextInt(Integer.MAX_VALUE); diff --git a/framework/src/org/apache/cordova/CordovaClientCertRequest.java b/framework/src/org/apache/cordova/CordovaClientCertRequest.java index 5dd0ecae..ccda0272 100644 --- a/framework/src/org/apache/cordova/CordovaClientCertRequest.java +++ b/framework/src/org/apache/cordova/CordovaClientCertRequest.java @@ -22,10 +22,12 @@ import java.security.Principal; import java.security.PrivateKey; import java.security.cert.X509Certificate; +import android.annotation.SuppressLint; import android.webkit.ClientCertRequest; /** * Implementation of the ICordovaClientCertRequest for Android WebView. + * */ public class CordovaClientCertRequest implements ICordovaClientCertRequest { @@ -38,6 +40,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest { /** * Cancel this request */ + @SuppressLint("NewApi") public void cancel() { request.cancel(); @@ -46,6 +49,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest { /* * Returns the host name of the server requesting the certificate. */ + @SuppressLint("NewApi") public String getHost() { return request.getHost(); @@ -54,6 +58,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest { /* * Returns the acceptable types of asymmetric keys (can be null). */ + @SuppressLint("NewApi") public String[] getKeyTypes() { return request.getKeyTypes(); @@ -62,6 +67,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest { /* * Returns the port number of the server requesting the certificate. */ + @SuppressLint("NewApi") public int getPort() { return request.getPort(); @@ -70,6 +76,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest { /* * Returns the acceptable certificate issuers for the certificate matching the private key (can be null). */ + @SuppressLint("NewApi") public Principal[] getPrincipals() { return request.getPrincipals(); @@ -78,6 +85,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest { /* * Ignore the request for now. Do not remember user's choice. */ + @SuppressLint("NewApi") public void ignore() { request.ignore(); @@ -89,6 +97,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest { * @param privateKey The privateKey * @param chain The certificate chain */ + @SuppressLint("NewApi") public void proceed(PrivateKey privateKey, X509Certificate[] chain) { request.proceed(privateKey, chain); diff --git a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java index 71dcb782..8fdbff5e 100644 --- a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java +++ b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java @@ -19,6 +19,7 @@ package org.apache.cordova; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; @@ -221,6 +222,7 @@ public class CordovaInterfaceImpl implements CordovaInterface { requestPermissions(plugin, requestCode, permissions); } + @SuppressLint("NewApi") public void requestPermissions(CordovaPlugin plugin, int requestCode, String [] permissions) { int mappedRequestCode = permissionResultCallbacks.registerCallback(plugin, requestCode); getActivity().requestPermissions(permissions, mappedRequestCode); diff --git a/framework/src/org/apache/cordova/CordovaWebViewImpl.java b/framework/src/org/apache/cordova/CordovaWebViewImpl.java index 85a0b5f5..fb99c344 100644 --- a/framework/src/org/apache/cordova/CordovaWebViewImpl.java +++ b/framework/src/org/apache/cordova/CordovaWebViewImpl.java @@ -18,6 +18,7 @@ */ package org.apache.cordova; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.net.Uri; @@ -91,6 +92,7 @@ public class CordovaWebViewImpl implements CordovaWebView { init(cordova, new ArrayList(), new CordovaPreferences()); } + @SuppressLint("Assert") @Override public void init(CordovaInterface cordova, List pluginEntries, CordovaPreferences preferences) { if (this.cordova != null) { diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java b/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java index 3be7d940..00f08387 100755 --- a/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java +++ b/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java @@ -255,6 +255,9 @@ public class SystemWebViewEngine implements CordovaWebViewEngine { } } + // Yeah, we know, which is why we makes ure that we don't do this if the bridge is + // below JELLYBEAN_MR1. It'd be great if lint was just a little smarter. + @SuppressLint("AddJavascriptInterface") private static void exposeJsInterface(WebView webView, CordovaBridge bridge) { if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) { LOG.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");