Changed: Ensure AppShell executable is not null before trying to execute it

This commit is contained in:
agnostic-apollo
2022-06-11 13:52:10 +05:00
parent b96fcb78fd
commit 042487c2b4
2 changed files with 8 additions and 0 deletions

View File

@@ -69,6 +69,13 @@ public final class AppShell {
final AppShellClient appShellClient, final AppShellClient appShellClient,
@NonNull final ShellEnvironmentClient shellEnvironmentClient, @NonNull final ShellEnvironmentClient shellEnvironmentClient,
final boolean isSynchronous) { final boolean isSynchronous) {
if (executionCommand.executable == null || executionCommand.executable.isEmpty()) {
executionCommand.setStateFailed(Errno.ERRNO_FAILED.getCode(),
currentPackageContext.getString(R.string.error_executable_unset, executionCommand.getCommandIdAndLabelLogString()));
AppShell.processAppShellResult(null, executionCommand);
return null;
}
if (executionCommand.workingDirectory == null || executionCommand.workingDirectory.isEmpty()) if (executionCommand.workingDirectory == null || executionCommand.workingDirectory.isEmpty())
executionCommand.workingDirectory = shellEnvironmentClient.getDefaultWorkingDirectoryPath(); executionCommand.workingDirectory = shellEnvironmentClient.getDefaultWorkingDirectoryPath();
if (executionCommand.workingDirectory.isEmpty()) if (executionCommand.workingDirectory.isEmpty())

View File

@@ -62,6 +62,7 @@
<!-- Shell --> <!-- Shell -->
<string name="error_sending_sigkill_to_process">Sending SIGKILL to process on user request or because android is killing the execution service</string> <string name="error_sending_sigkill_to_process">Sending SIGKILL to process on user request or because android is killing the execution service</string>
<string name="error_executable_unset">Executable not set \"%1$s\" for shell command</string>
<string name="error_execution_cancelled">Execution has been cancelled since execution service is being killed</string> <string name="error_execution_cancelled">Execution has been cancelled since execution service is being killed</string>
<string name="error_failed_to_execute_termux_session_command">Failed to execute \"%1$s\" termux session command</string> <string name="error_failed_to_execute_termux_session_command">Failed to execute \"%1$s\" termux session command</string>
<string name="error_failed_to_execute_app_shell_command">Failed to execute \"%1$s\" app shell command</string> <string name="error_failed_to_execute_app_shell_command">Failed to execute \"%1$s\" app shell command</string>