juhbert
juhbert

Reputation: 45

How to detect if an Android app is opened by the user or via remote access (PhoneLink, AnyDesk, TeamViewer, etc.) without root access?

I want to determine whether my Android application is being opened directly by the user on the device or through remote access tools such as PhoneLink, AnyDesk, or TeamViewer. However, the solution must not require root access.

Detecting PhoneLink in particular is crucial, as it allows seamless remote control of the device without explicitly notifying the user, unlike traditional screen-sharing apps. Identifying such remote access scenarios is essential for applying security measures and preventing potential misuse.

Is there a reliable way to detect these conditions using Android’s native APIs without root privileges? Has anyone worked on a similar implementation or has suggestions on how to approach this?

Upvotes: 0

Views: 42

Answers (1)

monblu
monblu

Reputation: 108

You could check the packagename of the calling activity, but a full solution exists only with a cooperating calling activity, using one of the following alternatives:

  • methods getCallingActivity()/getCallingPackage() work only if calling activity uses startActivityForResult() and not startActivity()
  • method getInitialCaller() works from API Level 35, but only if the calling app has called ActivityOptions.setShareIdentityEnabled(true) or the launched activity has the same uid as the calling app or the launched activity is running in a package that is signed with the same key used to sign the platform.
  • methods getLaunchedFromPackage()/getLaunchedFromUid() work from API Level 34, but only if the calling app has called ActivityOptions.setShareIdentityEnabled(true) or the launched activity has the same uid as the calling app or the launched activity is running in a package that is signed with the same key used to sign the platform.

Upvotes: 1

Related Questions