Skip to main content

Root指令

当您使用模拟器或Root的设备时,可以使用该指令

  • 函数
system.shell(command: str, callback: ShellListener = None)
  • 参数
参数类型是否必填说明
commandstrRoot指令
callbackShellListener接口回调对象,请创建一个类继承 ascript.android.system.ShellListener
    • ShellListener
class ShellListener(ABC):
@abstractmethod
def commandOutput(self, i: int, s: str):
#当命令有输出值时
pass

@abstractmethod
def commandTerminated(self, i: int, s: str):
# 当命令被中断时
pass

def commandCompleted(self, i: int, i1: int):
# 当命令执行完毕时
pass
  • 示例
# 修改分辨率
from ascript.android import system
from ascript.android.system import ShellListener

class L(ShellListener):
def commandOutput(self, i: int, s: str):
print('?',s)

def commandTerminated(self, i: int, s: str):
pass

def commandCompleted(self, i: int, i1: int):
pass


res = system.shell('wm size reset',L())