代码拉取完成,页面将自动刷新
安卓手机打开开发者模式,允许调试,USB连接PC授权信任 可参照 https://cloud.tencent.com/developer/article/1889583
go mod tidy
go run main.go -l DEBUG --mode pc --port 30000
make arm64_package
output目录下得到arm环境运行文件
./AndroidSMSAdapter --port 30000
详细参数
启动服务
Usage:
AndriodSMSAdapter server [flags]
Flags:
-h, --help help for server
--mode string 运行模式:1. phone: 即为在手机内部运行 2. pc: 在PC上外部运行 (default "phone")
--port uint16 设定服务端口 (default 30000)
Global Flags:
--log-json 设置日志为JSON格式
-l, --log-level string 设置日志级别 (default "INFO")
$ curl --location 'http://127.0.0.1:30000/'
{"message":"hi, I'm sms adapter"}
curl --location 'http://127.0.0.1:30000/read' \
--header 'Content-Type: application/json' \
--data '{"where": "_id=220"} '
{
"description": "查询短信信息",
"message": "ok",
"status_code": 200,
"data": "Row: 0 _id=220, thread_id=32, address=10000, person=NULL, date=1602837752232, date_sent=1602837749000, protocol=0, read=1, status=-1, type=1, reply_path_present=0, subject=NULL, body=【公益短信】今天是世界粮食日,本周是我国粮食安全宣传周。让我们共同携手,厉行勤俭节约,反对餐饮浪费,把中国人的饭碗牢牢端在自己手上!国家粮食和物资储备局, service_center=+460030934772200, locked=0, error_code=0, seen=1, timed=0, deleted=0, sync_state=2, marker=128121671947195392, source=NTc1MDU0MjYwOTU3NjgyNTY6MDoxMDAwMDoxNjAyODM3NzUyMjMy, bind_id=57505426095768256, mx_status=0, mx_id=NULL, out_time=0, account=901235800, sim_id=1, block_type=0, advanced_seen=3, b2c_ttl=0, b2c_numbers=NULL, fake_cell_type=0, url_risky_type=0, creator=NULL, favorite_date=0, mx_id_v2=NULL, sub_id=-1\n"
}
具体参见adb shell的语法
curl --location 'http://127.0.0.1:30000/read' \
--header 'Content-Type: application/json' \
--data '{"where": "body like '\''%同学您好,请于2022%'\'' and address='\''18952788xxx'\''", "sort": "date DESC"} '
--mode pc
时,执行adb shell content query --uri content://sms/ --where "body like '%同学您好,请于2022%' " --sort "date DESC"
--mode phone
时【默认参数】, 执行content query --uri content://sms/ --where "body like '%同学您好,请于2022%'" --sort "date DESC"
注意
--mode pc
不能使用sort、where的like条件and逻辑等复杂语法,--mode phone
时可以
在Android内部的shell终端内运行使用的是sh
,
实际执行名的命令如下
lmipro:/data/local/tmp $ sh -c "content query --uri content://sms/ --where 'body like \"%同学您好,请于2022%\"' --sort 'date DESC'"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。