adb command list to perform different functions - android

I have been exploring various options with adb by connecting to real device. Went thru the android documents.
By reading random documents, i found out that i can open a webpage directly by adb using
adb shell am start -a android.intent.action.VIEW -d http://www.wikipedia.org
or i can send BT turn On request using
adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE
I am wondering, if i can find all such functions at one place or how to explore more about what all could be done using adb.

Here is a collection of ADB commands , i am collected from various sites & books
Please go through this . Feel free to ask any doubts regarding these commands

Related

Manage phone calls with node.js using Android

I'm making a node.js app that control calls in android phone, I'm using the npm mudule ADB and was able to make calls as bellow:
adb -s <serialno> shell am start -a android.intent.action.CALL -d tel:123-456
Unfortunately I was not able to manage the audio and control it from my app.
My question is:
Is there a way to send and receive the voice between my application and the phone (Without using any third party like twilio)?
Any help will be appreciated.

How to check whether a service in running on particular port using adb

I have a third party application in my android phone.
The application offers a service at 127.0.0.1:30002.
I don't know the name of service.
Is there a way to find out whether that tcp service is up or not using adb or some other means.
Also what is the use of adb reverse.
Can i run a server in host pc and forward that server on android using adb reverse.
I am completely new to android, so please be brief.
Thanks in advance.
To find which app using specific port:
1. $ cat /proc/net/tcp - This will give you a list of open ports and the UId (unique application ID) of the port's owner.
2. & cat /data/system/packages.list | grep '<The UID you just found>' - This will give you the app name connected to this UID.
3. ps |grep '<the app name>' Will tell you if the app service is running.
What is adb reverse?
adb reverse tells your phone use a port of your local machine (e.g laptop).
Assume you use the command:
adb reverse tcp:80 tcp:3000
Now when your phone tries to access http://localhost:3000/ your request will be routed to localhost:80 of your laptop.

How to toggle turn on/off mobile data with adb command

I looking for toggle my android phone mobile data with adb command. that is usually i do it with touch my mobile data icon in settings.
i found many reference to do it, for example this question , but nothing work for me, i try use:
$ adb shell svc data enable
$ adb shell svc data disable
when i look to my android phone nothing happen.
my android is KitKat 4 and i sure have rooted
Thanks.

Android : simulate / mimic a call programmatically on device

Is it possible to simulate or mimic a call coming in on an Android device programmatically from the device (not connected to a computer)? I am doing a safety demo about the dangers of calls while driving and I would prefer not to have to create my own copy of the call app.
Yes you can!
Use adb for that, for emulators you can also use the android-studio tools.
adb -s <serial> shell am start -a android.intent.action.CALL -d tel:0612345678
Where <serial> should be your device or emulator id (like emulator-5555)
If you want to do it on the device itself, you can try to call yourself (yes it kind of works on most devices).

Detect if ADB server is running on Android?

I am trying to detect if the adb server is running on the Android device for part of an anti-cheating implementation for my free game.
Specifically, I want to stop use of adb shell input tap x,y, since the game is a competitive multiplayer puzzle game.
Things I have tried:
Using battery info I can detect if USB is plugged in. Well, that is also a legit use.
Using Settings.Secure or Settings.Global, I can query ADB_ENABLED, but that always returns 1 if adb is enabled. It DOES NOT take into account adb connected or not!
Querying all system services, but I cannot see anything that looks like an adb service.
At this point, I am out of ideas. Hopefully someone else knows how to do this?
You can check for running adbd process or query init.svc.adbd system property:
$ ps adbd
USER PID PPID VSIZE RSS WCHAN PC NAME
root 14947 1 4596 208 ffffffff 00019358 S /sbin/adbd
$ getprop init.svc.adbd
running
In Android the adb driver is implemented as a function of universal usb driver. You can check the (comma separated) list of currently enabled usb functions to see if it includes "adb":
$ cat /sys/devices/virtual/android_usb/android0/functions
mtp,adb
But you would not be able stop cheating while your app is running completely on the user controlled device.

Categories

Resources