Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/interceptors/android/adb-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,23 @@ export async function pushFile(
}

export async function isProbablyRooted(deviceClient: Adb.DeviceClient) {
return run(deviceClient, ['command', '-v', 'su'], {
let hasSu = await run(deviceClient, ['command', '-v', 'su'], {
timeout: 500,
skipLogging: true
})
.then((result) => result.includes('/su'))
.catch(() => false);

if (hasSu) return true;

// Check if we're currently running commands as root.
// Requires the user to have run `adb root` beforehand
return run(deviceClient, ['id'], {
timeout: 500,
skipLogging: true
})
.then((result) => result.includes('uid=0(root)'))
.catch(() => false);
}

const runAsRootCommands = [
Expand Down
Loading