Yeah, an old thread but I removed AMS in a prior trial because it was nuisancing me by occupying a valuable notification slot. I get lots of e-mails and phone calls and want to see those notifications. A static “You are safe” tells me nothing. If the AV isn’t running and I was never prompted to let it stop and I never stopped it then the product does not adequately protect itself.
As for the rationale that a notification is needed to keep the Android OS from killing the Avast app, please explain how other AVs manage to keep running that do not occupy a slot in notifications. Also explain why always-on services don’t restart when killed. Why aren’t you running AMS as a service to keep the OS from stopping it? Why isn’t it a restartable service? If an app, like battery saver, wants to stop apps, why isn’t AMS requiring that an app must be enabled as a device administrator to stop AMS?
I’ve use battery saver apps, just like yours, and trying to stop a service configured always on (unstoppable aka restartable) results in the service restarting. The Android OS may kill a service when the background app is idle too long and the OS needs more resources, but I thought the service onStartCommand method returning START_STICKY would have the OS automatically restart the service.
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
Found the above mentioned at http://stackoverflow.com/questions/15758980/android-service-needs-to-run-always-never-pause-or-stop#, reply 60. Also see https://developer.android.com/reference/android/app/Service.html#START_STICKY. I suspect you use startForeground(int,Notification) but that will keep showing a notification to the user.
I also found mention of how to make an unstoppable service at:
http://androidtrainningcenter.blogspot.it/2013/05/how-to-make-android-service-unstoppable.html
While I use Avast on my home PC, I will wait until AMS is better protected against apps stopping it and figure out how to run as an unstoppable (or automatically restarted) service so the OS does not [permanently] unload it. AMS is the only AV that I tried (the others, I think, were BitDefender and Sophos) that occupied a notification slot; i.e., every time I look at my notifications to see e-mails and calls, there’s a useless [to me] “Yes you’re safe” wasting screen space. Imagine how useless would be notifications if every app did that. You’d have to scroll and scroll to see the real notifications.
Yes, restarting a service starts it from scratch. So what? What does AMS have to retain within a power-on session of the smartphone that its loss results in an unusable restarted service? Why does state have to be maintained for an AV program between separate instances of it (i.e., why does prior state have to be migrated to a restarted instance of the service)?