1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-23 18:35:54 +00:00

Rename variables (ref#1102)

This commit is contained in:
Catfriend1 2018-05-27 21:57:12 +02:00 committed by Audrius Butkevicius
parent 6fc81918e9
commit 5815d8f056

View file

@ -216,7 +216,7 @@ public class SyncthingRunnable implements Runnable {
* containing the PIDs of found instances. * containing the PIDs of found instances.
*/ */
private List<String> getSyncthingPIDs() { private List<String> getSyncthingPIDs() {
List<String> libSyncthingPID = new ArrayList<String>(); List<String> syncthingPIDs = new ArrayList<String>();
Process ps = null; Process ps = null;
DataOutputStream psOut = null; DataOutputStream psOut = null;
BufferedReader br = null; BufferedReader br = null;
@ -233,7 +233,7 @@ public class SyncthingRunnable implements Runnable {
if (line.contains(Constants.FILENAME_SYNCTHING_BINARY)) { if (line.contains(Constants.FILENAME_SYNCTHING_BINARY)) {
String syncthingPID = line.trim().split("\\s+")[1]; String syncthingPID = line.trim().split("\\s+")[1];
Log.v(TAG, "getSyncthingPIDs: Found process PID [" + syncthingPID + "]"); Log.v(TAG, "getSyncthingPIDs: Found process PID [" + syncthingPID + "]");
libSyncthingPID.add(syncthingPID); syncthingPIDs.add(syncthingPID);
} }
} }
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
@ -253,7 +253,7 @@ public class SyncthingRunnable implements Runnable {
ps.destroy(); ps.destroy();
} }
} }
return libSyncthingPID; return syncthingPIDs;
} }
/** /**
@ -267,15 +267,15 @@ public class SyncthingRunnable implements Runnable {
int ret = 1; int ret = 1;
try { try {
Thread.sleep(1000); // Wait a second before getting the pid Thread.sleep(1000); // Wait a second before getting the pid
List<String> libSyncthingPID = getSyncthingPIDs(); List<String> syncthingPIDs = getSyncthingPIDs();
if (libSyncthingPID.isEmpty()) { if (syncthingPIDs.isEmpty()) {
Log.w(TAG, "niceSyncthing: Found no running instances of " + Constants.FILENAME_SYNCTHING_BINARY); Log.w(TAG, "niceSyncthing: Found no running instances of " + Constants.FILENAME_SYNCTHING_BINARY);
} else { } else {
nice = Runtime.getRuntime().exec((mUseRoot) ? "su" : "sh"); nice = Runtime.getRuntime().exec((mUseRoot) ? "su" : "sh");
niceOut = new DataOutputStream(nice.getOutputStream()); niceOut = new DataOutputStream(nice.getOutputStream());
for (String runningPID : libSyncthingPID) { for (String syncthingPID : syncthingPIDs) {
// Set best-effort, low priority using ionice. // Set best-effort, low priority using ionice.
niceOut.writeBytes("ionice " + runningPID + " be 7\n"); niceOut.writeBytes("ionice " + syncthingPID + " be 7\n");
} }
niceOut.writeBytes("exit\n"); niceOut.writeBytes("exit\n");
log(nice.getErrorStream(), Log.WARN, false); log(nice.getErrorStream(), Log.WARN, false);
@ -314,14 +314,14 @@ public class SyncthingRunnable implements Runnable {
public void killSyncthing(OnSyncthingKilled onKilledListener) { public void killSyncthing(OnSyncthingKilled onKilledListener) {
new Thread(() -> { new Thread(() -> {
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
List<String> libSyncthingPID = getSyncthingPIDs(); List<String> syncthingPIDs = getSyncthingPIDs();
if (libSyncthingPID.isEmpty()) { if (syncthingPIDs.isEmpty()) {
Log.d(TAG, "killSyncthing: Found no more running instances of " + Constants.FILENAME_SYNCTHING_BINARY); Log.d(TAG, "killSyncthing: Found no more running instances of " + Constants.FILENAME_SYNCTHING_BINARY);
break; break;
} }
for (String runningPID : libSyncthingPID) { for (String syncthingPID : syncthingPIDs) {
killProcessId(runningPID, i > 0); killProcessId(syncthingPID, i > 0);
} }
} }
onKilledListener.onKilled(); onKilledListener.onKilled();