Fix: String literals should not be duplicated (squid:S1192)

This commit is contained in:
Jano Svitok 2018-07-30 12:23:11 +02:00
parent 9b6074ce2d
commit aec31abf1f
2 changed files with 10 additions and 10 deletions

View File

@ -6,7 +6,7 @@ import se.vidstige.jadb.RemoteFile;
import se.vidstige.jadb.Stream;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -25,7 +25,7 @@ public class PackageManager {
ArrayList<Package> result = new ArrayList<>();
BufferedReader input = null;
try {
input = new BufferedReader(new InputStreamReader(device.executeShell("pm", "list", "packages"), Charset.forName("UTF-8")));
input = new BufferedReader(new InputStreamReader(device.executeShell("pm", "list", "packages"), StandardCharsets.UTF_8));
String line;
while ((line = input.readLine()) != null) {
final String prefix = "package:";
@ -49,7 +49,7 @@ public class PackageManager {
public void remove(RemoteFile file) throws IOException, JadbException {
InputStream s = device.executeShell("rm", "-f", Bash.quote(file.getPath()));
Stream.readAll(s, Charset.forName("UTF-8"));
Stream.readAll(s, StandardCharsets.UTF_8);
}
private void install(File apkFile, List<String> extraArguments) throws IOException, JadbException {
@ -60,7 +60,7 @@ public class PackageManager {
arguments.addAll(extraArguments);
arguments.add(remote.getPath());
InputStream s = device.executeShell("pm", arguments.toArray(new String[arguments.size()]));
String result = Stream.readAll(s, Charset.forName("UTF-8"));
String result = Stream.readAll(s, StandardCharsets.UTF_8);
remove(remote);
verifyOperation("install", apkFile.getName(), result);
}
@ -84,7 +84,7 @@ public class PackageManager {
public void uninstall(Package name) throws IOException, JadbException {
InputStream s = device.executeShell("pm", "uninstall", name.toString());
String result = Stream.readAll(s, Charset.forName("UTF-8"));
String result = Stream.readAll(s, StandardCharsets.UTF_8);
verifyOperation("uninstall", name.toString(), result);
}

View File

@ -7,7 +7,7 @@ import se.vidstige.jadb.SyncTransport;
import java.io.*;
import java.net.ProtocolException;
import java.net.Socket;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
class AdbProtocolHandler implements Runnable {
private final Socket socket;
@ -43,12 +43,12 @@ class AdbProtocolHandler implements Runnable {
while (true) {
byte[] buffer = new byte[4];
input.readFully(buffer);
String encodedLength = new String(buffer, Charset.forName("utf-8"));
String encodedLength = new String(buffer, StandardCharsets.UTF_8);
int length = Integer.parseInt(encodedLength, 16);
buffer = new byte[length];
input.readFully(buffer);
String command = new String(buffer, Charset.forName("utf-8"));
String command = new String(buffer, StandardCharsets.UTF_8);
responder.onCommand(command);
@ -67,7 +67,7 @@ class AdbProtocolHandler implements Runnable {
writer.writeBytes(d.getSerial() + "\t" + d.getType() + "\n");
}
output.writeBytes("OKAY");
send(output, new String(tmp.toByteArray(), Charset.forName("utf-8")));
send(output, new String(tmp.toByteArray(), StandardCharsets.UTF_8));
} else if (command.startsWith("host:transport:")) {
String serial = command.substring("host:transport:".length());
selected = findDevice(serial);
@ -133,7 +133,7 @@ class AdbProtocolHandler implements Runnable {
private String readString(DataInput input, int length) throws IOException {
byte[] responseBuffer = new byte[length];
input.readFully(responseBuffer);
return new String(responseBuffer, Charset.forName("utf-8"));
return new String(responseBuffer, StandardCharsets.UTF_8);
}
private void sync(DataOutput output, DataInput input) throws IOException, JadbException {