-
On my car headunit (Changan, Android 9) I have a needPushMkdirWorkaround as TRUE and my process stopped on sync.write call because shell on my device need password (verify). Keeps hanging await this._adb.subprocess.spawnAndWait([ this
|
Beta Was this translation helpful? Give feedback.
Answered by
yume-chan
Sep 21, 2024
Replies: 1 comment 2 replies
-
If shell commands all require the password, you might be able to patch the transport object to enter the password automatically: import { Adb, AdbServerClient, decodeUtf8, encodeUtf8 } from "@yume-chan/adb";
import { AdbServerNodeTcpConnector } from "@yume-chan/adb-server-node-tcp";
import { TransformStream, WritableStream } from "@yume-chan/stream-extra";
// Get your transport object normally, here I used server transport as an example
async function getTransport() {
const client = new AdbServerClient(
new AdbServerNodeTcpConnector({ host: "127.0.0.1", port: 5037 })
);
const devices = await client.getDevices();
if (!devices.length) {
console.error("No devices found.");
process.exit(1);
}
return await client.createTransport(devices[0]);
}
const transport = await getTransport();
const originalConnect = transport.connect;
transport.connect = async (service) => {
if (!service.startsWith("shell")) {
return originalConnect.call(transport, service);
}
const socket = await originalConnect.call(transport, service);
const writer = socket.writable.getWriter();
socket.readable = socket.readable.pipeThrough(
new TransformStream({
async transform(chunk, controller) {
if (decodeUtf8(chunk).includes("please input verify password:")) {
await writer.write(encodeUtf8("adb36987\n"));
return;
}
controller.enqueue(chunk);
},
})
);
socket.writable = new WritableStream({
write(chunk) {
return writer.write(chunk);
},
close() {
return writer.close();
},
abort() {
return writer.abort();
},
});
return socket;
};
const adb = new Adb(transport);
const output = await adb.subprocess.spawnAndWait("ls");
console.log(output); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
dstarkoff
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If shell commands all require the password, you might be able to patch the transport object to enter the password automatically: