Skip to content

Commit

Permalink
perf: 🐛 Improve wireless connection verification method
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Jan 2, 2025
1 parent 21389a9 commit 69fecc3
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions electron/exposes/adb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,39 @@ async function battery(id) {
}

async function pair(host, port, code) {
return shell(`pair ${ipv6Wrapper(host)}:${port} ${code}`)
const { stderr, stdout } = await shell(`pair ${ipv6Wrapper(host)}:${port} ${code}`)

if (stderr) {
throw stderr
}

return stdout
}

async function connect(host, port = 5555) {
return shell(`connect ${ipv6Wrapper(host)}:${port}`)
const { stderr, stdout } = await shell(`connect ${ipv6Wrapper(host)}:${port}`)

if (stderr) {
throw stderr
}

const errorKeys = ['cannot', 'failed']

if (errorKeys.some(item => stdout.includes(item))) {
throw stdout
}

return stdout
}

async function disconnect(host, port = 5555) {
return shell(`disconnect ${ipv6Wrapper(host)}:${port}`)
const { stderr, stdout } = await shell(`disconnect ${ipv6Wrapper(host)}:${port}`)

if (stderr) {
throw stderr
}

return stdout
}

function init() {
Expand Down

0 comments on commit 69fecc3

Please sign in to comment.