Detect if ADB server is running on Android?

I am trying to determine if the adb server running on an Android device for the anti-cheat implementation part for my free game.

In particular, I want to stop using adb shell input tap x,y , since the game is a competitive multi-player puzzle game.

Things I tried:

  • Using the battery information, I can determine if USB is connected. Well, this is also legal use.

  • Using Settings.Secure or Settings.Global , I can query ADB_ENABLED , but always returns 1 if adb is enabled. It does NOT take into account the connected adb or not!

  • Requesting all system services, but I don't see anything that looks like an adb service.

At this moment I have no ideas. Hope someone else knows how to do this?

+5
source share
2 answers

You can check the adbd process or the init.svc.adbd request 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 the universal usb driver. You can check the usb enabled list of functions at the moment to see if it includes "adb" :

 $ cat /sys/devices/virtual/android_usb/android0/functions mtp,adb 

But you can’t stop cheating while your application is fully running on a user-controlled device.

+6
source

Cannot display input events marked as “synthetic / artificial / monkey”?

static boolean isUserAMonkey () Returns "true" if the user interface is currently running by a monkey.

-1
source

Source: https://habr.com/ru/post/1210831/


All Articles