my app uses accessibility permission and every time i run it i need to grant the permission manually , it is tedious, is there an option to grant my app this permission, by some command ,just for debug purposes? Thank you.
Asked
Active
Viewed 3,868 times
2 Answers
3
There is, although I'm not sure if you need to do it as the root user. Try this command.
adb shell settings put secure enabled_accessibility_services %accessibility:packagename/packagename.YourAccessibilityServiceName
Keep in mind that if you have applicationIdSuffix for your debug build this command becomes
adb shell settings put secure enabled_accessibility_services %accessibility:packagename.applicationIdSuffix/packagename.YourAccessibilityServiceName
You can read more about the other secure settings you can modify using shell commands here.

Venkata Narayana
- 1,657
- 12
- 25
-
it works , but i still need to check/uncheck something in order for it to update, is there like a command for update secure settings or somthing? otherwise it won't get that is has this permission – The Y.c Oct 24 '17 at 13:27
-
Did not quite get your question. Do you mean the callback to onServiceConnected method? – Venkata Narayana Oct 24 '17 at 18:37
-
2Yes sir. unless i change something in the accessibility settings , even for other services (on or off) my accessibility service won't bind , and won't call onServiceConnected(). – The Y.c Oct 25 '17 at 14:40
-
Unfortunately, yes the callbacks aren't being received. Perhaps you could try this solution https://stackoverflow.com/a/28209995/5551621. – Venkata Narayana Oct 25 '17 at 22:47
-
Coming back to your original question, you only need to give accessibility permission once when you first install the build. For the subsequent installs, the accessibility permission will be retained unless you uninstall and reinstall the app. So, what's the problem? – Venkata Narayana Oct 25 '17 at 22:48
-
1@VenkataNarayana the act of debugging the app in Android Studio seems to revoke the accessibility permission. Debugging can be very tedious. I wish I could get this to work! – Tyler Oct 21 '19 at 02:26
-
I don't think I understand this answer. Could someone give an example of the command working? – Tyler Oct 21 '19 at 02:26
-
@Tyler Debugging typically doesn't revert the Accessibility permission. As far as I can remember, the revert only happens if your app crashes or if you reinstall it. Coming to the answer, this command will set the flags but you will not receive any events from the service. So the command given in the answer is a dead end. Nevertheless, Android Studio should not revoke your permissions unless you uninstall and reinstall the app or if your app crashes. – Venkata Narayana Oct 22 '19 at 02:54
-
It's not just debugging but running the app from Android Studio as well. I don't know if it's related to how Android Studio updates & reloads the app but it is quite a pain to have to re-enable acc services each time I run the app from Android Studio – jpage4500 Oct 23 '19 at 18:00
-
@VenkataNarayana Do we have something similar for granting VPN permission as well? – Vishal Nagpure Jun 07 '21 at 14:53
1
I found this post which looks like the same thing: Accessibility Service is turned off automatically on each Run since Android studio 3.5
It references an issue to track this: https://issuetracker.google.com/issues/140056246

jpage4500
- 951
- 9
- 11
-
I've never faced this issue. It could be because I was using an older version of Android Studio or because I was installing from the command line. Nevertheless, from the answer in the link, command line installation seems to be a workaround for this issue. – Venkata Narayana Oct 25 '19 at 07:08