Wireless adb debugging

Wireless adb debugging

images (2)
In my attempts to make terminal clients of whatsapp and paytm, I was consistently asked that if we had to connect it via USB, there is not much fun. So I made this entire experience wireless. This article will explain how to do wireless adb debugging over a network.

What do you need?

  1. Connectbot app: To power wireless connection over ssh.

  2. Adb setup: Use this google guide to set this up.

  3. Same Wifi network for phone and laptop.

 

Lets do it.

  1. Note down ip address of your system. (use ifconfig on linux).

  2. Open Connectbot, Enter your username@hostname for ssh field.

Screenshot_2014-09-28-16-31-43

You should be able to connect to your system terminal after basic authentication clearance.

  1. Long press your newly made connection and select Edit host. Inside Post login automation, add this

adb connect localhost:5555

Screenshot_2014-09-28-16-41-40

ensure to enter an extra [ENTER] after this command and press ok.

  1. Again go back to your connection, long press it and select Edit port forward this time. (Yes, We are going to use port forwarding to make it wireless)

Use settings button to add new port forward and enter this

Nickname: ADB

Type: Remote

Source Port: 5555

Destination: localhost:5555

Screenshot_2014-09-28-16-42-02

save the settings and mobile part is done.

  1. Connect your android to system and enter below command to allow tcpip on 5555 port for adb.

adb tcpip 5555

And you are done. Go wireless now and type adb devices on your system. you should see something like this.

Screen Shot 2014-09-28 at 4.39.54 PM

 

Now go out and try Wireless terminal Whatsapp and Seemless mobile recharge via Paytm.

Paytm AndroidTerminal – Seamless recharge via linux

Paytm AndroidTerminal – Seamless recharge via linux

download (4)

In continuation to my previous attempt to control Whatsapp via command line (If you haven’t read that, Please do before continuing), This guide will allow you to recharge your mobile number via command line using Paytm.

 

Prerequisites:

With all prerequisites as in previous guide still valid (including Android phone attached via data cable to Linux machine), couple of additional ones are

  1. Paytm app – Download here.

  2. A logged in user with paytm wallet balance – Yeah, this guide is not a free recharge guide and will be using Paytm cash from user’s account.

Terminal Commands

1. To unlock your phone

adb shell input keyevent 82

If your phone is locked, this command will unlock it for you. For those who are using screen-locks, it can also be automated but it is again beyond scope of this tutorial.

2. Open Paytm app

As we did for whatsapp, we can open paytm app via stop-start machanism to ensure it to work even though it was open already.

adb shell am force-stop net.one97.paytm
adb shell am start -n net.one97.paytm/.AJRHomePage

3. Ask Recharge number

After reading the recharge number, Tap on recharge number coordinates (270, 650) found by hit and trial.

echo -n "Enter Number:"
read number
adb shell input tap 270 650
adb shell input text $number

4. Ask user for amount he wants to recharge with.

Similar to Number, Tap on coordinates for amount and fed the desired amount in it.

adb shell input tap 270 1050
echo -n "Enter Amount:"
read amount
adb shell input text $amount

5. Get the recharge done

Now to proceed further, you need to tap on back button once to remove keypad screen and then press on Proceed buttons and subsequently tapping on pay with path cash button.
adb shell input tap 270 1850
adb shell input tap 270 1350
adb shell input tap 270 1450
adb shell input tap 990 1650
adb shell input tap 990 1650
adb shell input tap 990 850

6. Close the Paytm app.

Echo a thanks message before closing the app.

echo "Thank you for recharging with Paytm AndroidTerminal \m/"
adb shell am force-stop net.one97.paytm

 

PS: If your android phone is connected to internet via a slow connection, you might need to add appropriate sleep command to make it work.

This entire experience can be automated by saving below commands in a file

adb shell input keyevent 82
adb shell am force-stop net.one97.paytm
adb shell am start -n net.one97.paytm/.AJRHomePage
echo -n "Enter Number:"
read number
adb shell input tap 270 650
adb shell input text $number
adb shell input tap 270 1050
sleep 2
echo -n "Enter Amount:"
read amount
adb shell input text $amount
adb shell input tap 270 1850
adb shell input tap 270 1350
adb shell input tap 270 1450
sleep 2
adb shell input tap 990 1650
sleep 2
adb shell input tap 990 1650
sleep 2
adb shell input tap 990 850
echo "thank you for recharging with command line paytm \m/"
adb shell am force-stop net.one97.paytm

Save it in a file named paytm and make it executable with global access. Now next time you need to recharge, Paytm CommandLine will be at your service.