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?
If you're already on Ice Cream Sandwich, go to Settings > Developer options and tick “Android debugging” or “USB debugging.” A result like that (where the X's represent your device's actual serial number) confirms that your ADB is set up and working.
You can verify that your device is connected by executing adb devices from the android_sdk /platform-tools/ directory. If connected, you'll see the device name listed as a "device." Note: When you connect a device running Android 4.2.
To know if the service is currently started or stopped, look for app=ProcessRecord(...) or app=null respectively. while inside of your shell. If my application is a system application, will be it be displayed with "adb shell service list" command? "adb shell dumpsys activity services myservice" worked like a charm.
Next type cd platform-tools : Then type ls (or dir on Windows). You should see adb or adb.exe depending on your operating system. From here you can type ./adb and see some program output.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With