mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-08 03:24:04 +08:00
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:
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user