## One Android Device mapping to One Docker Container using udev and cgroup
安卓USB设备与容器一一对应

* host udev rule setup
```
cp ./bin/* /usr/bin
cp -f 99-detect.rules /etc/udev/rules.d/
service udev restart
udevadm trigger
```
* android_udev_stf_container image build
```
docker build -t nuaays/android_stf .
```
* simple docker image only with adb
```
nuaays/android_stf:adb
```
* docker image with stf and rethinkdb
```
nuaays/android_stf:stf
```
* launch rethinkdb using container
```
docker run --net=host --name=rethink -v "$PWD/rethink_data:/data" -d rethinkdb
```
## Monitor the change on USB by udevadm monitor command
- just get event
```
udevadm monitor -u --subsystem-match=usb
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
UDEV [7720.921717] remove /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.1 (usb)
UDEV [7720.929956] remove /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.0 (usb)
UDEV [7720.932053] remove /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2 (usb)
UDEV [7724.501340] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2 (usb)
UDEV [7724.505189] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.0 (usb)
UDEV [7724.510521] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.1 (usb)
```
- get both event and enviroment
```
udevadm monitor -u --subsystem-match=usb --environment
```
the result are as follows:
```
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
UDEV [9202.807021] remove /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.1 (usb)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.1
DEVTYPE=usb_interface
ID_VENDOR_FROM_DATABASE=Google Inc.
INTERFACE=255/66/1
MODALIAS=usb:v18D1p9025d0231dc00dsc00dp00icFFisc42ip01in01
PRODUCT=18d1/9025/231
SEQNUM=8566
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=8475333643
UDEV [9202.827430] remove /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.0 (usb)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.0
DEVTYPE=usb_interface
ID_VENDOR_FROM_DATABASE=Google Inc.
INTERFACE=8/6/80
MODALIAS=usb:v18D1p9025d0231dc00dsc00dp00ic08isc06ip50in00
PRODUCT=18d1/9025/231
SEQNUM=8565
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=8475332701
UDEV [9202.828414] remove /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2 (usb)
ACTION=remove
BUSNUM=001
DEVNAME=/dev/bus/usb/001/011
DEVNUM=011
DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=Android
ID_MODEL_ENC=Android
ID_MODEL_ID=9025
ID_REVISION=0231
ID_SERIAL=Android_Android_724e5658
ID_SERIAL_SHORT=724e5658
ID_USB_INTERFACES=:080650:ff4201:
ID_VENDOR=Android
ID_VENDOR_ENC=Android
ID_VENDOR_FROM_DATABASE=Google Inc.
ID_VENDOR_ID=18d1
MAJOR=189
MINOR=10
PRODUCT=18d1/9025/231
SEQNUM=8567
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=8475321439
UDEV [9212.816382] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2 (usb)
ACTION=add
BUSNUM=001
DEVNAME=/dev/bus/usb/001/012
DEVNUM=012
DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2
DEVTYPE=usb_device
DRIVER=usb
ID_BUS=usb
ID_MODEL=Android
ID_MODEL_ENC=Android
ID_MODEL_ID=9025
ID_REVISION=0231
ID_SERIAL=Android_Android_724e5658
ID_SERIAL_SHORT=724e5658
ID_USB_INTERFACES=:080650:ff4201:
ID_VENDOR=Android
ID_VENDOR_ENC=Android
ID_VENDOR_FROM_DATABASE=Google Inc.
ID_VENDOR_ID=18d1
MAJOR=189
MINOR=11
PRODUCT=18d1/9025/231
SEQNUM=8568
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=9212815498
UDEV [9212.833764] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.0 (usb)
.MM_USBIFNUM=00
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.0
DEVTYPE=usb_interface
DRIVER=usb-storage
ID_VENDOR_FROM_DATABASE=Google Inc.
INTERFACE=8/6/80
MODALIAS=usb:v18D1p9025d0231dc00dsc00dp00ic08isc06ip50in00
PRODUCT=18d1/9025/231
SEQNUM=8569
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=9212823278
UDEV [9212.852586] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.1 (usb)
.MM_USBIFNUM=01
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-2/1-2:1.1
DEVTYPE=usb_interface
ID_VENDOR_FROM_DATABASE=Google Inc.
INTERFACE=255/66/1
MODALIAS=usb:v18D1p9025d0231dc00dsc00dp00icFFisc42ip01in01
PRODUCT=18d1/9025/231
SEQNUM=8572
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=9212838805
```
## Reference
* http://www.jianshu.com/p/8632c728325e
* https://testerhome.com/topics/6112
* https://github.com/openstf/stf/blob/e3d87f253a9536bf7d6185bf023cdd5abaa04247/doc/DEPLOYMENT.md

徐浪老师
- 粉丝: 9536
最新资源
- 基于Spring Boot 和 WxJava 实现的微信小程序Java后端Demo.zip
- 小红书抓取,微信小程序,抓包工具.zip
- 微信小程序蓝牙.zip
- 微信小程序版妹纸图.zip
- A192基于springboot+vue的协作机器人门户网站(LW文档+完整前后端代码+sql脚本+开发文档+全套软件)
- 微信小程序RSA签名验签加密解密.zip
- chartjs微信小程序适配.zip
- 微信小程序Redux绑定.zip
- swoft-elasticsearch搜索引擎包-基于Swoft框架的高性能Elasticsearch集成组件-提供全文搜索数据索引分布式查询聚合分析实时数据处理日志管理.zip
- 微信小程序-图书共享预定.zip
- 微信小程序摄影简介模块.zip
- 一个探索性的人工智能桌面应用程序,具有对象树、交叉表和聊天树,用于深度对话分析 无缝导入您的ch…
- A193基于Springboot+vue的宠物共享平台(LW文档+完整前后端代码+sql脚本+开发文档+全套软件)
- 中国地级市CO2排放数据(2000-2023年)
- A193基于Springboot+vue的宠物共享平台(LW文档+完整前后端代码+sql脚本+开发文档+全套软件)
- 700万+各区县-各行业大类企业注册、存续、注销统计数据(1950-2022年)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


