Is it possible to do on Android? I want to block Internet access before running some code then resume it after the code is finished executing on Android.
-
2what exactly do u want?..its ur code u can do anything with it.. – bakriOnFire May 25 '13 at 17:01
-
@bakriOnFire usually it's because you want to do something like run an untrusted script or piece of code that you don't want to access the internet. – Kristopher Micinski May 25 '13 at 17:17
2 Answers
You can't do this in Android because sandboxing happens at the application level. That is to say that if your app has the INTERNET
permission, then anything in the app can access the internet.
The correct way to get around this would be to put the other code in another app that doesn't have the internet permission and call to it via AIDL.
There are ways to get around this, you could write an interpreter for a mini language that doesn't have the ability to access the internet (at which point you would have to show the interpeter couldn't be coerced to do that) or do static analysis on the code you're going to call. But fundamentally if the other code is potentially malicious the only way to ensure that internet access cannot occur at the OS level is to remove the internet permission.

- 7,572
- 3
- 29
- 34
-
1@ShardaSingh that is completely incorrect. How do you think native code, code running in a service, etc.. can access the internet? Also, what happens if one part of the app passes information to another via a thread, then that defeats the solution you mentioned. – Kristopher Micinski May 25 '13 at 17:03
-
@Sharda Singh what do you mean by activity's 'pwn permission'? There's no such place anywhere. – Alexander Kulyakhtin May 25 '13 at 17:07
For instance, there is no programatically way to set permissions in the Manifest(like Internet permissions), since for security reasons, users must be aware of application's permissions, check this out.

- 1
- 1

- 7,588
- 4
- 35
- 44