@@ -168,8 +168,12 @@ def adb(self, *args: str, text: bool = True, shell: bool = False,
168
168
commands = self .get_base_command (args )
169
169
packed_commands = self .pack_commands (commands , shell , quote )
170
170
171
+ # Force UTF-8 for text output
172
+ encoding = 'utf-8' if text else None
173
+
171
174
# Invoke the command
172
- rep = sp .run (packed_commands , check = check , shell = shell , text = text ,
175
+ rep = sp .run (packed_commands , check = check , shell = shell ,
176
+ text = text , encoding = encoding ,
173
177
stdin = sp .DEVNULL , stdout = sp .PIPE , stderr = sp .PIPE )
174
178
175
179
# Return the output
@@ -219,11 +223,14 @@ def adb_async(self, *args: str, text: bool = True, shell: bool = False,
219
223
commands = self .get_base_command (args )
220
224
packed_commands = self .pack_commands (commands , shell , quote )
221
225
226
+ # Force UTF-8 for text output
227
+ encoding = 'utf-8' if text else None
228
+
222
229
# Sink inputs to DEVNULL to stop the child process stealing keyboard
223
230
# Sink outputs to DEVNULL to stop full output buffers blocking child
224
231
# pylint: disable=consider-using-with
225
232
process = sp .Popen (packed_commands ,
226
- text = text , shell = shell ,
233
+ text = text , encoding = encoding , shell = shell ,
227
234
stdin = sp .DEVNULL , stdout = output , stderr = sp .DEVNULL )
228
235
229
236
# Return the output process a user can use to wait, if needed.
@@ -258,9 +265,12 @@ def adb_run(self, *args: str, text: bool = True, shell: bool = False,
258
265
commands .extend (args )
259
266
packed_commands = self .pack_commands (commands , shell , quote )
260
267
268
+ # Force UTF-8 for text output
269
+ encoding = 'utf-8' if text else None
270
+
261
271
# Invoke the command
262
272
rep = sp .run (packed_commands ,
263
- check = check , shell = shell , text = text ,
273
+ check = check , shell = shell , text = text , encoding = encoding ,
264
274
stdin = sp .DEVNULL , stdout = sp .PIPE , stderr = sp .PIPE )
265
275
266
276
# Return the output
@@ -298,9 +308,12 @@ def adb_runas(self, *args: str, text: bool = True, shell: bool = False,
298
308
commands .extend (args )
299
309
packed_commands = self .pack_commands (commands , shell , quote )
300
310
311
+ # Force UTF-8 for text output
312
+ encoding = 'utf-8' if text else None
313
+
301
314
# Invoke the command
302
315
rep = sp .run (packed_commands ,
303
- check = check , shell = shell , text = text ,
316
+ check = check , shell = shell , text = text , encoding = encoding ,
304
317
stdin = sp .DEVNULL , stdout = sp .PIPE , stderr = sp .PIPE )
305
318
306
319
# Return the output
0 commit comments