Fixing linting issues

This commit is contained in:
Joe Bowser 2017-04-04 13:38:40 -07:00
parent ffadf5dd51
commit 7b17abc555
6 changed files with 22 additions and 0 deletions

View File

@ -319,6 +319,7 @@ public class CordovaActivity extends Activity {
/** /**
* Called when view focus is changed * Called when view focus is changed
*/ */
@SuppressLint("InlinedApi")
@Override @Override
public void onWindowFocusChanged(boolean hasFocus) { public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus); super.onWindowFocusChanged(hasFocus);

View File

@ -18,6 +18,8 @@
*/ */
package org.apache.cordova; package org.apache.cordova;
import android.annotation.SuppressLint;
import java.security.SecureRandom; import java.security.SecureRandom;
import org.json.JSONArray; import org.json.JSONArray;
@ -110,6 +112,9 @@ public class CordovaBridge {
} }
/** Called by cordova.js to initialize the bridge. */ /** 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() { int generateBridgeSecret() {
SecureRandom randGen = new SecureRandom(); SecureRandom randGen = new SecureRandom();
expectedBridgeSecret = randGen.nextInt(Integer.MAX_VALUE); expectedBridgeSecret = randGen.nextInt(Integer.MAX_VALUE);

View File

@ -22,10 +22,12 @@ import java.security.Principal;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import android.annotation.SuppressLint;
import android.webkit.ClientCertRequest; import android.webkit.ClientCertRequest;
/** /**
* Implementation of the ICordovaClientCertRequest for Android WebView. * Implementation of the ICordovaClientCertRequest for Android WebView.
*
*/ */
public class CordovaClientCertRequest implements ICordovaClientCertRequest { public class CordovaClientCertRequest implements ICordovaClientCertRequest {
@ -38,6 +40,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
/** /**
* Cancel this request * Cancel this request
*/ */
@SuppressLint("NewApi")
public void cancel() public void cancel()
{ {
request.cancel(); request.cancel();
@ -46,6 +49,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
/* /*
* Returns the host name of the server requesting the certificate. * Returns the host name of the server requesting the certificate.
*/ */
@SuppressLint("NewApi")
public String getHost() public String getHost()
{ {
return request.getHost(); return request.getHost();
@ -54,6 +58,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
/* /*
* Returns the acceptable types of asymmetric keys (can be null). * Returns the acceptable types of asymmetric keys (can be null).
*/ */
@SuppressLint("NewApi")
public String[] getKeyTypes() public String[] getKeyTypes()
{ {
return request.getKeyTypes(); return request.getKeyTypes();
@ -62,6 +67,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
/* /*
* Returns the port number of the server requesting the certificate. * Returns the port number of the server requesting the certificate.
*/ */
@SuppressLint("NewApi")
public int getPort() public int getPort()
{ {
return request.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). * Returns the acceptable certificate issuers for the certificate matching the private key (can be null).
*/ */
@SuppressLint("NewApi")
public Principal[] getPrincipals() public Principal[] getPrincipals()
{ {
return request.getPrincipals(); return request.getPrincipals();
@ -78,6 +85,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
/* /*
* Ignore the request for now. Do not remember user's choice. * Ignore the request for now. Do not remember user's choice.
*/ */
@SuppressLint("NewApi")
public void ignore() public void ignore()
{ {
request.ignore(); request.ignore();
@ -89,6 +97,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
* @param privateKey The privateKey * @param privateKey The privateKey
* @param chain The certificate chain * @param chain The certificate chain
*/ */
@SuppressLint("NewApi")
public void proceed(PrivateKey privateKey, X509Certificate[] chain) public void proceed(PrivateKey privateKey, X509Certificate[] chain)
{ {
request.proceed(privateKey, chain); request.proceed(privateKey, chain);

View File

@ -19,6 +19,7 @@
package org.apache.cordova; package org.apache.cordova;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -221,6 +222,7 @@ public class CordovaInterfaceImpl implements CordovaInterface {
requestPermissions(plugin, requestCode, permissions); requestPermissions(plugin, requestCode, permissions);
} }
@SuppressLint("NewApi")
public void requestPermissions(CordovaPlugin plugin, int requestCode, String [] permissions) { public void requestPermissions(CordovaPlugin plugin, int requestCode, String [] permissions) {
int mappedRequestCode = permissionResultCallbacks.registerCallback(plugin, requestCode); int mappedRequestCode = permissionResultCallbacks.registerCallback(plugin, requestCode);
getActivity().requestPermissions(permissions, mappedRequestCode); getActivity().requestPermissions(permissions, mappedRequestCode);

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.cordova; package org.apache.cordova;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
@ -91,6 +92,7 @@ public class CordovaWebViewImpl implements CordovaWebView {
init(cordova, new ArrayList<PluginEntry>(), new CordovaPreferences()); init(cordova, new ArrayList<PluginEntry>(), new CordovaPreferences());
} }
@SuppressLint("Assert")
@Override @Override
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences) { public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences) {
if (this.cordova != null) { if (this.cordova != null) {

View File

@ -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) { private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) { if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
LOG.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old."); LOG.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");