How to detect a remote access app is running on Android 10 device
Asked Answered
D

2

7

I am developing an Android application. There is a requirement that the app doesn't allow users to use the app if they are controlling the device remotely via WiFi using some apps like Air Droid, TeamViewer... In Android 9 and below, I can query the network statistics to detect if those apps are obtaining some ports to enable remote controlling. But from Android 10, Google doesn't allow app to query network statistics anymore by denying access to /proc/net directory: https://developer.android.com/about/versions/10/privacy/changes#proc-net-filesystem

Is there an alternative solution for this requirement?

Thank you for your help.

Deroo answered 26/8, 2020 at 10:0 Comment(4)
Why does this not suit you? Quote: Apps that need access to this information, such as VPNs, should use the NetworkStatsManager or ConnectivityManager class.Bank
Using ConnectivityManager couldn't help to identify which app is using network. NetworkStatsManager provides methods to query data usage of an app but it doesn't measure data usage in fine grain of time. It only provides data usage history of an app in a bucket of 120 minutes. So, it doesn't help me to solve my problem, too.Deroo
Are those other apps using fixed ports?Bank
How did you resolve this issue?Kink
D
4

Instead of looking at network ports, I tested out some methods to try and directly get a list of the running apps on an Android 12 device. Didn't manage to get much out of this but it might help save you some time in case anyone was wondering about going down this direction...

  • ActivityManager.getRunningTasks(): Known to work up to Android 4.4 (API 19); on Android 12 it only returns details of the calling app.
  • ActivityManager.getRunningAppProcess(): Known to work up to Android 5.1 (API 22); on Android 12 it only returns details of the calling app.
  • Reading /proc via this library (https://github.com/jaredrummler/AndroidProcesses/): Known to work up to Android 6.0 (API 23); on Android 12 didn't return any info.
Dragonroot answered 27/5, 2022 at 13:50 Comment(1)
@SandeshKhutalSaheb Do you have a better answer? If so, please share your answer, and we can maybe extend the bounty time?Ial
P
0

I used getDisplays() of DisplayManager

When a remote session is active, it returns > 1 If no remote session, it returns 1

Propertius answered 3/9 at 8:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.