Mustafa
Mustafa

Reputation: 981

Block internet access for some parts of the code in Android

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.

Upvotes: 0

Views: 1193

Answers (2)

Daniel Conde Marin
Daniel Conde Marin

Reputation: 7742

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.

Upvotes: 0

Kristopher Micinski
Kristopher Micinski

Reputation: 7672

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.

Upvotes: 1

Related Questions