Skip to content

Commit

Permalink
Fixed: RunCommandService notification was not being cleared if an err…
Browse files Browse the repository at this point in the history
…or was raised
  • Loading branch information
agnostic-apollo committed Aug 20, 2021
1 parent 98edf1f commit fabcc4f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/src/main/java/com/termux/app/RunCommandService.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
errmsg = this.getString(R.string.error_run_command_service_invalid_intent_action, intent.getAction());
executionCommand.setStateFailed(Errno.ERRNO_FAILED.getCode(), errmsg);
PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand, false);
return Service.START_NOT_STICKY;
return stopService();
}

String executableExtra = executionCommand.executable = IntentUtils.getStringExtraIfSet(intent, RUN_COMMAND_SERVICE.EXTRA_COMMAND_PATH, null);
Expand Down Expand Up @@ -125,7 +125,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
if (errmsg != null) {
executionCommand.setStateFailed(Errno.ERRNO_FAILED.getCode(), errmsg);
PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand, true);
return Service.START_NOT_STICKY;
return stopService();
}


Expand All @@ -135,7 +135,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
errmsg = this.getString(R.string.error_run_command_service_mandatory_extra_missing, RUN_COMMAND_SERVICE.EXTRA_COMMAND_PATH);
executionCommand.setStateFailed(Errno.ERRNO_FAILED.getCode(), errmsg);
PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand, false);
return Service.START_NOT_STICKY;
return stopService();
}

// Get canonical path of executable
Expand All @@ -150,7 +150,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
error.appendMessage("\n" + this.getString(R.string.msg_executable_absolute_path, executionCommand.executable));
executionCommand.setStateFailed(error);
PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand, false);
return Service.START_NOT_STICKY;
return stopService();
}


Expand All @@ -172,7 +172,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
error.appendMessage("\n" + this.getString(R.string.msg_working_directory_absolute_path, executionCommand.workingDirectory));
executionCommand.setStateFailed(error);
PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand, false);
return Service.START_NOT_STICKY;
return stopService();
}
}

Expand Down Expand Up @@ -219,8 +219,11 @@ public int onStartCommand(Intent intent, int flags, int startId) {
this.startService(execIntent);
}

runStopForeground();
return stopService();
}

private int stopService() {
runStopForeground();
return Service.START_NOT_STICKY;
}

Expand Down

0 comments on commit fabcc4f

Please sign in to comment.