openatx / adbutils

pure python adb library for google adb service.
MIT License
761 stars 175 forks source link

add open_local function(get file-like stream object directly instead … #27

Closed hfutxqd closed 3 years ago

hfutxqd commented 4 years ago

add open_local function(get file-like stream object directly instead of tcp forward)

example:
get a minitouch writable stream: adb.open_local('localabstract:minitouch', 'wb')

codeskyblue commented 4 years ago

已经有forward这个功能了

hfutxqd commented 4 years ago

已经有forward这个功能了

forward需要占用一个本地端口

codeskyblue commented 3 years ago

不好意思现在才处理这个问题,我本地测试了一下。有点不好使

f = adbutils.adb.open_local("CTN5T20410005246", "/sdcard/tmp.txt")

报这个异常

----> 1 f = adbutils.adb.open_local("CTN5T20410005246", "/sdcard/tmq.jar")

~/OpenProjects/adbutils/adbutils/__init__.py in open_local(self, serial, path, mode)
    316         else:
    317             c.send_command('localfilesystem:' + path)
--> 318         c.check_okay()
    319         return c.conn.makefile(mode)
    320 

~/OpenProjects/adbutils/adbutils/__init__.py in check_okay(self)
    150         data = self.read_string(4)
    151         if data == _FAIL:
--> 152             raise AdbError(self.read_string_block())
    153         elif data == _OKAY:
    154             return

AdbError: closed
hfutxqd commented 3 years ago

你可以参考这里: https://cs.android.com/android/platform/superproject/+/master:packages/modules/adb/SERVICES.TXT

hfutxqd commented 3 years ago

这里的path不能打开真正的文件,只能打开socket 要打开本地文件,应该使用 dev:

codeskyblue commented 3 years ago

Manually merged in https://github.com/openatx/adbutils/commit/a1ea667be71e1c7b358edbe8c78e153c4e0f7e98