Skip to content

Instantly share code, notes, and snippets.

@milis92
Created April 27, 2020 06:44
Show Gist options
  • Select an option

  • Save milis92/5f5405e426018b08506424f9338bc5aa to your computer and use it in GitHub Desktop.

Select an option

Save milis92/5f5405e426018b08506424f9338bc5aa to your computer and use it in GitHub Desktop.
task getDeviceIp {
doLast {
new ByteArrayOutputStream().withStream { os ->
exec {
commandLine(android.getAdbExe())
args('shell', 'ip', 'addr', 'show', 'wlan0', ' | grep', '\'inet \'', '| cut -d\' \'', '-f6', '|cut -d/', '-f1')
standardOutput = os
}
ext.deviceIp = os.toString().trim()
}
}
}
task enableWifyDebug {
dependsOn getDeviceIp
doFirst {
exec {
commandLine(android.getAdbExe())
args('tcpip', '5555')
}
}
doLast {
exec {
commandLine(android.getAdbExe())
args('connect', getDeviceIp.deviceIp)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment