Skip to content

Commit fabcc4f

Browse files
Fixed: RunCommandService notification was not being cleared if an error was raised
1 parent 98edf1f commit fabcc4f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

app/src/main/java/com/termux/app/RunCommandService.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
7373
errmsg = this.getString(R.string.error_run_command_service_invalid_intent_action, intent.getAction());
7474
executionCommand.setStateFailed(Errno.ERRNO_FAILED.getCode(), errmsg);
7575
PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand, false);
76-
return Service.START_NOT_STICKY;
76+
return stopService();
7777
}
7878

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

131131

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

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

156156

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

@@ -219,8 +219,11 @@ public int onStartCommand(Intent intent, int flags, int startId) {
219219
this.startService(execIntent);
220220
}
221221

222-
runStopForeground();
222+
return stopService();
223+
}
223224

225+
private int stopService() {
226+
runStopForeground();
224227
return Service.START_NOT_STICKY;
225228
}
226229

0 commit comments

Comments
 (0)