When you import third party APIs (packet dependency injection, generated libraries, source code, etc) in your Android project, you assume they will behave as advertised. Most of the times code is not open source, it is obfuscated or just compiled.
Is there a way to control the access of this APIs to important system resources such as network, contacts, video and audio, location?
The best approach would be to provide a proxy
to them for the system resources. This would have the following benefits:
- Tests could be performed by providing mock data in the proxies
- Your application would not have to provide all the permissions the API require if they are not necessary and the proxy would allow the API to not break because of permission by emulating permission granted
- Filter possible data collected locally about user and sent to an API home repo, used for advertising or malicious intent
I have failed to find how one such solution can be implemented since the user's defined activities and services can not control the services of the third party APIs or even prevent them for making direct calls to any Android public interface.
The solution should not require root access, since you do not want to have this control outside the boundaries of your own app.
The content of this question is linked to several questions which address particularities of this broad question (log data of content providers, network requests - that got me to think of this problem while researching an answer for it)
Note: The short answer is no, but one can be creative enough (maybe going for native level hacks may resolve this issue - idk)