-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59c7d45
commit c665135
Showing
4 changed files
with
108 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {Platform} from '../interfaces'; | ||
import {execBinarySync} from './sdk'; | ||
import Logger from '../../../logger'; | ||
import inquirer from 'inquirer'; | ||
|
||
export async function connectToWifiADB(adbLocation: string, platform: Platform): Promise<boolean> { | ||
try { | ||
const deviceList = execBinarySync(adbLocation, 'adb', platform, 'devices -l'); | ||
if (deviceList !== null) { | ||
if (!deviceList.toString().includes('transport_id')) { | ||
Logger.log('No devices found. Please connect a device and try again.'); | ||
|
||
return false; | ||
} | ||
} | ||
|
||
const deviceIPAnswer = await inquirer.prompt({ | ||
type: 'input', | ||
name: 'deviceIP', | ||
message: 'Enter the IP address of your device:' | ||
}); | ||
const deviceIP = deviceIPAnswer.deviceIP; | ||
|
||
const portAnswer = await inquirer.prompt({ | ||
type: 'input', | ||
name: 'port', | ||
message: 'Enter the desired port number:' | ||
}); | ||
const port = portAnswer.port; | ||
|
||
const pairingCodeAnswer = await inquirer.prompt({ | ||
type: 'input', | ||
name: 'pairingCode', | ||
message: 'Enter the pairing code displayed on your device:' | ||
}); | ||
const pairingCode = pairingCodeAnswer.pairingCode; | ||
|
||
const pairing = execBinarySync(adbLocation, 'adb', platform, `pair ${deviceIP}:${port} ${pairingCode}`); | ||
if (pairing !== null) { | ||
Logger.log(pairing.toString()); | ||
} | ||
|
||
const finalPortAnswer = await inquirer.prompt({ | ||
type: 'input', | ||
name: 'finalPort', | ||
message: 'Enter port number to connect:' | ||
}); | ||
const finalPort = finalPortAnswer.finalPort; | ||
|
||
execBinarySync(adbLocation, 'adb', platform, `connect ${deviceIP}:${finalPort}`); | ||
Logger.log('Connected to device wirelessly.'); | ||
|
||
return true; | ||
} catch (error) { | ||
Logger.log('Error connecting to wifi ADB'); | ||
console.error('Error:', error); | ||
|
||
return false; | ||
} | ||
} |