#include "gflags/gflags.h" #include "android-base/logging.h" #include "common/libs/fs/shared_fd.h" #include "host/commands/cvd_send_sms/sms_sender.h" DEFINE_string(sender_number, "+16501234567", "sender phone number in E.164 format"); DEFINE_uint32(instance_number, 1, "number of the cvd instance to send the sms to, default is 1"); DEFINE_uint32(modem_id, 0, "modem id needed for multisim devices, default is 0"); namespace cuttlefish { namespace { // Usage examples: // * cvd_send_sms "hello world" // * cvd_send_sms --sender_number="+16501239999" "hello world" // * cvd_send_sms --sender_number="16501239999" "hello world" // * cvd_send_sms --instance-number=2 "hello world" // * cvd_send_sms --instance-number=2 --modem_id=1 "hello world" int SendSmsMain(int argc, char** argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); if (argc == 1) { LOG(ERROR) << "Missing message content. First positional argument is used " "as the message content, `cvd_send_sms --instance-number=2 " "\"hello world\"`"; return -1; } // Builds the name of the corresponding modem simulator monitor socket. // https://cs.android.com/android/platform/superproject/+/master:device/google/cuttlefish/host/commands/modem_simulator/main.cpp;l=115;drc=cbfe7dba44bfea95049152b828c1a5d35c9e0522 std::string socket_name = std::string("modem_simulator") + std::to_string(1000 + FLAGS_instance_number); auto client_socket = cuttlefish::SharedFD::SocketLocalClient( socket_name.c_str(), /* abstract */ true, SOCK_STREAM); SmsSender sms_sender(client_socket); if (!sms_sender.Send(argv[1], FLAGS_sender_number, FLAGS_modem_id)) { return -1; } return 0; } } // namespace } // namespace cuttlefish int main(int argc, char** argv) { return cuttlefish::SendSmsMain(argc, argv); }