Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove handle_adb_error for droidcast.py #3170

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

cangular
Copy link
Contributor

@cangular cangular commented Oct 1, 2023

类似于#1167,Mac在待机后过一段时间就找不到adb了,需要用adb_reconnect来找
但当使用droidcast作为截图方法的时候,driodcast会直接用本地缓存的数据来create forward,但此时由于adb找不到device,所以会直接报adberror(),然后进去retry,然后由于具体的error为空字符串,这时候AzurLaneAutoScript/module/device/method/utils.py中的handle_adb_error(e)会直接break,但是其实这时候直接adb_reconnect就可以修复,所以我直接把droidcast中的handle_adb_error直接去掉了,这样不管碰到怎么样的adb_error都会尝试进行adb_reconnect。
坏处是这样的话droidcast中的retry_wrapper会和其他地方的retry_wrapper不一样,还有一种方案是直接把AzurLaneAutoScript/module/device/method/utils.py中的handle_adb_error的else改成return true,这样的话也是无论碰到什么adb_error都会尝试adb_reconnect。

remove adb check condition for droidcast
@cangular cangular changed the title remove handl droidcast.py remove handle_adb_error for droidcast.py Oct 1, 2023
@LmeSzinc
Copy link
Owner

LmeSzinc commented Oct 1, 2023

需要判断你遇到的异常并处理,同时 其他异常处理必须按照原样进行,否则这个PR不会被接受

@cangular cangular changed the base branch from master to dev October 1, 2023 12:40
@cangular
Copy link
Contributor Author

cangular commented Oct 1, 2023

好了

@LmeSzinc LmeSzinc added the bug / 缺陷 Something isn't working label Oct 5, 2023
@LmeSzinc
Copy link
Owner

LmeSzinc commented Oct 5, 2023

异常在 Connection.adb_forward() 和 Connection.adb_reverse() 内捕获,看你是在 adb.forward_list() 上有问题还是 adb.forward()

def adb_forward(self, remote):
"""
Do `adb forward <local> <remote>`.
choose a random port in FORWARD_PORT_RANGE or reuse an existing forward,
and also remove redundant forwards.
Args:
remote (str):
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
Returns:
int: Port
"""
port = 0
for forward in self.adb.forward_list():
if forward.serial == self.serial and forward.remote == remote and forward.local.startswith('tcp:'):
if not port:
logger.info(f'Reuse forward: {forward}')
port = int(forward.local[4:])
else:
logger.info(f'Remove redundant forward: {forward}')
self.adb_forward_remove(forward.local)
if port:
return port
else:
# Create new forward
port = random_port(self.config.FORWARD_PORT_RANGE)
forward = ForwardItem(self.serial, f'tcp:{port}', remote)
logger.info(f'Create forward: {forward}')
self.adb.forward(forward.local, forward.remote)
return port

@cangular
Copy link
Contributor Author

cangular commented Oct 9, 2023

在adb.forward()上面有问题,forward_list是空的。local其实是没有的因为这个时候找不到adb device,但是直接用会直接报个adberror()的错误。没有报adberror(device xxx not found)可能是因为没有用到adb_shell()来调用forward。

@cangular
Copy link
Contributor Author

cangular commented Oct 9, 2023

这样就会报adberror(device xxx not found)了

@cangular
Copy link
Contributor Author

好像用adb_shell 来调用forward会连不上,还是回调吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / 缺陷 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants