折腾:
【调研】支付宝 蚂蚁森林 自动收集
期间,自己的小米9的安卓10手机,无法用前面调用的各种方式去实现自动手机蚂蚁森林能量
看来只能自己去写代码去实现了。
去搭建uiautomator2的python开发环境。
AutoCollectAliPayAntForestEnery
【已解决】Mac中搭建uiautomator2的开发环境
现在去写代码逻辑
先去启动支付宝
先去搞清楚此处支付宝的id是啥:
【已解决】安卓应用支付宝的包名app id即package id是啥
再去搞清楚:
【已解决】安卓中支付宝的蚂蚁森林页面的activity名称是什么
需要后续代码去能否直接启动到这个页面,才能验证的确是这个activity的name
# 通过指定main activity的方式启动应用,等价于调用am start -n com.example.hello_world/.MainActivity d.app_start("com.example.hello_world", ".MainActivity")
结果代码:
# launch Alipay's AntForest activity startResp = d.app_start(Alipay_PackageId, Alipay_Activity_AntForest) logging.info("startResp=%s", startResp)
报错:
$ curl -X POST -d '{"command": "am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n 'com.eg.android.AlipayGphone/com.alipay.mobile.nebulax.integration.mpaas.activity.NebulaActivity$Main'", "timeout": "60"}' 'http://localhost:49324/shell' xxx connectionpool.py:433 DEBUG http://localhost:49324 "POST /shell HTTP/1.1" 200 2440 xxx.955 Response (45 ms) >>> {"error":{"Stderr":null},"exitCode":255,"output":"Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.eg.android.AlipayGphone/com.alipay.mobile.nebulax.integration.mpaas.activity.NebulaActivity$Main }\nSecurity exception: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.eg.android.AlipayGphone/com.alipay.mobile.nebulax.integration.mpaas.activity.NebulaActivity$Main } from null (pid=31729, uid=2000) not exported from uid 10242\n\njava.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.eg.android.AlipayGphone/com.alipay.mobile.nebulax.integration.mpaas.activity.NebulaActivity$Main } from null (pid=31729, uid=2000) not exported from uid 10242\n\tat com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1089)\n\tat com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:788)\n\tat com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:587)\n\tat com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1388)\n\tat com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:518)\n\tat com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1089)\n\tat com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1063)\n\tat com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3560)\n\tat com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:518)\n\tat com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:172)\n\tat android.os.ShellCommand.exec(ShellCommand.java:104)\n\tat com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10062)\n\tat android.os.Binder.shellCommand(Binder.java:881)\n\tat android.os.Binder.onTransact(Binder.java:765)\n\tat android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4659)\n\tat com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2790)\n\tat android.os.Binder.execTransactInternal(Binder.java:1021)\n\tat android.os.Binder.execTransact(Binder.java:994)\n"} <<< END 20200827 x AutoCollectAliPayAntForestEnery.py:110 INFO startResp=None
看来是没权限启动
只是只启动app
startResp = d.app_start(Alipay_PackageId)
结果:
是可以的
{"error":null,"exitCode":0,"output":"Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.eg.android.AlipayGphone/.AlipayLogin }\n"}
手机页面已启动支付宝了:
不过启动那一刻,支付宝中很多内容还没刷新出来
不过无所谓,后续可以继续操作即可。
继续写代码
【未解决】用uiautomator2在支付宝中寻找并点击启动蚂蚁森林页面