Fix a bunch of static analysis warnings

This commit is contained in:
Cameron Gutman
2014-10-30 00:21:34 -07:00
parent 419c4c5592
commit e8de7908fd
19 changed files with 52 additions and 52 deletions

View File

@@ -52,7 +52,7 @@ public class AndroidCryptoProvider implements LimelightCryptoProvider {
private RSAPrivateKey key;
private byte[] pemCertBytes;
private static Object globalCryptoLock = new Object();
private static final Object globalCryptoLock = new Object();
static {
// Install the Bouncy Castle provider
@@ -74,7 +74,10 @@ public class AndroidCryptoProvider implements LimelightCryptoProvider {
try {
FileInputStream fin = new FileInputStream(f);
byte[] fileData = new byte[(int) f.length()];
fin.read(fileData);
if (fin.read(fileData) != f.length()) {
// Failed to read
fileData = null;
}
fin.close();
return fileData;
} catch (IOException e) {

View File

@@ -418,7 +418,7 @@ public class ControllerHandler {
// UI thread.
try {
Thread.sleep(ControllerHandler.MINIMUM_BUTTON_DOWN_TIME_MS);
} catch (InterruptedException e) {}
} catch (InterruptedException ignored) {}
}
switch (keyCode) {
@@ -495,7 +495,7 @@ public class ControllerHandler {
try {
Thread.sleep(EMULATED_SELECT_UP_DELAY_MS);
} catch (InterruptedException e) {}
} catch (InterruptedException ignored) {}
}
}
@@ -513,7 +513,7 @@ public class ControllerHandler {
try {
Thread.sleep(EMULATED_SPECIAL_UP_DELAY_MS);
} catch (InterruptedException e) {}
} catch (InterruptedException ignored) {}
}
}

View File

@@ -65,7 +65,7 @@ public class TouchContext {
// do input detection by polling
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
} catch (InterruptedException ignored) {}
// Raise the mouse button
conn.sendMouseButtonUp(buttonIndex);

View File

@@ -158,7 +158,7 @@ public class EvdevHandler {
try {
handlerThread.join();
} catch (InterruptedException e) {}
} catch (InterruptedException ignored) {}
}
public void notifyDeleted() {

View File

@@ -13,7 +13,7 @@ public class EvdevReader {
}
// Requires root to chmod /dev/input/eventX
public static boolean setPermissions(String[] files, int octalPermissions) {
public static boolean setPermissions(String[] files, int octalPermissions) {
ProcessBuilder builder = new ProcessBuilder("su");
try {
@@ -28,6 +28,7 @@ public class EvdevReader {
p.waitFor();
p.destroy();
return true;
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {

View File

@@ -8,11 +8,12 @@ import com.limelight.LimeLog;
import android.os.FileObserver;
@SuppressWarnings("ALL")
public class EvdevWatcher {
private static final String PATH = "/dev/input";
private static final String REQUIRED_FILE_PREFIX = "event";
private HashMap<String, EvdevHandler> handlers = new HashMap<String, EvdevHandler>();
private final HashMap<String, EvdevHandler> handlers = new HashMap<String, EvdevHandler>();
private boolean shutdown = false;
private boolean init = false;
private boolean ungrabbed = false;

View File

@@ -18,6 +18,7 @@ import com.limelight.nvstream.av.video.VideoDecoderRenderer;
import com.limelight.nvstream.av.video.VideoDepacketizer;
import com.limelight.nvstream.av.video.cpu.AvcDecoder;
@SuppressWarnings("EmptyCatchBlock")
public class AndroidCpuDecoderRenderer implements VideoDecoderRenderer {
private Thread rendererThread;

View File

@@ -324,7 +324,7 @@ public class MediaCodecDecoderRenderer implements VideoDecoderRenderer {
rendererThread.interrupt();
try {
rendererThread.join();
} catch (InterruptedException e) { }
} catch (InterruptedException ignored) { }
}
// Stop the decoder
@@ -454,7 +454,6 @@ public class MediaCodecDecoderRenderer implements VideoDecoderRenderer {
timestampUs, codecFlags);
depacketizer.freeDecodeUnit(decodeUnit);
return;
}
@Override

View File

@@ -3,6 +3,7 @@ package com.limelight.binding.video;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
@@ -99,9 +100,7 @@ public class MediaCodecHelper {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
for (MediaCodecInfo info : mcl.getCodecInfos()) {
infoList.add(info);
}
Collections.addAll(infoList, mcl.getCodecInfos());
}
else {
for (int i = 0; i < MediaCodecList.getCodecCount(); i++) {
@@ -112,7 +111,8 @@ public class MediaCodecHelper {
return infoList;
}
public static String dumpDecoders() throws Exception {
@SuppressWarnings("RedundantThrows")
public static String dumpDecoders() throws Exception {
String str = "";
for (MediaCodecInfo codecInfo : getMediaCodecList()) {
// Skip encoders
@@ -203,7 +203,8 @@ public class MediaCodecHelper {
// We declare this method as explicitly throwing Exception
// since some bad decoders can throw IllegalArgumentExceptions unexpectedly
// and we want to be sure all callers are handling this possibility
public static MediaCodecInfo findKnownSafeDecoder() throws Exception {
@SuppressWarnings("RedundantThrows")
public static MediaCodecInfo findKnownSafeDecoder() throws Exception {
for (MediaCodecInfo codecInfo : getMediaCodecList()) {
// Skip encoders
if (codecInfo.isEncoder()) {