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

@@ -1,3 +1,4 @@
import com.android.builder.model.ProductFlavor
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
@@ -33,6 +34,7 @@ android {
sourceSets.main.jni.srcDirs = [] sourceSets.main.jni.srcDirs = []
//noinspection GroovyAssignabilityCheck,GroovyAssignabilityCheck
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') { task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
Properties properties = new Properties() Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream()) properties.load(project.rootProject.file('local.properties').newDataInputStream())

View File

@@ -98,7 +98,7 @@ public class AddComputerManually extends Activity {
try { try {
addThread.join(); addThread.join();
} catch (InterruptedException e) {} } catch (InterruptedException ignored) {}
addThread = null; addThread = null;
} }

View File

@@ -81,7 +81,7 @@ public class AppView extends Activity {
@Override @Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
long id) { long id) {
AppObject app = (AppObject) appListAdapter.getItem(pos); AppObject app = appListAdapter.getItem(pos);
if (app == null || app.app == null) { if (app == null || app.app == null) {
return; return;
} }
@@ -134,7 +134,7 @@ public class AppView extends Activity {
super.onCreateContextMenu(menu, v, menuInfo); super.onCreateContextMenu(menu, v, menuInfo);
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
AppObject selectedApp = (AppObject) appListAdapter.getItem(info.position); AppObject selectedApp = appListAdapter.getItem(info.position);
if (selectedApp == null || selectedApp.app == null) { if (selectedApp == null || selectedApp.app == null) {
return; return;
} }
@@ -159,7 +159,7 @@ public class AppView extends Activity {
@Override @Override
public boolean onContextItemSelected(MenuItem item) { public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
AppObject app = (AppObject) appListAdapter.getItem(info.position); AppObject app = appListAdapter.getItem(info.position);
switch (item.getItemId()) switch (item.getItemId())
{ {
case RESUME_ID: case RESUME_ID:
@@ -221,9 +221,9 @@ public class AppView extends Activity {
// Success case // Success case
return; return;
} catch (GfeHttpResponseException e) { } catch (GfeHttpResponseException ignored) {
} catch (IOException e) { } catch (IOException ignored) {
} catch (XmlPullParserException e) { } catch (XmlPullParserException ignored) {
} finally { } finally {
spinner.dismiss(); spinner.dismiss();
} }

View File

@@ -555,9 +555,9 @@ public class Game extends Activity implements SurfaceHolder.Callback,
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
// ACTION_MOVE is special because it always has actionIndex == 0 // ACTION_MOVE is special because it always has actionIndex == 0
// We'll call the move handlers for all indexes manually // We'll call the move handlers for all indexes manually
for (int i = 0; i < touchContextMap.length; i++) { for (TouchContext aTouchContextMap : touchContextMap) {
touchContextMap[i].touchMoveEvent(eventX, eventY); aTouchContextMap.touchMoveEvent(eventX, eventY);
} }
break; break;
default: default:
return false; return false;
@@ -621,21 +621,15 @@ public class Game extends Activity implements SurfaceHolder.Callback,
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (!handleMotionEvent(event)) { return handleMotionEvent(event) || super.onTouchEvent(event);
return super.onTouchEvent(event);
} }
return true;
}
@Override @Override
public boolean onGenericMotionEvent(MotionEvent event) { public boolean onGenericMotionEvent(MotionEvent event) {
if (!handleMotionEvent(event)) { return handleMotionEvent(event) || super.onGenericMotionEvent(event);
return super.onGenericMotionEvent(event);
} }
return true;
}
private void updateMousePosition(int eventX, int eventY) { private void updateMousePosition(int eventX, int eventY) {
// Send a mouse move if we already have a mouse location // Send a mouse move if we already have a mouse location

View File

@@ -101,7 +101,7 @@ public class PcView extends Activity {
@Override @Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
long id) { long id) {
ComputerObject computer = (ComputerObject) pcListAdapter.getItem(pos); ComputerObject computer = pcListAdapter.getItem(pos);
if (computer.details == null) { if (computer.details == null) {
// Placeholder item; no context menu for it // Placeholder item; no context menu for it
return; return;
@@ -236,7 +236,7 @@ public class PcView extends Activity {
super.onCreateContextMenu(menu, v, menuInfo); super.onCreateContextMenu(menu, v, menuInfo);
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
ComputerObject computer = (ComputerObject) pcListAdapter.getItem(info.position); ComputerObject computer = pcListAdapter.getItem(info.position);
if (computer == null || computer.details == null) { if (computer == null || computer.details == null) {
startComputerUpdates(); startComputerUpdates();
return; return;
@@ -477,7 +477,7 @@ public class PcView extends Activity {
@Override @Override
public boolean onContextItemSelected(MenuItem item) { public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
ComputerObject computer = (ComputerObject) pcListAdapter.getItem(info.position); ComputerObject computer = pcListAdapter.getItem(info.position);
switch (item.getItemId()) switch (item.getItemId())
{ {
case PAIR_ID: case PAIR_ID:

View File

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

View File

@@ -418,7 +418,7 @@ public class ControllerHandler {
// UI thread. // UI thread.
try { try {
Thread.sleep(ControllerHandler.MINIMUM_BUTTON_DOWN_TIME_MS); Thread.sleep(ControllerHandler.MINIMUM_BUTTON_DOWN_TIME_MS);
} catch (InterruptedException e) {} } catch (InterruptedException ignored) {}
} }
switch (keyCode) { switch (keyCode) {
@@ -495,7 +495,7 @@ public class ControllerHandler {
try { try {
Thread.sleep(EMULATED_SELECT_UP_DELAY_MS); Thread.sleep(EMULATED_SELECT_UP_DELAY_MS);
} catch (InterruptedException e) {} } catch (InterruptedException ignored) {}
} }
} }
@@ -513,7 +513,7 @@ public class ControllerHandler {
try { try {
Thread.sleep(EMULATED_SPECIAL_UP_DELAY_MS); 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 // do input detection by polling
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException e) {} } catch (InterruptedException ignored) {}
// Raise the mouse button // Raise the mouse button
conn.sendMouseButtonUp(buttonIndex); conn.sendMouseButtonUp(buttonIndex);

View File

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

View File

@@ -13,7 +13,7 @@ public class EvdevReader {
} }
// Requires root to chmod /dev/input/eventX // 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"); ProcessBuilder builder = new ProcessBuilder("su");
try { try {
@@ -28,6 +28,7 @@ public class EvdevReader {
p.waitFor(); p.waitFor();
p.destroy(); p.destroy();
return true;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (InterruptedException e) { } catch (InterruptedException e) {

View File

@@ -8,11 +8,12 @@ import com.limelight.LimeLog;
import android.os.FileObserver; import android.os.FileObserver;
@SuppressWarnings("ALL")
public class EvdevWatcher { public class EvdevWatcher {
private static final String PATH = "/dev/input"; private static final String PATH = "/dev/input";
private static final String REQUIRED_FILE_PREFIX = "event"; 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 shutdown = false;
private boolean init = false; private boolean init = false;
private boolean ungrabbed = 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.VideoDepacketizer;
import com.limelight.nvstream.av.video.cpu.AvcDecoder; import com.limelight.nvstream.av.video.cpu.AvcDecoder;
@SuppressWarnings("EmptyCatchBlock")
public class AndroidCpuDecoderRenderer implements VideoDecoderRenderer { public class AndroidCpuDecoderRenderer implements VideoDecoderRenderer {
private Thread rendererThread; private Thread rendererThread;

View File

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

View File

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

View File

@@ -42,7 +42,7 @@ public class ComputerManagerService extends Service {
private boolean stopped; private boolean stopped;
private DiscoveryService.DiscoveryBinder discoveryBinder; private DiscoveryService.DiscoveryBinder discoveryBinder;
private ServiceConnection discoveryServiceConnection = new ServiceConnection() { private final ServiceConnection discoveryServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder binder) { public void onServiceConnected(ComponentName className, IBinder binder) {
synchronized (discoveryServiceConnection) { synchronized (discoveryServiceConnection) {
DiscoveryService.DiscoveryBinder privateBinder = ((DiscoveryService.DiscoveryBinder)binder); DiscoveryService.DiscoveryBinder privateBinder = ((DiscoveryService.DiscoveryBinder)binder);
@@ -84,7 +84,7 @@ public class ComputerManagerService extends Service {
// Wait for the bind notification // Wait for the bind notification
discoveryServiceConnection.wait(1000); discoveryServiceConnection.wait(1000);
} }
} catch (InterruptedException e) { } catch (InterruptedException ignored) {
} }
} }
} }
@@ -93,7 +93,7 @@ public class ComputerManagerService extends Service {
while (activePolls.get() != 0) { while (activePolls.get() != 0) {
try { try {
Thread.sleep(250); Thread.sleep(250);
} catch (InterruptedException e) {} } catch (InterruptedException ignored) {}
} }
} }

View File

@@ -54,7 +54,7 @@ public class IdentityManager {
if (reader != null) { if (reader != null) {
try { try {
reader.close(); reader.close();
} catch (IOException e) {} } catch (IOException ignored) {}
} }
} }
} }
@@ -76,7 +76,7 @@ public class IdentityManager {
if (writer != null) { if (writer != null) {
try { try {
writer.close(); writer.close();
} catch (IOException e) {} } catch (IOException ignored) {}
} }
} }

View File

@@ -13,7 +13,7 @@ public class Dialog implements Runnable {
private AlertDialog alert; private AlertDialog alert;
private static ArrayList<Dialog> rundownDialogs = new ArrayList<Dialog>(); private static final ArrayList<Dialog> rundownDialogs = new ArrayList<Dialog>();
public Dialog(Activity activity, String title, String message, boolean endAfterDismiss) public Dialog(Activity activity, String title, String message, boolean endAfterDismiss)
{ {
@@ -57,7 +57,7 @@ public class Dialog implements Runnable {
alert.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { alert.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
synchronized (rundownDialogs) { synchronized (rundownDialogs) {
rundownDialogs.remove(this); rundownDialogs.remove(Dialog.this);
alert.dismiss(); alert.dismiss();
} }

View File

@@ -14,7 +14,7 @@ public class SpinnerDialog implements Runnable,OnCancelListener {
private ProgressDialog progress; private ProgressDialog progress;
private boolean finish; private boolean finish;
private static ArrayList<SpinnerDialog> rundownDialogs = new ArrayList<SpinnerDialog>(); private static final ArrayList<SpinnerDialog> rundownDialogs = new ArrayList<SpinnerDialog>();
public SpinnerDialog(Activity activity, String title, String message, boolean finish) public SpinnerDialog(Activity activity, String title, String message, boolean finish)
{ {

View File

@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:padding="10dp" android:padding="10dp"
android:layout_height="wrap_content"> android:layout_height="wrap_content">