I'm a PHP developer, but I'm now finishing Android App that different developer started.
One of the requirements is to make it possible to disallow mobile connection. For that I already created checkbox preference on settings page I got.
But I can't find correct way to globaly disallow my app to use mobile connection for data transactions. I don't need to disable connection, I just need to forbid my app to use it and use only WiFi. I got too much places, where connection is done and no time to refactor it.
TL;DR
I need to globally forbid my app to use mobile connection without disabling connection itself.
Just can say one thing is that Android allows to turn on/off WiFi manually only because of security.
Related
I would like to create logfiles of the activities on my Android phone.
The goal is to be able to trace back any suspicious activities of apps and check if the phone's been hacked.
In this question someone suggested using a proxy server.
But using a proxy changes the ip used and a lot of services (i.e. Netflix) block mobile traffic coming from either server ip's or home ip's when making mobile requests.
The question is already 3.5 years old so maybe the options have changed.
As for the network traffic an option to setup a local proxy on the device itself with a possibility to set logging rules would work though.
How could you setup a local proxy on an Android device?
However this is only the first part as to find possible suspicious activities. But without logging the actual phone activities it will be difficult (or impossible) to actually find out which malicious code or app is doing this.
How can we log activities on Android?
I think when loggin all user activities like touch events etc. and all calls between apps would suffice.
Can this be done without rooting the device? And if not how would one do this on a rooted device?
I would prefer to have this device independent, but I use an Oneplus 6 with Oxygen OS.
I'm hoping to write an app in Android Studio which will require me to connect to a VPN.
I've read through the documentation on this, but I'm having trouble understanding some things about it, which the source code provided at the bottom of the article hasn't completely clarified to me.
Will this VpnService mean that I don't need to develop a separate VPN app for my main app to use for a VPN connection?
When the app opens for the very first time, I'll need to present a page for the user to enter the VPN details (IP address etc.) However, after these settings have been saved, how do I then open the VPN connection on app startup?
Answering your points.
You don't need to develop a separate app for VPN. You can use the vpn service class for creating vpn connections.
Just take the input from the user and pass them when configuring the vpn connection. Save the values in shared preferences and load from it for the next time use.
I want create firewall app for Android that when an app wants to connect to internet shows app's name and let the user block it for permanent or block it temporarily or allow it and when that app wants to receive data from network shows app name and user can allow or deny it.
I viewed this question: create firewall, but it doesn't cover my needs.
Any suggestion to detect which apps have access to network and / or receive data from it?
Thanks!
This is quite possible, and has been done before.
See these applications/implementations:
https://github.com/ukanth/afwall
https://code.google.com/p/iptableslog/
https://code.google.com/p/droidwall/
https://github.com/n8fr8/orbot
https://github.com/Soyokaze99/VPNFirewall
Depending on implementation it may require your device to be rooted.
Universal, non-ROOT, way is to create custom VPN service and track connections using NFLOG/ULOG kernel-userspace module.
See other QAs for reference:
Building a firewall application
https://android.stackexchange.com/questions/34181/droidwall-firewall-app-alternative-for-non-rooted-phones
https://android.stackexchange.com/questions/37067/allow-only-specific-apps-to-use-cell-data-only-when-on-3g
Non-Root firewall can also be create using VPNService and a few C code to handle tcp/udp. NetGuard is a good example:
https://github.com/M66B/NetGuard
I'm trying to make a android system app (for me and friends), to let me control my android phone over my server.
Actually I've problem to enable/disable data connection. When I search, I found topic that said there is no possibility, or giving a no longer supported way (by using breach). This was exactly the same for GPS controle, but I found a way because my app is a system app.
So I want to know if someone know a way to enable and disable data connection without user consent on a system app. I didn't find anything on the api.
Thanks !
I am developing an application. In which, I want to disable the using Internet for some time, especially if he has homework. How can I disable the Internet ?
To enable/disable data connection programatically check this post
To disable / enable wi-fi refer this tutorial
You can set the "mobile data" and "wifi state" whithin your application as long as you have the right permissions.
Also, you can register system wide BroadcastListener to detect when the device is connected to the internet, and do whatever you consider needs to be done.
There are ways to do this using Airplane mode, or via system hooks but the user will still retain the power to connect back. If you disconnect it again, he can disable/remove your app.
Is there an absolute way to restrict the user? I don't believe so. For security reasons alone, Providing this ability to third party applications would be very dangerous.