Executes the given privileged command on the device
(
cmd, device_id, wait_for_termination=True, timeout=None, do_log=True
)
| 99 | |
| 100 | |
| 101 | def execute_privileged_command( |
| 102 | cmd, device_id, wait_for_termination=True, timeout=None, do_log=True |
| 103 | ): |
| 104 | """Executes the given privileged command on the device""" |
| 105 | if ( |
| 106 | device_id in FANS_PIXEL_2_XL |
| 107 | or (type(device_id) == bytes and b"emulator" in device_id) |
| 108 | or (type(device_id) == str and "emulator" in device_id) |
| 109 | ): |
| 110 | out, err = call_adb( |
| 111 | ["shell", "su root sh -c '{}'".format(cmd)], |
| 112 | device_id=device_id, |
| 113 | wait_for_termination=wait_for_termination, |
| 114 | timeout=timeout, |
| 115 | do_log=do_log, |
| 116 | ) |
| 117 | else: |
| 118 | out, err = call_adb( |
| 119 | ["shell", "su -c '{}'".format(cmd)], |
| 120 | device_id=device_id, |
| 121 | wait_for_termination=wait_for_termination, |
| 122 | timeout=timeout, |
| 123 | do_log=do_log, |
| 124 | ) |
| 125 | if err: |
| 126 | log.debug( |
| 127 | f">>>[{device_id}]>>> error executing privileged cmd. err: {err}" |
| 128 | ) |
| 129 | return out, err |
| 130 | |
| 131 | |
| 132 | def execute_runas_command( |
no test coverage detected