Replace "if(" with "if ("

This commit is contained in:
agnostic-apollo
2021-04-12 14:32:02 +05:00
parent 0cd7cb8162
commit 24a5493ea5
11 changed files with 107 additions and 105 deletions

View File

@@ -153,7 +153,7 @@ clean {
}
}
task downloadBootstraps(){
task downloadBootstraps() {
doLast {
def version = "2021.02.19-r1"
downloadBootstrap("aarch64", "1e3d80bd8cc8771715845ab4a1e67fc125d84c4deda3a1a435116fe4d1f86160", version)

View File

@@ -178,7 +178,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
// Since we cannot rely on {@link TermuxActivity.onDestroy()} to always complete,
// we unset clients here as well if it failed, so that we do not leave service and session
// clients with references to the activity.
if(mTermuxSessionClient != null)
if (mTermuxSessionClient != null)
unsetTermuxSessionClient();
return false;
}
@@ -258,14 +258,14 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
List<TermuxTask> termuxTasks = new ArrayList<>(mTermuxTasks);
for (int i = 0; i < termuxTasks.size(); i++) {
ExecutionCommand executionCommand = termuxTasks.get(i).getExecutionCommand();
if(executionCommand.isPluginExecutionCommand && executionCommand.pluginPendingIntent != null)
if (executionCommand.isPluginExecutionCommand && executionCommand.pluginPendingIntent != null)
termuxTasks.get(i).killIfExecuting(this, true);
}
List<ExecutionCommand> pendingPluginExecutionCommands = new ArrayList<>(mPendingPluginExecutionCommands);
for (int i = 0; i < pendingPluginExecutionCommands.size(); i++) {
ExecutionCommand executionCommand = pendingPluginExecutionCommands.get(i);
if(!executionCommand.shouldNotProcessResults() && executionCommand.pluginPendingIntent != null) {
if (!executionCommand.shouldNotProcessResults() && executionCommand.pluginPendingIntent != null) {
if (executionCommand.setStateFailed(ExecutionCommand.RESULT_CODE_CANCELED, this.getString(com.termux.shared.R.string.error_execution_cancelled), null)) {
PluginUtils.processPluginExecutionCommandResult(this, LOG_TAG, executionCommand);
}
@@ -316,7 +316,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
/** Process action to release Power and Wi-Fi WakeLocks. */
private void actionReleaseWakeLock(boolean updateNotification) {
if (mWakeLock == null && mWifiLock == null){
if (mWakeLock == null && mWifiLock == null) {
Logger.logDebug(LOG_TAG, "Ignoring releasing WakeLocks since none are already held");
return;
}
@@ -333,7 +333,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
mWifiLock = null;
}
if(updateNotification)
if (updateNotification)
updateNotification();
Logger.logDebug(LOG_TAG, "WakeLocks released successfully");
@@ -342,7 +342,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
/** Process {@link TERMUX_SERVICE#ACTION_SERVICE_EXECUTE} intent to execute a shell command in
* a foreground TermuxSession or in a background TermuxTask. */
private void actionServiceExecute(Intent intent) {
if (intent == null){
if (intent == null) {
Logger.logError(LOG_TAG, "Ignoring null intent to actionServiceExecute");
return;
}
@@ -351,7 +351,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
executionCommand.executableUri = intent.getData();
if(executionCommand.executableUri != null) {
if (executionCommand.executableUri != null) {
executionCommand.executable = executionCommand.executableUri.getPath();
executionCommand.arguments = intent.getStringArrayExtra(TERMUX_SERVICE.EXTRA_ARGUMENTS);
}
@@ -408,7 +408,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
return null;
}
if(Logger.getLogLevel() >= Logger.LOG_LEVEL_VERBOSE)
if (Logger.getLogLevel() >= Logger.LOG_LEVEL_VERBOSE)
Logger.logVerbose(LOG_TAG, executionCommand.toString());
TermuxTask newTermuxTask = TermuxTask.execute(this, executionCommand, this, false);
@@ -421,7 +421,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
// Remove the execution command from the pending plugin execution commands list since it has
// now been processed
if(executionCommand.isPluginExecutionCommand)
if (executionCommand.isPluginExecutionCommand)
mPendingPluginExecutionCommands.remove(executionCommand);
updateNotification();
@@ -433,13 +433,13 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
@Override
public void onTermuxTaskExited(final TermuxTask termuxTask) {
mHandler.post(() -> {
if(termuxTask != null) {
if (termuxTask != null) {
ExecutionCommand executionCommand = termuxTask.getExecutionCommand();
Logger.logVerbose(LOG_TAG, "The onTermuxTaskExited() callback called for \"" + executionCommand.getCommandIdAndLabelLogString() + "\" TermuxTask command");
// If the execution command was started for a plugin, then process the results
if(executionCommand != null && executionCommand.isPluginExecutionCommand)
if (executionCommand != null && executionCommand.isPluginExecutionCommand)
PluginUtils.processPluginExecutionCommandResult(this, LOG_TAG, executionCommand);
mTermuxTasks.remove(termuxTask);
@@ -495,7 +495,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
return null;
}
if(Logger.getLogLevel() >= Logger.LOG_LEVEL_VERBOSE)
if (Logger.getLogLevel() >= Logger.LOG_LEVEL_VERBOSE)
Logger.logVerbose(LOG_TAG, executionCommand.toString());
// If the execution command was started for a plugin, only then will the stdout be set
@@ -511,12 +511,12 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
// Remove the execution command from the pending plugin execution commands list since it has
// now been processed
if(executionCommand.isPluginExecutionCommand)
if (executionCommand.isPluginExecutionCommand)
mPendingPluginExecutionCommands.remove(executionCommand);
// Notify {@link TermuxSessionsListViewController} that sessions list has been updated if
// activity in is foreground
if(mTermuxSessionClient != null)
if (mTermuxSessionClient != null)
mTermuxSessionClient.termuxSessionListNotifyUpdated();
updateNotification();
@@ -529,7 +529,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
public synchronized int removeTermuxSession(TerminalSession sessionToRemove) {
int index = getIndexOfSession(sessionToRemove);
if(index >= 0)
if (index >= 0)
mTermuxSessions.get(index).finish();
return index;
@@ -538,20 +538,20 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
/** Callback received when a {@link TermuxSession} finishes. */
@Override
public void onTermuxSessionExited(final TermuxSession termuxSession) {
if(termuxSession != null) {
if (termuxSession != null) {
ExecutionCommand executionCommand = termuxSession.getExecutionCommand();
Logger.logVerbose(LOG_TAG, "The onTermuxSessionExited() callback called for \"" + executionCommand.getCommandIdAndLabelLogString() + "\" TermuxSession command");
// If the execution command was started for a plugin, then process the results
if(executionCommand != null && executionCommand.isPluginExecutionCommand)
if (executionCommand != null && executionCommand.isPluginExecutionCommand)
PluginUtils.processPluginExecutionCommandResult(this, LOG_TAG, executionCommand);
mTermuxSessions.remove(termuxSession);
// Notify {@link TermuxSessionsListViewController} that sessions list has been updated if
// activity in is foreground
if(mTermuxSessionClient != null)
if (mTermuxSessionClient != null)
mTermuxSessionClient.termuxSessionListNotifyUpdated();
}
@@ -575,22 +575,22 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
switch (sessionAction) {
case TERMUX_SERVICE.VALUE_EXTRA_SESSION_ACTION_SWITCH_TO_NEW_SESSION_AND_OPEN_ACTIVITY:
setCurrentStoredTerminalSession(newTerminalSession);
if(mTermuxSessionClient != null)
if (mTermuxSessionClient != null)
mTermuxSessionClient.setCurrentSession(newTerminalSession);
startTermuxActivity();
break;
case TERMUX_SERVICE.VALUE_EXTRA_SESSION_ACTION_KEEP_CURRENT_SESSION_AND_OPEN_ACTIVITY:
if(getTermuxSessionsSize() == 1)
if (getTermuxSessionsSize() == 1)
setCurrentStoredTerminalSession(newTerminalSession);
startTermuxActivity();
break;
case TERMUX_SERVICE.VALUE_EXTRA_SESSION_ACTION_SWITCH_TO_NEW_SESSION_AND_DONT_OPEN_ACTIVITY:
setCurrentStoredTerminalSession(newTerminalSession);
if(mTermuxSessionClient != null)
if (mTermuxSessionClient != null)
mTermuxSessionClient.setCurrentSession(newTerminalSession);
break;
case TERMUX_SERVICE.VALUE_EXTRA_SESSION_ACTION_KEEP_CURRENT_SESSION_AND_DONT_OPEN_ACTIVITY:
if(getTermuxSessionsSize() == 1)
if (getTermuxSessionsSize() == 1)
setCurrentStoredTerminalSession(newTerminalSession);
break;
default:
@@ -605,7 +605,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
// For android >= 10, apps require Display over other apps permission to start foreground activities
// from background (services). If it is not granted, then TermuxSessions that are started will
// show in Termux notification but will not run until user manually clicks the notification.
if(PermissionUtils.validateDisplayOverOtherAppsPermissionForPostAndroid10(this)) {
if (PermissionUtils.validateDisplayOverOtherAppsPermissionForPostAndroid10(this)) {
TermuxActivity.startTermuxActivity(this);
}
}

View File

@@ -43,7 +43,7 @@ public class ExtraKeysInfo {
ExtraKeyButton button;
if(! jobject.has("popup")) {
if (! jobject.has("popup")) {
// no popup
button = new ExtraKeyButton(getSelectedCharMap(), jobject);
} else {
@@ -63,10 +63,10 @@ public class ExtraKeysInfo {
*/
private static JSONObject normalizeKeyConfig(Object key) throws JSONException {
JSONObject jobject;
if(key instanceof String) {
if (key instanceof String) {
jobject = new JSONObject();
jobject.put("key", key);
} else if(key instanceof JSONObject) {
} else if (key instanceof JSONObject) {
jobject = (JSONObject) key;
} else {
throw new JSONException("An key in the extra-key matrix must be a string or an object");
@@ -84,7 +84,7 @@ public class ExtraKeysInfo {
*/
static class CleverMap<K,V> extends HashMap<K,V> {
V get(K key, V defaultValue) {
if(containsKey(key))
if (containsKey(key))
return get(key);
else
return defaultValue;

View File

@@ -55,7 +55,7 @@ public class PluginUtils {
logTag = DataUtils.getDefaultIfNull(logTag, LOG_TAG);
if(!executionCommand.hasExecuted()) {
if (!executionCommand.hasExecuted()) {
Logger.logWarn(logTag, "Ignoring call to processPluginExecutionCommandResult() since the execution command state is not higher than the ExecutionState.EXECUTED");
return;
}
@@ -66,7 +66,7 @@ public class PluginUtils {
// If isPluginExecutionCommand is true and pluginPendingIntent is not null, then
// send pluginPendingIntent to its creator with the result
if(executionCommand.isPluginExecutionCommand && executionCommand.pluginPendingIntent != null) {
if (executionCommand.isPluginExecutionCommand && executionCommand.pluginPendingIntent != null) {
String errmsg = executionCommand.errmsg;
//Combine errmsg and stacktraces
@@ -78,7 +78,7 @@ public class PluginUtils {
result = sendPluginExecutionCommandResultPendingIntent(context, logTag, executionCommand.getCommandIdAndLabelLogString(), executionCommand.stdout, executionCommand.stderr, executionCommand.exitCode, executionCommand.errCode, errmsg, executionCommand.pluginPendingIntent);
}
if(!executionCommand.isStateFailed() && result)
if (!executionCommand.isStateFailed() && result)
executionCommand.setState(ExecutionCommand.ExecutionState.SUCCESS);
}
@@ -109,11 +109,11 @@ public class PluginUtils {
* is {@code false}.
*/
public static void processPluginExecutionCommandError(final Context context, String logTag, final ExecutionCommand executionCommand, boolean forceNotification) {
if(context == null || executionCommand == null) return;
if (context == null || executionCommand == null) return;
logTag = DataUtils.getDefaultIfNull(logTag, LOG_TAG);
if(!executionCommand.isStateFailed()) {
if (!executionCommand.isStateFailed()) {
Logger.logWarn(logTag, "Ignoring call to processPluginExecutionCommandError() since the execution command is not in ExecutionState.FAILED");
return;
}
@@ -124,7 +124,7 @@ public class PluginUtils {
// If isPluginExecutionCommand is true and pluginPendingIntent is not null, then
// send pluginPendingIntent to its creator with the errors
if(executionCommand.isPluginExecutionCommand && executionCommand.pluginPendingIntent != null) {
if (executionCommand.isPluginExecutionCommand && executionCommand.pluginPendingIntent != null) {
String errmsg = executionCommand.errmsg;
//Combine errmsg and stacktraces
@@ -169,12 +169,12 @@ public class PluginUtils {
// Build the notification
Notification.Builder builder = getPluginCommandErrorsNotificationBuilder(context, title, notificationText, notificationText, pendingIntent, NotificationUtils.NOTIFICATION_MODE_VIBRATE);
if(builder == null) return;
if (builder == null) return;
// Send the notification
int nextNotificationId = NotificationUtils.getNextNotificationId(context);
NotificationManager notificationManager = NotificationUtils.getNotificationManager(context);
if(notificationManager != null)
if (notificationManager != null)
notificationManager.notify(nextNotificationId, builder.build());
}
@@ -196,7 +196,7 @@ public class PluginUtils {
* @return Returns {@code true} if pluginPendingIntent was successfully send, otherwise [@code false}.
*/
public static boolean sendPluginExecutionCommandResultPendingIntent(Context context, String logTag, String label, String stdout, String stderr, Integer exitCode, Integer errCode, String errmsg, PendingIntent pluginPendingIntent) {
if(context == null || pluginPendingIntent == null) return false;
if (context == null || pluginPendingIntent == null) return false;
logTag = DataUtils.getDefaultIfNull(logTag, LOG_TAG);
@@ -209,7 +209,7 @@ public class PluginUtils {
String stderrOriginalLength = (stderr == null) ? null: String.valueOf(stderr.length());
// Truncate stdout and stdout to max TRANSACTION_SIZE_LIMIT_IN_BYTES
if(stderr == null || stderr.isEmpty()) {
if (stderr == null || stderr.isEmpty()) {
truncatedStdout = DataUtils.getTruncatedCommandOutput(stdout, DataUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES, false, false, false);
} else if (stdout == null || stdout.isEmpty()) {
truncatedStderr = DataUtils.getTruncatedCommandOutput(stderr, DataUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES, false, false, false);
@@ -218,12 +218,12 @@ public class PluginUtils {
truncatedStderr = DataUtils.getTruncatedCommandOutput(stderr, DataUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES / 2, false, false, false);
}
if(truncatedStdout != null && truncatedStdout.length() < stdout.length()){
if (truncatedStdout != null && truncatedStdout.length() < stdout.length()) {
Logger.logWarn(logTag, "Execution Result for Execution Command \"" + label + "\" stdout length truncated from " + stdoutOriginalLength + " to " + truncatedStdout.length());
stdout = truncatedStdout;
}
if(truncatedStderr != null && truncatedStderr.length() < stderr.length()){
if (truncatedStderr != null && truncatedStderr.length() < stderr.length()) {
Logger.logWarn(logTag, "Execution Result for Execution Command \"" + label + "\" stderr length truncated from " + stderrOriginalLength + " to " + truncatedStderr.length());
stderr = truncatedStderr;
}
@@ -233,7 +233,7 @@ public class PluginUtils {
// Truncate errmsg to max TRANSACTION_SIZE_LIMIT_IN_BYTES / 4
// trim from end to preserve start of stacktraces
String truncatedErrmsg = DataUtils.getTruncatedCommandOutput(errmsg, DataUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES / 4, true, false, false);
if(truncatedErrmsg != null && truncatedErrmsg.length() < errmsg.length()){
if (truncatedErrmsg != null && truncatedErrmsg.length() < errmsg.length()) {
Logger.logWarn(logTag, "Execution Result for Execution Command \"" + label + "\" errmsg length truncated from " + errmsgOriginalLength + " to " + truncatedErrmsg.length());
errmsg = truncatedErrmsg;
}
@@ -282,7 +282,7 @@ public class PluginUtils {
TermuxConstants.TERMUX_PLUGIN_COMMAND_ERRORS_NOTIFICATION_CHANNEL_ID, Notification.PRIORITY_HIGH,
title, notificationText, notificationBigText, pendingIntent, notificationMode);
if(builder == null) return null;
if (builder == null) return null;
// Enable timestamp
builder.setShowWhen(true);

View File

@@ -104,9 +104,9 @@ public class FileAttributes {
}
public String file() {
if(filePath != null)
if (filePath != null)
return filePath;
else if(fileDescriptor != null)
else if (fileDescriptor != null)
return fileDescriptor.toString();
else
return null;
@@ -397,7 +397,7 @@ public class FileAttributes {
logString.append("\n").append(fileAttributes.getInodeString());
logString.append("\n").append(fileAttributes.getLinksString());
if(fileAttributes.isBlock() || fileAttributes.isCharacter())
if (fileAttributes.isBlock() || fileAttributes.isCharacter())
logString.append("\n").append(fileAttributes.getDeviceTypeString());
logString.append("\n").append(fileAttributes.getOwnerString());

View File

@@ -104,7 +104,7 @@ public class FileUtilsTests {
errmsg = FileUtils.clearDirectory(context, label, testRootDirectoryPath);
assertEqual("Failed to create " + label + " directory file", null, errmsg);
if(!FileUtils.directoryFileExists(testRootDirectoryPath, false))
if (!FileUtils.directoryFileExists(testRootDirectoryPath, false))
throwException("The " + label + " directory file does not exist as expected after creation");
@@ -124,30 +124,30 @@ public class FileUtilsTests {
label = dir1__sub_dir1_label; path = dir1__sub_dir1_path;
errmsg = FileUtils.createDirectoryFile(context, label, path);
assertEqual("Failed to create " + label + " directory file", null, errmsg);
if(!FileUtils.directoryFileExists(path, false))
if (!FileUtils.directoryFileExists(path, false))
throwException("The " + label + " directory file does not exist as expected after creation");
// Create dir1/sub_reg1 regular file
label = dir1__sub_reg1_label; path = dir1__sub_reg1_path;
errmsg = FileUtils.createRegularFile(context, label, path);
assertEqual("Failed to create " + label + " regular file", null, errmsg);
if(!FileUtils.regularFileExists(path, false))
if (!FileUtils.regularFileExists(path, false))
throwException("The " + label + " regular file does not exist as expected after creation");
// Create dir1/sub_sym1 -> dir2 absolute symlink file
label = dir1__sub_sym1_label; path = dir1__sub_sym1_path;
errmsg = FileUtils.createSymlinkFile(context, label, dir2_path, path);
assertEqual("Failed to create " + label + " symlink file", null, errmsg);
if(!FileUtils.symlinkFileExists(path))
if (!FileUtils.symlinkFileExists(path))
throwException("The " + label + " symlink file does not exist as expected after creation");
// Copy dir1/sub_sym1 symlink file to dir1/sub_sym2
label = dir1__sub_sym2_label; path = dir1__sub_sym2_path;
errmsg = FileUtils.copySymlinkFile(context, label, dir1__sub_sym1_path, path, false);
assertEqual("Failed to copy " + dir1__sub_sym1_label + " symlink file to " + label, null, errmsg);
if(!FileUtils.symlinkFileExists(path))
if (!FileUtils.symlinkFileExists(path))
throwException("The " + label + " symlink file does not exist as expected after copying it from " + dir1__sub_sym1_label);
if(!new File(path).getCanonicalPath().equals(dir2_path))
if (!new File(path).getCanonicalPath().equals(dir2_path))
throwException("The " + label + " symlink file does not point to " + dir2_label);
@@ -158,7 +158,7 @@ public class FileUtilsTests {
label = dir2__sub_reg1_label; path = dir2__sub_reg1_path;
errmsg = FileUtils.writeStringToFile(context, label, path, Charset.defaultCharset(), "line1", false);
assertEqual("Failed to write string to " + label + " file with append mode false", null, errmsg);
if(!FileUtils.regularFileExists(path, false))
if (!FileUtils.regularFileExists(path, false))
throwException("The " + label + " file does not exist as expected after writing to it with append mode false");
// Write "line2" to dir2/sub_reg1 regular file
@@ -175,7 +175,7 @@ public class FileUtilsTests {
label = dir2__sub_reg2_label; path = dir2__sub_reg2_path;
errmsg = FileUtils.copyRegularFile(context, label, dir2__sub_reg1_path, path, false);
assertEqual("Failed to copy " + dir2__sub_reg1_label + " regular file to " + label, null, errmsg);
if(!FileUtils.regularFileExists(path, false))
if (!FileUtils.regularFileExists(path, false))
throwException("The " + label + " regular file does not exist as expected after copying it from " + dir2__sub_reg1_label);
@@ -186,21 +186,21 @@ public class FileUtilsTests {
label = dir3_label; path = dir3_path;
errmsg = FileUtils.copyDirectoryFile(context, label, dir2_path, path, false);
assertEqual("Failed to copy " + dir2_label + " directory file to " + label, null, errmsg);
if(!FileUtils.directoryFileExists(path, false))
if (!FileUtils.directoryFileExists(path, false))
throwException("The " + label + " directory file does not exist as expected after copying it from " + dir2_label);
// Copy dir1 directory file to dir3 again to test overwrite
label = dir3_label; path = dir3_path;
errmsg = FileUtils.copyDirectoryFile(context, label, dir2_path, path, false);
assertEqual("Failed to copy " + dir2_label + " directory file to " + label, null, errmsg);
if(!FileUtils.directoryFileExists(path, false))
if (!FileUtils.directoryFileExists(path, false))
throwException("The " + label + " directory file does not exist as expected after copying it from " + dir2_label);
// Move dir3 directory file to dir4
label = dir4_label; path = dir4_path;
errmsg = FileUtils.moveDirectoryFile(context, label, dir3_path, path, false);
assertEqual("Failed to move " + dir3_label + " directory file to " + label, null, errmsg);
if(!FileUtils.directoryFileExists(path, false))
if (!FileUtils.directoryFileExists(path, false))
throwException("The " + label + " directory file does not exist as expected after copying it from " + dir3_label);
@@ -211,7 +211,7 @@ public class FileUtilsTests {
label = dir1__sub_sym3_label; path = dir1__sub_sym3_path;
errmsg = FileUtils.createSymlinkFile(context, label, "../dir4", path);
assertEqual("Failed to create " + label + " symlink file", null, errmsg);
if(!FileUtils.symlinkFileExists(path))
if (!FileUtils.symlinkFileExists(path))
throwException("The " + label + " symlink file does not exist as expected after creation");
// Create dir1/sub_sym3 -> dirX relative dangling symlink file
@@ -219,7 +219,7 @@ public class FileUtilsTests {
label = dir1__sub_sym3_label; path = dir1__sub_sym3_path;
errmsg = FileUtils.createSymlinkFile(context, label, "../dirX", path);
assertEqual("Failed to create " + label + " symlink file", null, errmsg);
if(!FileUtils.symlinkFileExists(path))
if (!FileUtils.symlinkFileExists(path))
throwException("The " + label + " dangling symlink file does not exist as expected after creation");
@@ -230,13 +230,13 @@ public class FileUtilsTests {
label = dir1__sub_sym2_label; path = dir1__sub_sym2_path;
errmsg = FileUtils.deleteSymlinkFile(context, label, path, false);
assertEqual("Failed to delete " + label + " symlink file", null, errmsg);
if(FileUtils.fileExists(path, false))
if (FileUtils.fileExists(path, false))
throwException("The " + label + " symlink file still exist after deletion");
// Check if dir2 directory file still exists after deletion of dir1/sub_sym2 since it was a symlink to dir2
// When deleting a symlink file, its target must not be deleted
label = dir2_label; path = dir2_path;
if(!FileUtils.directoryFileExists(path, false))
if (!FileUtils.directoryFileExists(path, false))
throwException("The " + label + " directory file has unexpectedly been deleted after deletion of " + dir1__sub_sym2_label);
@@ -247,7 +247,7 @@ public class FileUtilsTests {
label = dir1_label; path = dir1_path;
errmsg = FileUtils.deleteDirectoryFile(context, label, path, false);
assertEqual("Failed to delete " + label + " directory file", null, errmsg);
if(FileUtils.fileExists(path, false))
if (FileUtils.fileExists(path, false))
throwException("The " + label + " directory file still exist after deletion");
@@ -255,10 +255,10 @@ public class FileUtilsTests {
// dir1 since there was a dir1/sub_sym1 symlink to dir2 in it
// When deleting a directory, any targets of symlinks must not be deleted when deleting symlink files
label = dir2_label; path = dir2_path;
if(!FileUtils.directoryFileExists(path, false))
if (!FileUtils.directoryFileExists(path, false))
throwException("The " + label + " directory file has unexpectedly been deleted after deletion of " + dir1_label);
label = dir2__sub_reg1_label; path = dir2__sub_reg1_path;
if(!FileUtils.fileExists(path, false))
if (!FileUtils.fileExists(path, false))
throwException("The " + label + " regular file has unexpectedly been deleted after deletion of " + dir1_label);
@@ -269,7 +269,7 @@ public class FileUtilsTests {
label = dir2__sub_reg1_label; path = dir2__sub_reg1_path;
errmsg = FileUtils.deleteRegularFile(context, label, path, false);
assertEqual("Failed to delete " + label + " regular file", null, errmsg);
if(FileUtils.fileExists(path, false))
if (FileUtils.fileExists(path, false))
throwException("The " + label + " regular file still exist after deletion");
FileUtils.getFileType("/dev/ptmx", false);

View File

@@ -32,15 +32,15 @@ public class Logger {
public static void logMessage(int logLevel, String tag, String message) {
if(logLevel == Log.ERROR && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
if (logLevel == Log.ERROR && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
Log.e(getFullTag(tag), message);
else if(logLevel == Log.WARN && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
else if (logLevel == Log.WARN && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
Log.w(getFullTag(tag), message);
else if(logLevel == Log.INFO && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
else if (logLevel == Log.INFO && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
Log.i(getFullTag(tag), message);
else if(logLevel == Log.DEBUG && CURRENT_LOG_LEVEL >= LOG_LEVEL_DEBUG)
else if (logLevel == Log.DEBUG && CURRENT_LOG_LEVEL >= LOG_LEVEL_DEBUG)
Log.d(getFullTag(tag), message);
else if(logLevel == Log.VERBOSE && CURRENT_LOG_LEVEL >= LOG_LEVEL_VERBOSE)
else if (logLevel == Log.VERBOSE && CURRENT_LOG_LEVEL >= LOG_LEVEL_VERBOSE)
Log.v(getFullTag(tag), message);
}
@@ -99,7 +99,7 @@ public class Logger {
public static void logErrorAndShowToast(Context context, String tag, String message) {
if (context == null) return;
if(CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL) {
if (CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL) {
logError(tag, message);
showToast(context, message, true);
}
@@ -114,7 +114,7 @@ public class Logger {
public static void logDebugAndShowToast(Context context, String tag, String message) {
if (context == null) return;
if(CURRENT_LOG_LEVEL >= LOG_LEVEL_DEBUG) {
if (CURRENT_LOG_LEVEL >= LOG_LEVEL_DEBUG) {
logDebug(tag, message);
showToast(context, message, true);
}
@@ -127,7 +127,7 @@ public class Logger {
public static void logStackTraceWithMessage(String tag, String message, Throwable throwable) {
if(CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
if (CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
Log.e(getFullTag(tag), getMessageAndStackTraceString(message, throwable));
}
@@ -144,12 +144,12 @@ public class Logger {
}
public static void logStackTracesWithMessage(String tag, String message, List<Throwable> throwableList) {
if(CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
if (CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
Log.e(getFullTag(tag), getMessageAndStackTracesString(message, throwableList));
}
public static String getMessageAndStackTraceString(String message, Throwable throwable) {
if(message == null && throwable == null)
if (message == null && throwable == null)
return null;
else if(message != null && throwable != null)
return message + ":\n" + getStackTraceString(throwable);

View File

@@ -131,10 +131,10 @@ public class ExecutionCommand {
public ExecutionCommand(){
public ExecutionCommand() {
}
public ExecutionCommand(Integer id){
public ExecutionCommand(Integer id) {
this.id = id;
}

View File

@@ -52,7 +52,7 @@ public class SharedPreferenceUtils {
* default if failed to read a valid value, like in case of an exception.
*/
public static boolean getBoolean(SharedPreferences sharedPreferences, String key, boolean def) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Error getting boolean value for the \"" + key + "\" key from null shared preferences. Returning default value \"" + def + "\".");
return def;
}
@@ -78,12 +78,12 @@ public class SharedPreferenceUtils {
*/
@SuppressLint("ApplySharedPref")
public static void setBoolean(SharedPreferences sharedPreferences, String key, boolean value, boolean commitToFile) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Ignoring setting boolean value \"" + value + "\" for the \"" + key + "\" key into null shared preferences.");
return;
}
if(commitToFile)
if (commitToFile)
sharedPreferences.edit().putBoolean(key, value).commit();
else
sharedPreferences.edit().putBoolean(key, value).apply();
@@ -102,7 +102,7 @@ public class SharedPreferenceUtils {
* default if failed to read a valid value, like in case of an exception.
*/
public static float getFloat(SharedPreferences sharedPreferences, String key, float def) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Error getting float value for the \"" + key + "\" key from null shared preferences. Returning default value \"" + def + "\".");
return def;
}
@@ -128,12 +128,12 @@ public class SharedPreferenceUtils {
*/
@SuppressLint("ApplySharedPref")
public static void setFloat(SharedPreferences sharedPreferences, String key, float value, boolean commitToFile) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Ignoring setting float value \"" + value + "\" for the \"" + key + "\" key into null shared preferences.");
return;
}
if(commitToFile)
if (commitToFile)
sharedPreferences.edit().putFloat(key, value).commit();
else
sharedPreferences.edit().putFloat(key, value).apply();
@@ -151,7 +151,7 @@ public class SharedPreferenceUtils {
* default if failed to read a valid value, like in case of an exception.
*/
public static int getInt(SharedPreferences sharedPreferences, String key, int def) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Error getting int value for the \"" + key + "\" key from null shared preferences. Returning default value \"" + def + "\".");
return def;
}
@@ -177,12 +177,12 @@ public class SharedPreferenceUtils {
*/
@SuppressLint("ApplySharedPref")
public static void setInt(SharedPreferences sharedPreferences, String key, int value, boolean commitToFile) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Ignoring setting int value \"" + value + "\" for the \"" + key + "\" key into null shared preferences.");
return;
}
if(commitToFile)
if (commitToFile)
sharedPreferences.edit().putInt(key, value).commit();
else
sharedPreferences.edit().putInt(key, value).apply();
@@ -200,7 +200,7 @@ public class SharedPreferenceUtils {
* default if failed to read a valid value, like in case of an exception.
*/
public static long getLong(SharedPreferences sharedPreferences, String key, long def) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Error getting long value for the \"" + key + "\" key from null shared preferences. Returning default value \"" + def + "\".");
return def;
}
@@ -226,12 +226,12 @@ public class SharedPreferenceUtils {
*/
@SuppressLint("ApplySharedPref")
public static void setLong(SharedPreferences sharedPreferences, String key, long value, boolean commitToFile) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Ignoring setting long value \"" + value + "\" for the \"" + key + "\" key into null shared preferences.");
return;
}
if(commitToFile)
if (commitToFile)
sharedPreferences.edit().putLong(key, value).commit();
else
sharedPreferences.edit().putLong(key, value).apply();
@@ -249,7 +249,7 @@ public class SharedPreferenceUtils {
* default if failed to read a valid value, like in case of an exception.
*/
public static String getString(SharedPreferences sharedPreferences, String key, String def) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Error getting String value for the \"" + key + "\" key from null shared preferences. Returning default value \"" + def + "\".");
return def;
}
@@ -275,12 +275,12 @@ public class SharedPreferenceUtils {
*/
@SuppressLint("ApplySharedPref")
public static void setString(SharedPreferences sharedPreferences, String key, String value, boolean commitToFile) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Ignoring setting String value \"" + value + "\" for the \"" + key + "\" key into null shared preferences.");
return;
}
if(commitToFile)
if (commitToFile)
sharedPreferences.edit().putString(key, value).commit();
else
sharedPreferences.edit().putString(key, value).apply();
@@ -298,7 +298,7 @@ public class SharedPreferenceUtils {
* default if failed to read a valid value, like in case of an exception.
*/
public static Set<String> getStringSet(SharedPreferences sharedPreferences, String key, Set<String> def) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Error getting Set<String> value for the \"" + key + "\" key from null shared preferences. Returning default value \"" + def + "\".");
return def;
}
@@ -324,12 +324,12 @@ public class SharedPreferenceUtils {
*/
@SuppressLint("ApplySharedPref")
public static void setStringSet(SharedPreferences sharedPreferences, String key, Set<String> value, boolean commitToFile) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Ignoring setting Set<String> value \"" + value + "\" for the \"" + key + "\" key into null shared preferences.");
return;
}
if(commitToFile)
if (commitToFile)
sharedPreferences.edit().putStringSet(key, value).commit();
else
sharedPreferences.edit().putStringSet(key, value).apply();
@@ -348,7 +348,7 @@ public class SharedPreferenceUtils {
* like in case of an exception.
*/
public static int getIntStoredAsString(SharedPreferences sharedPreferences, String key, int def) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Error getting int value for the \"" + key + "\" key from null shared preferences. Returning default value \"" + def + "\".");
return def;
}
@@ -358,7 +358,7 @@ public class SharedPreferenceUtils {
try {
stringValue = sharedPreferences.getString(key, Integer.toString(def));
if(stringValue != null)
if (stringValue != null)
intValue = Integer.parseInt(stringValue);
else
intValue = def;
@@ -381,12 +381,12 @@ public class SharedPreferenceUtils {
*/
@SuppressLint("ApplySharedPref")
public static void setIntStoredAsString(SharedPreferences sharedPreferences, String key, int value, boolean commitToFile) {
if(sharedPreferences == null) {
if (sharedPreferences == null) {
Logger.logError(LOG_TAG, "Ignoring setting int value \"" + value + "\" for the \"" + key + "\" key into null shared preferences.");
return;
}
if(commitToFile)
if (commitToFile)
sharedPreferences.edit().putString(key, Integer.toString(value)).commit();
else
sharedPreferences.edit().putString(key, Integer.toString(value)).apply();

View File

@@ -38,7 +38,7 @@ public class TermuxTaskerAppSharedPreferences {
public int getLogLevel(boolean readFromFfile) {
if(readFromFfile)
if (readFromFfile)
return SharedPreferenceUtils.getInt(mMultiProcessSharedPreferences, TERMUX_TASKER_APP.KEY_LOG_LEVEL, Logger.DEFAULT_LOG_LEVEL);
else
return SharedPreferenceUtils.getInt(mSharedPreferences, TERMUX_TASKER_APP.KEY_LOG_LEVEL, Logger.DEFAULT_LOG_LEVEL);

View File

@@ -145,7 +145,7 @@ public class TermuxUtils {
String termuxPackageName = null;
String termuxAppName = null;
if(termuxPackageContext != null) {
if (termuxPackageContext != null) {
termuxPackageName = PackageUtils.getPackageNameForPackage(termuxPackageContext);
termuxAppName = PackageUtils.getAppNameForPackage(termuxPackageContext);
}
@@ -156,13 +156,13 @@ public class TermuxUtils {
boolean isTermuxPackage = (termuxPackageName != null && termuxPackageName.equals(currentPackageName));
if(returnTermuxPackageInfoToo && !isTermuxPackage)
if (returnTermuxPackageInfoToo && !isTermuxPackage)
markdownString.append("## ").append(currentAppName).append(" App Info (Current)\n");
else
markdownString.append("## ").append(currentAppName).append(" App Info\n");
markdownString.append(getAppInfoMarkdownStringInner(currentPackageContext));
if(returnTermuxPackageInfoToo && !isTermuxPackage) {
if (returnTermuxPackageInfoToo && !isTermuxPackage) {
markdownString.append("\n\n## ").append(termuxAppName).append(" App Info\n");
markdownString.append(getAppInfoMarkdownStringInner(termuxPackageContext));
}
@@ -284,6 +284,8 @@ public class TermuxUtils {
return markdownString.toString();
}
public static Properties getSystemProperties() {
Properties systemProperties = new Properties();
@@ -311,7 +313,7 @@ public class TermuxUtils {
if (matcher.matches()) {
key = matcher.group(1);
value = matcher.group(2);
if(key != null && value != null && !key.isEmpty() && !value.isEmpty())
if (key != null && value != null && !key.isEmpty() && !value.isEmpty())
systemProperties.put(key, value);
}
}
@@ -340,8 +342,8 @@ public class TermuxUtils {
}
private static void appendPropertyToMarkdownIfSet(StringBuilder markdownString, String label, Object value) {
if(value == null) return;
if(value instanceof String && (((String) value).isEmpty()) || "REL".equals(value)) return;
if (value == null) return;
if (value instanceof String && (((String) value).isEmpty()) || "REL".equals(value)) return;
markdownString.append("\n").append(getPropertyMarkdown(label, value));
}