3

In order to test and control my regular android application, I wrote a command line Linux test program and used adb shell to execute this test program.

I can send a broadcast or start an activity to/from my android application indirectly by executing commands such as am via exec, but I can't directly establish a Binder connection between my android application like getService()/startActivityForResult()/bindService().

My Linux executable is also not a privileged program, so I should not be able to use ServiceManager to publish my services directly in the system.

Is there any way for me to establish a Binder connection with a regular application?

Lino
  • 5,084
  • 3
  • 21
  • 39
progquester
  • 1,228
  • 14
  • 23

1 Answers1

0

Unfortunately you can't.. The Binder interface is restricted to system-level processes or applications with appropriate permissions. A non-privileged Linux native executable in Android cannot directly establish a Binder connection with a regular application.

Nova
  • 406
  • 2
  • 13
  • Thank you very much! Would you please provide some official references or some details on it? What is the exact mean of 'appropriate permissions'? – progquester Jan 31 '23 at 01:30
  • The exact meaning of "appropriate permissions" refers to the Android system permissions required to access Binder. Only system-level processes or applications with the appropriate permissions can access the Binder interface. you can refer to the following official references: Android Binder IPC - https://source.android.com/docs/core/architecture/hidl/binder-ipc Android Inter-Process Communication (IPC) - https://proandroiddev.com/ipc-techniques-for-android-45d815ac59be (not official but a good one) – Nova Jan 31 '23 at 09:52
  • thanks. But, a normal native process can access Binder by `ServiceManager.getService()` by service name. What's the appropriate permission? Links you provided I can not find any information for the APPROPRIATE permission. Can you give me a name about it? – progquester Jan 31 '23 at 12:05
  • The ServiceManager interface is also restricted and can only be used by system-level processes or applications with appropriate permissions.. Regarding the "appropriate permission", it's not a specific permission that can be declared in the manifest, but rather a set of privileges that the process must have in order to use the ServiceManager interface. In other words, the process must be running as a privileged system user (e.g. root or shell). – Nova Jan 31 '23 at 15:10
  • And this information can be found in the source code of the Android framework, specifically in the service manager header file. In this header file, the ServiceManager interface is defined as a system-level service, and the methods are not available to ordinary applications. – Nova Jan 31 '23 at 15:11