Skip to content

How run commands (pm install) when adb shell need enter password #678

Answered by dstarkoff
dstarkoff asked this question in Q&A
Discussion options

You must be logged in to vote

Im have a solution (use core functions of package):

const process = await adb.subprocess.shell('pm install -r ' + `/data/local/tmp/${file.name}`),
          writer = process.stdin.getWriter(),
          decoder = new TextDecoder();
    let   accumulatedOutput = '';

    setInstalStatus("installing");

    process.stdout.pipeTo(
      new WritableStream({
        async write(chunk) {
          const output = decoder.decode(chunk);
          accumulatedOutput += output; // console.log(accumulatedOutput)
          if (accumulatedOutput.includes("please input verify password:")) {
            await writer.write(new TextEncoder().encode("adb36987\n"));
            accumulatedOutput = '';
     …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@dstarkoff
Comment options

@dstarkoff
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by dstarkoff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants