Avoid star imports and add missing braces (#10521)

Fixes the following SAT findings:

* AvoidStarImportCheck (125)
* NeedBracesCheck (39)

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2021-04-15 16:12:05 +02:00
committed by GitHub
parent e24d43aecb
commit 0c36650179
110 changed files with 793 additions and 217 deletions

View File

@@ -12,7 +12,9 @@
*/
package org.openhab.binding.androiddebugbridge.internal;
import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URLEncoder;
@@ -22,7 +24,11 @@ import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
import java.util.Base64;
import java.util.concurrent.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -98,8 +104,9 @@ public class AndroidDebugBridgeDevice {
public void startPackage(String packageName)
throws InterruptedException, AndroidDebugBridgeDeviceException, TimeoutException, ExecutionException {
var out = runAdbShell("monkey", "--pct-syskeys", "0", "-p", packageName, "-v", "1");
if (out.contains("monkey aborted"))
if (out.contains("monkey aborted")) {
throw new AndroidDebugBridgeDeviceException("Unable to open package");
}
}
public void stopPackage(String packageName)
@@ -114,8 +121,9 @@ public class AndroidDebugBridgeDevice {
var lineParts = targetLine.split(" ");
if (lineParts.length >= 2) {
var packageActivityName = lineParts[lineParts.length - 2];
if (packageActivityName.contains("/"))
if (packageActivityName.contains("/")) {
return packageActivityName.split("/")[0];
}
}
throw new AndroidDebugBridgeDeviceReadException("Unable to read package name");
}
@@ -222,8 +230,9 @@ public class AndroidDebugBridgeDevice {
String volumeResp = runAdbShell("media", "volume", "--show", "--stream", String.valueOf(stream), "--get", "|",
"grep", "volume");
Matcher matcher = VOLUME_PATTERN.matcher(volumeResp);
if (!matcher.find())
if (!matcher.find()) {
throw new AndroidDebugBridgeDeviceReadException("Unable to get volume info");
}
var volumeInfo = new VolumeInfo(Integer.parseInt(matcher.group("current")),
Integer.parseInt(matcher.group("min")), Integer.parseInt(matcher.group("max")));
logger.debug("Device {}:{} VolumeInfo: current {}, min {}, max {}", this.ip, this.port, volumeInfo.current,

View File

@@ -19,7 +19,11 @@ import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.*;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;

View File

@@ -23,7 +23,13 @@ import java.util.concurrent.TimeoutException;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.types.*;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.NextPreviousType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.PlayPauseType;
import org.openhab.core.library.types.RewindFastforwardType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@@ -271,8 +277,9 @@ public class AndroidDebugBridgeHandler extends BaseThingHandler {
public void checkConnection() {
var currentConfig = config;
if (currentConfig == null)
if (currentConfig == null) {
return;
}
try {
logger.debug("Refresh device {} status", currentConfig.ip);
if (adbConnection.isConnected()) {