1 Star 0 Fork 0

谷牧溪 / AndriodSMSAdapter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

AndriodSMSAdapter

环境准备

安卓手机打开开发者模式,允许调试,USB连接PC授权信任 可参照 https://cloud.tencent.com/developer/article/1889583

运行调试

go mod tidy
go run main.go -l DEBUG --mode pc --port 30000

编译AMR二进制文件

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")

测试API服务

测试服务器启动状态

$ 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时可以

sh

在Android内部的shell终端内运行使用的是sh, 实际执行名的命令如下

lmipro:/data/local/tmp $ sh -c "content query --uri content://sms/ --where 'body like \"%同学您好,请于2022%\"'  --sort 'date DESC'"

空文件

简介

通过API服务读取安卓短信 展开 收起
Go 等 2 种语言
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/toddler/andriod-smsadapter.git
git@gitee.com:toddler/andriod-smsadapter.git
toddler
andriod-smsadapter
AndriodSMSAdapter
main

搜索帮助