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
apply plugin: 'com.android.application'
@@ -33,6 +34,7 @@ android {
sourceSets.main.jni.srcDirs = []
//noinspection GroovyAssignabilityCheck,GroovyAssignabilityCheck
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

View File

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

View File

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

View File

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

View File

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

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()) {

View File

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

View File

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

View File

@@ -13,7 +13,7 @@ public class Dialog implements Runnable {
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)
{
@@ -57,7 +57,7 @@ public class Dialog implements Runnable {
alert.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
synchronized (rundownDialogs) {
rundownDialogs.remove(this);
rundownDialogs.remove(Dialog.this);
alert.dismiss();
}

View File

@@ -14,7 +14,7 @@ public class SpinnerDialog implements Runnable,OnCancelListener {
private ProgressDialog progress;
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)
{

View File

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