2

I am using a accessibility service and if i kill the app from running applications the system is taking away the accessibility permission that user explicitly gave and that leads me to ask for permission again. Any explanation why this is happening and some solution to avoid this problem.

rds
  • 26,253
  • 19
  • 107
  • 134
dirtydexter
  • 1,063
  • 1
  • 10
  • 17
  • "leads me to ask for permission again" You mean the system is displaying the "are you sure you want to enable" dialog again? On what device / OS version does this occur? – alanv Nov 02 '14 at 23:38
  • I meant the permission is taken away and for my app to work I need the permission, so I have to ask user to give me the permission again by going to accessibility settings. I have tested it on 4.0, 4.2, 4.4 – dirtydexter Nov 03 '14 at 03:29
  • I'm having trouble understanding exactly what you mean, but it sounds like you're killing the accessibility service process. What do you expect to happen when you kill the service process? – alanv Nov 03 '14 at 05:39
  • I expect that if the guy is using some kind of task-manager that kills the accessibility service process, it should just kill the process its side-affect that is that the permission is also revoked from my service. – dirtydexter Nov 03 '14 at 09:24

1 Answers1

1

Unfortunately you cannot prevent this situation, even if you move an accessibility service to a new process.

When you click "Force Stop" then not only application's processes are killed, the app is moved into the "stopped" state (Android 3.1 APIs) where nothing in the app will run again until a user manually start the app (e.g. with launcher icon). Because of security reasons, an Accessibility Service has to be enabled manually by a user - it cannot be started programmatically, what is more even system won't restart the accessibility service when is leaving "stopped" state.

Please also bear in mind about Android Settings issue. Sometimes, after application "Force Stop", Android Settings shows that Accessibility Service is enabled but in fact it doesn't work.

MikePtr
  • 1,661
  • 1
  • 16
  • 18