4

I have an android native application which hosts a web server inside it. I want to know which application makes requests before they are processed by my application. What I have is the port of the calling application.

How can I find out which application is using this port? I've tried looking for all processes (cat /proc/net/tcp6), but the application with the port I have is not listed (on a rooted device it is). I also tried playing with lots of options of the netstat command, but I don't get any valuable information.

I need to find a way to find the calling application name on a regular device (not rooted).

Gary
  • 13,303
  • 18
  • 49
  • 71

1 Answers1

0

The uid is a field in /proc/net/tcp6, which at least of the moment is readable from an unprivileged app.

Then you can use PackageManager.getNameForUid()

That said, your goal seems like an odd design.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117