Skip to content

Commit c40888b

Browse files
committed
Make Android isProbablyRooted work with adb root
1 parent aec631f commit c40888b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/interceptors/android/adb-commands.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,23 @@ export async function pushFile(
246246
}
247247

248248
export async function isProbablyRooted(deviceClient: Adb.DeviceClient) {
249-
return run(deviceClient, ['command', '-v', 'su'], {
249+
let hasSu = await run(deviceClient, ['command', '-v', 'su'], {
250250
timeout: 500,
251251
skipLogging: true
252252
})
253253
.then((result) => result.includes('/su'))
254254
.catch(() => false);
255+
256+
if (hasSu) return true;
257+
258+
// Check if we're currently running commands as root.
259+
// Requires the user to have run `adb root` beforehand
260+
return run(deviceClient, ['id'], {
261+
timeout: 500,
262+
skipLogging: true
263+
})
264+
.then((result) => result.includes('uid=0(root)'))
265+
.catch(() => false);
255266
}
256267

257268
const runAsRootCommands = [

0 commit comments

Comments
 (0)