mirror of
https://github.com/zhaarey/AppleMusicDecrypt.git
synced 2025-10-23 15:11:06 +00:00
fix: adapt Android Emulator
This commit is contained in:
18
src/adb.py
18
src/adb.py
@@ -44,12 +44,18 @@ class Device:
|
||||
raise ADBConnectException
|
||||
self.device = self.client.device(f"{host}:{port}")
|
||||
|
||||
def _execute_command(self, cmd: str, su: bool = False) -> Optional[str]:
|
||||
if su:
|
||||
cmd = cmd.replace("\"", "\\\"")
|
||||
output = self.device.shell(f"{self.suMethod} \"{cmd}\"")
|
||||
else:
|
||||
output = self.device.shell(cmd, timeout=30)
|
||||
def _execute_command(self, cmd: str, su: bool = False, sh: bool = False) -> Optional[str]:
|
||||
whoami = self.device.shell("whoami")
|
||||
final_cmd = cmd
|
||||
if whoami.strip() != "root" and su:
|
||||
if self.suMethod == "su -c":
|
||||
replaced_cmd = cmd.replace("\"", "\\\"")
|
||||
final_cmd = f"{self.suMethod} \"{replaced_cmd}\""
|
||||
else:
|
||||
final_cmd = f"{self.suMethod} {final_cmd}"
|
||||
if sh:
|
||||
final_cmd = f"sh -c '{final_cmd}'"
|
||||
output = self.device.shell(final_cmd, timeout=30)
|
||||
if not output:
|
||||
return ""
|
||||
return output
|
||||
|
||||
@@ -43,7 +43,7 @@ class NewInteractiveShell:
|
||||
logger.add(lambda msg: print_formatted_text(ANSI(msg), end=""), colorize=True, level="INFO")
|
||||
|
||||
for device_info in self.config.devices:
|
||||
device = Device(frida_path=device_info.fridaPath)
|
||||
device = Device(frida_path=device_info.fridaPath, su_method=device_info.suMethod)
|
||||
device.connect(device_info.host, device_info.port)
|
||||
logger.info(f"Device {device_info.host}:{device_info.port} has connected")
|
||||
self.devices.append(device)
|
||||
|
||||
@@ -13,6 +13,7 @@ class Device(BaseModel):
|
||||
port: int
|
||||
agentPort: int
|
||||
fridaPath: str
|
||||
suMethod: str
|
||||
|
||||
|
||||
class Download(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user