Now, I finally can send SMS through the command line on an Android 8.0-oreo performing next steps:
- Installing the ShellMS app on the phone (once for ever)
- Going on the phone to Settings > Apps > ShellMS > Permissions > Enable all the permissions (once for ever). This step will no longer be necessary once an issue about permissions will be fixed
- Connecting the phone to the computer with USB (and giving permission on the phone for accessing data, if asked)
- Issuing next script on the computer:
#!/bin/bash phonenumber="$1" message="$2" # escape double quotes message=${message//\"/\\\"} adb shell "am startservice --user 0 -n com.android.shellms/.sendSMS -e \"contact\"contact $phonenumber\"$phonenumber\" -e msg \"$message\""