Add logcat errors in RunCommandService

This commit adds `logcat` errors if an invalid intent action is passed or if `allow-external-apps` is not set to `true` while sending an intent to `RunCommandService`, so that users can detect issues.
This commit is contained in:
agnostic-apollo
2021-02-27 13:07:07 +05:00
parent f50d15d353
commit 00194ebb90

View File

@@ -92,7 +92,18 @@ public class RunCommandService extends Service {
// Run again in case service is already started and onCreate() is not called
runStartForeground();
if (allowExternalApps() && RUN_COMMAND_ACTION.equals(intent.getAction())) {
// If wrong action passed, then just return
if (!RUN_COMMAND_ACTION.equals(intent.getAction())) {
Log.e("termux", "Unexpected intent action to RunCommandService: " + intent.getAction());
return Service.START_NOT_STICKY;
}
// If allow-external-apps property to not set to "true"
if (!allowExternalApps()) {
Log.e("termux", "RunCommandService requires allow-external-apps property to be set to \"true\" in ~/.termux/termux.properties file.");
return Service.START_NOT_STICKY;
}
Uri programUri = new Uri.Builder().scheme("com.termux.file").path(parsePath(intent.getStringExtra(RUN_COMMAND_PATH))).build();
Intent execIntent = new Intent(TermuxService.ACTION_EXECUTE, programUri);
@@ -106,7 +117,6 @@ public class RunCommandService extends Service {
} else {
this.startService(execIntent);
}
}
runStopForeground();