1

I'm trying to get a simple accessibility service, like Google's Voice Access or Button Mapper to work on an LG Exalt LTE, running a stripped down version of Marshmellow. The stock is missing many UI components, including system Accessibility Settings, which are normally used for turning accessibility services on or off. I would like to know if it is possible to compensate for lack of UI with ADB. I've tried the following: Install the app (Take Button Mapper for example), Its manifest declares a few permissions, that i've granted, say:

<uses-permission name="android.permission.WRITE_SECURE_SETTINGS" />

was granted adb shell pm grant package.name.here android.permission.WRITE_SECURE_SETTINGS

I even gave it android.permission.WRITE_SECURE_SETTINGS

even though its not declared in the permissions list in the top of the manifest. I get this error: Operation not allowed: java.lang.SecurityException: Package package.name.here has not requested permission android.permission.BIND_ACCESSIBILITY_SERVICE

However, It is declared in the manifest here though:

<service name="a.i" permission="android.permission.BIND_ACCESSIBILITY_SERVICE" stopWithTask="true">
  <meta-data name="android.accessibilityservice" resource="res/xml/accessibility.xml" />
  <intent-filter>
    <action name="android.accessibilityservice.AccessibilityService" />
  </intent-filter>
</service>

and thats where the problem is. this is the service itself, and it requires a non-package-wide permission, BIND_ACCESSIBILITY_SERVICE.

if I start it with ADB like this adb shell am startservice -n package.name.here/a.i

I get and error Error: Requires permission android.permission.BIND_ACCESSIBILITY_SERVICE

even though I already granted the permission to the package.

I've even tried adb shell settings put secure enabled_accessibility_services package.name.here/.a.i, but still get the same error.

Bottom line:

How do I start a service and grant permissions to that service with ADB? To be clear. I already know that I can use adb shell pm grant to grant a permission to the whole package, but in this case it is a permission not required by the whole package it is declared in a specific component and I am at loss as to how to launch the component with the permissions it requires through ADB.

4
  • obviously, i used the real package name in place of package.name.here... lol – sh7411usa Jun 12 '20 at 14:11
  • BIND_ACCESSIBILITY_SERVICE is a permission with signature protection level which means it cannot be granted using pm like permissions with dangerous protection level. But it can be granted to packages asking for it using: appops set <pkg> BIND_ACCESSIBILITY_SERVICE allow. If only a component (service) is asking for it, what you mentioned should work: settings put secure enabled_accessibility_services <pkg1>/<service 1>:<pkg2>/<service2>:.... That's what happens when you allow apps from GUI settings. – Irfan Latif Jun 12 '20 at 18:40
  • Try killing app process after granting permission. Also AFAIK service should be exported in Manifest to launch it from ADB or by other apps. – Irfan Latif Jun 12 '20 at 18:43
  • @IrfanLatif heres the cmd output: $ adb shell am kill flar2.homebutton $ adb shell appops set flar2.homebutton BIND_ACCESSIBILITY_SERVICE allow Error: Unknown operation string: BIND_ACCESSIBILITY_SERVICE $ adb shell settings put secure enabled_accessibility_services flar2.homebutton/a.i $ adb shell am startservice -n flar2.homebutton/a.i Starting service: Intent { cmp=flar2.homebutton/a.i } Error: Requires permission android.permission.BIND_ACCESSIBILITY_SERVICE – sh7411usa Jun 12 '20 at 19:10
0

I believe I figured it out. I'll use Voice Access as the example app.

adb shell am startservice com.android.cts.apps.accessibility.voiceaccess/com.google.android.apps.accessibility.voiceaccess.JustSpeakService

Next

adb shell settings put secure enabled_accessibility_services com.android.cts.apps.accessibility.voiceaccess/com.google.android.apps.accessibility.voiceaccess.JustSpeakService

Then

adb shell settings put secure accessibility_enabled 1

Then finally delete the the readout app, to avoid the accessibility features from being overwritten

adb shell pm uninstall -k --user 0 com.lge.voicecommand

I don't think there should be any errors after that, leave a comment if there are though.

1
  • 1
    If you want to enable another accessibility service, just rewrite step 2 to a list of all the services, with a colon between them. Like so adb shell settings put secure enabled_accessibility_services pkg1/serv1:pkg2/serv2 – Exosylver Nov 13 '20 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.