Does anyone know if there's a way to either keep the user from uninstalling an app from an Android phone or reinstall it on removal? Before you flame me, please know that I have an app that's intended to be installed on the phone by a parent/employer/etc. and has a password-protected settings screen; the user would need to enter the password to remove the app.
What if you have it send an email alert to a registered email address on uninstall?
On the topic of email notification when your service is uninstalled--
A lot of security software runs multiple processes which monitor each other, so that it's more difficult to shut the system down. You could do something similar with two services installed, each monitoring to see if the other is installed. If something goes wrong, they can send off the e-mail.
Not without modifying the kernel, or reducing the user priviledges on the device. Think of it as a Linux computer, where the cell phone user has root.
Can you prevent them from removing your app? No.
But you can make it painful and difficult enough that it's not worth it, and include alerts that indicate it has been removed.
First, I would modify the software so it requests and successfully answers a cryptographic challenge/response periodically from a remote server - daily should be enough, and wouldn't impact battery use. This way your server knows when it has been disabled (could be sold as an additional $10/yr service charge) and you can alert the purchaser.
Second, I would tie the software into the system at the driver level so that removal also removes text services. There are drivers or services that the texting application uses that could be replaced with your custom versions, and on removal would render the texting app useless. Chances are good that you already tie into the system in a similar way to block the texting app (and other apps) while traveling too fast.
Third, I would consider installing a monitoring program that runs as a separate process (check out how the latest viruses operate for clues). It would check to make sure that not only is the app still running, but it's running the latest version, and there isn't a GPS simulator or other program that prevents your app from getting correct GPS data.
I'm curious how you differentiate between the driver texting and a friend in the passenger seat texting on the driver's cell, though.
-Adam
Well, solution would be to mount /system/apps/ to be writable and put your app there once.
When you restart the phone it would automaticly install it and prevent a user from uninstalling (as every app in that folder, list it to see it). That's how mobile providers force user to have they app.
However, user could always delete this app by rooting + mounting /system/app/ to writable and then to delete. But "normal parents" can't do that :)
Regards
P.S. This question is two years old, I've notice it just now... :S
I'd highly doubt that's possible. The permission structure of Android is going to give the user full control over what's happening on their phone (to some degree) and not being able to uninstall an app would be a pretty large security risk.
If you modified the Android core, it would probably be possible, but if you're trying to force something onto an end-user, that's a bad idea.
Maybe there's a better approach to what you're doing? If there's some required functionality in the app to keep the user from uninstalling it, that would be a small incentive to keep the app, but there's no way to keep a user from removing something they really don't want. You could have the app report uptime to a seperate server so you could be notified if the app was removed, but I think that's as far as you're going to get.
Related
A client of mine is requesting for a very specific functionality, to keep the application always active, even after the user force kills it. He wants to ensure that the users have the application active at any time while using the device on which it is installed (the devices are managed in a constrained environment).
I've done some research on it, and already enabled background services for sending the user's location, but if they force kill the app then we are unable to send locations to the server. We've seen other apps do it, but wonder how they do it.
According to https://stackoverflow.com/a/34573169/640907 it should be possible in Android. We also found https://ssaurel.medium.com/how-to-auto-restart-an-android-application-after-a-crash-or-a-force-close-error-1a361677c0ce but I don't think this will work for our use-case, as the user can close the application without "force kill" aswell..
Anyone knows how to achieve this for a Flutter application?
because my questions might sound a bit suspicious, first some background: I'm writing an parental screen time control app. I am a seasoned java programmer with some Windows Phone background just learning the Android platform.
The app would run at startup (I understand that services can listen for a boot event and run) and when a violation of screen time is detected it would nuke all user processes that weren't around when the service started. Or lock the screen or some other annoyance every minute. No problems, right?
The kid will the try to terminate the process. I understand that this cannot be prevented on an unrooted device but a pair of processed could be used to bootstrap each other when the sibling dies?
Then the kid will try to uninstall the application, something that is also not possible on unrooted devices. I can listen to the uninstall event but by then the app is gone. Here is the tricky part, can I somehow reinstall automatically here? The application can ask any permission it wants on first install if it can help with the background reinstall
I understand that many of the features required here are nontrivial because that could be used for making, well, PITA apps. But I'm just trying to redistribute the misery my kids are giving me with screen control ;-)
Thankful for pointers,
A sadistic parent
you are looking for an Admin app.
this will allow you to put some restriction. and you can listen for event for deactivation where intern you can reset the device if necessary.
I would like to ask about something. I'm now aware that there's no possibility to turn GPS on via normal SDK application. My problem is that I need to do it without user's confirmation (my application's fundamental is to work silently). I need it because my application is meant to be used by a company to track their devices (tablets). It needs to turn on GPS to obtain location and after that turn it off. That means, if we prompt user to turn GPS on, he may not do it and the application (a service actually) will not work properly.
My next step is to find an alternative solution, I mean, if we turn GPS on using settings, it eventually gets turned on by a core application/service. My assumption is that it uses native code to access the GPS device and turn it on (if I'm wrong, please correct me and point to the right answer).
Therefore my question is - if possible, how can I do that in NDK and later on how to integrate it with my application. If NDK can't handle it, how it can be done? There must be a way, since it's eventually done in settings.
I would also like to ask the same question about Internet connection (to alternatively use network provider to obtain location).
Thanks in advance for any contribution!
You might find a way to handle GPS with NDK/JNI calls, but there's no such thing as GPS without notice to the user on an Android device. He can switch GPS off or refuse to switch it on. In such a case, that device itself (the hardware) switches the GPS sensor off.
What might be possible is to use other ways to locate the device:
Wifi gives you the position not as accurate as GPS, but better then nothing
Carrier track the position of a device according to the signal strength arriving at their antennas. But I haven't seen any Android interface able to handle that (might be a question to ask here, if anybody knows how to get that information)
The way, I'd handle your problem is on the organizational side (as this is company internal stuff): You basically say to the user: "Switch on GPS and you, user, get access to your emails" (well, as an example)
Give something and you will get something back :-)
"Settings" is not an application to begin with.
So if you already made an application you should understand somehow the basics of Android applications but if you didn't really understand them then I'd like to say that the applications generally run in a "sandbox" and these applications may be destroyed / terminated by the system should it deem it necessary. There's also no such thing as "silent mode" either. The user MUST ACCEPT / DECLINE permissions and the user MUST be in control of his device should you have the Android OS installed on your devices.
There are ways to circumvent that of course and those ways may be ranging from:
Make all devices have one central account on Google Play and activate the service to erase / destroy the device if they get lost, (You can find that in settings since you mentioned it ... under administrator accounts) and leave things right there as they are since that's all you need at the end of the day.
(Requires 1 to be enabled) You should make all your corporate devices (if you want to be that kind of jailer but going that path will make your employees just see you as a not so great employer) to run your piece of software and every single thing that needs access to your network will be running on a proprietary custom encrypted channel (no public encryption) and with the usage of the administrator account you being able to control what the users can install on their devices you can restrict that the only application is that said application that was mentioned above. Now make all that your employees need as a subapplication of your application ;) and on top of that enable these applications to be able to run ONLY if there's GPS signal (so if your employee gets in the tube ... his device will stop working) add / subtract whatever you feel right from this.
Be a good employer and just leave them do whatever they please with the devices you gave them. If you give trust you'll receive joy for the work they're doing meanwhile if you jail people you receive negative emotions and bad performance (eventually it can even go in the direction that people will just leave for a better employer)
From all the 3 I would certain go for the third option if I were in your shoes. From a technology challenge the #2 is I think the only way and a very interesting architecture that you could implement ... in a long time ... so you also need to make sure the effort invested in this is worth the 2 hours your employer will play angry birds at home with his child ;) nevertheless if you're in it for the challenge more than any real world application this is a great chance for you to learn the android operating system from all its perspectives. NDK may help you here but not the way you want it... more along the lines of custom encryption and so on.
EDIT: Sorry for my twisted logic and way of expressing but it's pretty late and has been a very long day.
I am starting an application for child monitoring. This would involve mainly the logging of the SMS messages sent and received and logging other activities that may be of interest to the parents. It will also be nice to have something like access control lists for these, too.
Now, as far as I know:
It is not possible to make an app "not uninstallable".
It is not possible to prompt for a password to uninstall an app.
It is not possible to assure that your app is "always" running even if it's getting killed with something like Task Killer, although I think you can respawn the application at given time intervals.
So, any ideas on how to overcome these problems?
There is no way to work around these problems directly without creating your own build of the Android OS. Android always assumes the current user is the owner of the phone and should always be allowed to do whatever they need to do.
It's easy to see why the functionality you need isn't available if you replace "child monitoring" with "malicious data logging" in your question; if Android allowed an app to prevent the user from removing it, it would clearly be open to abuse.
The only thing I can think to do is to have your keep a log of when it is running. This would allow a parent to seen when the app had been running when they viewed the log of the collected data. So if the child had disabled the app the parent would know, but they wouldn't know what had been missed. Although you'd had to be able differentiate between when the phone was switched off and when the app just wasn't running which might not be straightforward.
What you said is true.
Also remember that applications like Task Killer have some sort of blacklist/ignore list so re spawning your app might not make it work.
PS: Without a rooted phone, there is no way you can save your app from a geek kid :)
I was thinking about writing a similar app and considered the same exact scenario. "What if the kid uninstalls the app?"
The only solution I was able to come up with was to have the app periodically ping a server with the a unique ID. Affectively having the app "Check in" with the server a few times a day. Kind of like when prisoner goes on parole. The app is the prisoner and the server is the Parole officer :)
If the app misses a checkin you could treat this as a potential uninstall. However, this could be caused by a lack of network connectivity. I'm sure you could come up with some interesting ways to flag and treat missed checkins. Maybe you could have the app send an SMS checkin or something instead of over HTTP. Then you wouldn't have to depend on Network connectivity.
Once you figure out how to translate missed checkins to an uninstall, you could shoot out an email to the interested party (i.e. the kids parent).
With this option in place, the parent can then have a "Conversation" with their kid before giving them the phone. Something along the lines of:
- "This phone's got parental controls on it. Yes, you do have the ability to uninstall them. However, if you uninstall them I'll know about it and I'll take the phone away."
I think there's definitely a market for this. Need some type of web-interface/dashboard for that parents can log into for monitoring too.
Hope this helps & best of luck.
Cheers!
Does anyone know if there's a way to either keep the user from uninstalling an app from an Android phone or reinstall it on removal? Before you flame me, please know that I have an app that's intended to be installed on the phone by a parent/employer/etc. and has a password-protected settings screen; the user would need to enter the password to remove the app.
What if you have it send an email alert to a registered email address on uninstall?
On the topic of email notification when your service is uninstalled--
A lot of security software runs multiple processes which monitor each other, so that it's more difficult to shut the system down. You could do something similar with two services installed, each monitoring to see if the other is installed. If something goes wrong, they can send off the e-mail.
Not without modifying the kernel, or reducing the user priviledges on the device. Think of it as a Linux computer, where the cell phone user has root.
Can you prevent them from removing your app? No.
But you can make it painful and difficult enough that it's not worth it, and include alerts that indicate it has been removed.
First, I would modify the software so it requests and successfully answers a cryptographic challenge/response periodically from a remote server - daily should be enough, and wouldn't impact battery use. This way your server knows when it has been disabled (could be sold as an additional $10/yr service charge) and you can alert the purchaser.
Second, I would tie the software into the system at the driver level so that removal also removes text services. There are drivers or services that the texting application uses that could be replaced with your custom versions, and on removal would render the texting app useless. Chances are good that you already tie into the system in a similar way to block the texting app (and other apps) while traveling too fast.
Third, I would consider installing a monitoring program that runs as a separate process (check out how the latest viruses operate for clues). It would check to make sure that not only is the app still running, but it's running the latest version, and there isn't a GPS simulator or other program that prevents your app from getting correct GPS data.
I'm curious how you differentiate between the driver texting and a friend in the passenger seat texting on the driver's cell, though.
-Adam
Well, solution would be to mount /system/apps/ to be writable and put your app there once.
When you restart the phone it would automaticly install it and prevent a user from uninstalling (as every app in that folder, list it to see it). That's how mobile providers force user to have they app.
However, user could always delete this app by rooting + mounting /system/app/ to writable and then to delete. But "normal parents" can't do that :)
Regards
P.S. This question is two years old, I've notice it just now... :S
I'd highly doubt that's possible. The permission structure of Android is going to give the user full control over what's happening on their phone (to some degree) and not being able to uninstall an app would be a pretty large security risk.
If you modified the Android core, it would probably be possible, but if you're trying to force something onto an end-user, that's a bad idea.
Maybe there's a better approach to what you're doing? If there's some required functionality in the app to keep the user from uninstalling it, that would be a small incentive to keep the app, but there's no way to keep a user from removing something they really don't want. You could have the app report uptime to a seperate server so you could be notified if the app was removed, but I think that's as far as you're going to get.