Skip to content

Commit

Permalink
Merge branch 'main' into docs-hide
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Jan 5, 2024
2 parents 8d9ff15 + 79b382c commit c0a1206
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/core/engine/command/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,29 @@ export class AndroidCommand {
}
} else throw new Error('Android is not configured');
}

/**
* Runs a shell command on the connected Android device as the root user.
* This method requires the Android device to be properly configured and that you
* rooted the device.
*
* @async
* @param {string} command - The shell command to run on the Android device as root.
* @returns {Promise<string>} A promise that resolves with the result of the command or rejects if there's an error.
* @throws {Error} Throws an error if Android is not configured or if the command fails.
*/
async shellAsRoot(command) {
if (isAndroidConfigured(this.options)) {
log.debug('Run %s', command);
try {
this.a = new Android(this.options);
return this.a._runAsRootAndGet(command);
} catch (error) {
log.error('Could not run shell command as root %s', command, error);
throw new Error(
`Could not run Android shell commmand as root ${command}`
);
}
} else throw new Error('Android is not configured');
}
}

0 comments on commit c0a1206

Please sign in to comment.