Python笔记-centos7使用adb连接真实手机及初始化uiautomatro2项目

首先看看各个设备对应的IP

系统 ip
Android 192.168.1.100
windows 192.168.1.190
centos 192.168.79.134

这里3台机器都是能够相互ping通的。

 

windows上安装pyCharm,用这个进行开发。

centos上安装了python3.6.9,并使用了虚拟python环境。

Android是5.1的系统,是qiku的手机。

 

记录下操作演示的步骤:

centos7使用adb连接到Android手机:

这种方式是使用adb wifi去连接的,8681-A01-0xc60fcc9d是usb连接的。

 

进入python虚拟环境,为Android手机安装ATX

source u2_project/venv/bin/activate
python -m uiautomator2 init

在手机上就可以看到安装了个小汽车(ATX)

对应源码:

import time

import uiautomator2 as u2

#通过手机WIFI来进行连接
# d = u2.connect_wifi("192.168.1.103")
# print(d.device_info)
# d.app_start("com.wandoujia.phoenix2")
# time.sleep(10)
# d.app_stop("com.wandoujia.phoenix2")

#USB连接方式连接 手机序列号
d = u2.connect_usb("8681-A01-0xc60fcc9d")
print(d.device_info)

#通过adb wifi也是adb tcpip模式,注意端口号 ip加端口号
# d = u2.connect_adb_wifi("192.168.1.190:5555")
# print(d.info)

这里使用app_start参数为包名,可以使用adb查看目前安装了的包:

adb shell pm list packages

C:\Users\cff>adb shell pm list packages                           dnplayer2
package:com.yulong.modem
package:com.github.uiautomator
package:com.mediatek.gba
package:com.mediatek.ppl
package:com.qiku.blackmagic
package:com.yulong.android.factorypattern
package:com.android.providers.telephony
package:com.qiku.logsystem
package:com.android.providers.calendar
package:com.android.providers.media
package:com.mediatek.fwk.plugin
package:com.android.screenrecord
package:com.xinshuru.inputmethod
package:com.android.wallpapercropper
package:com.yulong.android.ota
package:com.mediatek.schpwronoff
package:com.qiku.android.gmsupdate
package:com.android.yulong.facerecognize
package:com.yulong.android.compass
package:com.yulong.android.register
package:com.android.documentsui
package:com.android.externalstorage
package:com.mediatek.ygps
package:com.android.htmlviewer
package:com.android.mms.service
package:com.yulong.android.coolsafe
package:com.yulong.android.coolshow
package:com.android.providers.downloads
package:com.github.uiautomator.test
package:com.mediatek.engineermode
package:com.qihoo.browser
package:com.android.qikupay.apk
package:com.yulong.android.agpssettings
package:com.mediatek.bluetoothle
package:com.meitu.mtxx_beauty
package:com.android.providers.applications
package:com.yulong.vendetta
package:com.qiku.healthguard
package:com.yulong.thirteen.issuereport
package:com.mediatek.fmradio
package:com.qiku.android.demo
package:com.yulong.android.xtime
package:com.yulong.android.calendar
package:com.yulong.audioelectric
package:com.android.defcontainer
package:com.via.bypass
package:com.android.pacprocessor
package:com.android.certinstaller
package:android
package:com.netease.mobimail.coolpad
package:com.qiku.android.aservice
package:com.android.mms
package:com.android.stk
package:com.android.utk
package:com.yulong.android
package:com.android.backupconfirm
package:com.qihoo360.transfer
package:com.yulong.android.filebrowser
package:com.mediatek.voiceextension
package:com.fansapk.rootex
package:com.mediatek.floatmenu
package:com.android.phasebeam
package:com.mediatek.providers.drm
package:com.android.providers.settings
package:com.mediatek.miravision.ui
package:com.android.sharedstoragebackup
package:com.android.printspooler
package:com.android.dreams.basic
package:com.qihoo360.mobilesafe
package:com.android.webview
package:com.android.sc
package:com.android.inputdevices
package:com.qihoo360.commodity_barcode.qikoo
package:com.mediatek
package:com.yulong.android.memo
package:com.yulong.android.launcher3
package:com.qiku.childrenmode
package:com.icoolme.android.weather
package:com.qiku.android.cloudsync
package:com.mediatek.nlpservice
package:com.qiku.android.privacyspace
package:com.android.server.telecom
package:com.android.keychain
package:com.android.camera
package:com.android.dialer
package:com.android.gallery3d
package:com.android.packageinstaller
package:com.android.remotecore
package:com.svox.pico
package:com.qiku.cardmanager
package:com.qiku.android.virtualnumber
package:com.android.proxyhandler
package:com.qiku.configcenter
package:com.yulong.android.settings
package:com.wandoujia.phoenix2
package:com.yulong.android.mwstarter
package:com.qiku.riskinsight
package:com.android.managedprovisioning
package:com.mediatek.atci.service
package:authentication.information
package:com.android.dreams.phototable
package:com.mediatek.thermalmanager
package:com.android.noisefield
package:com.qiku.android.setupwizard
package:com.mediatek.voicecommand
package:com.android.wallpaper.livepicker
package:com.yulong.android.videoplayer
package:com.kingroot.kinguser
package:com.qihoo.appstore
package:com.yulong.android.cdmaregister
package:com.android.settings
package:com.yulong.android.cp_engmode
package:com.qiku.speech
package:com.android.calculator2
package:com.mediatek.lbs.em2.ui
package:com.qiku.android.configcenter
package:com.android.wallpaper
package:com.qiku.voiceassistant
package:com.android.vpndialogs
package:com.android.settings.wifi
package:com.android.phone
package:com.android.shell
package:com.android.usbui
package:com.android.providers.userdictionary
package:com.leoao.fitness
package:com.mediatek.voiceunlock
package:com.android.location.fused
package:com.android.systemui
package:com.amap.android.location
package:com.yulong.android.diagfw
package:com.qiku.cleaner
package:com.mediatek.mtklogger
package:net.xnano.android.changemymac
package:com.android.settings.bluetooth
package:com.yulong.android.gpsview
package:com.mediatek.apst.target
package:com.qiku.freecall
package:com.yulong.android.soundrecorder
package:com.android.bluetooth
package:com.android.providers.contacts
package:com.android.captiveportallogin
package:com.mediatek.dataprotection
package:com.yulong.android.apperrorstack
package:com.yulong.android.preset

豌豆荚app的包名为:

com.wandoujia.phoenix2

 

 

©️2020 CSDN 皮肤主题: 数字20 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值