0

I have implemented some code in my app in order to get a list of accessibility services installed on my device using AccessibilityManager.getInstalledAccessibilityServiceList. Since devices running Android 11 and above are subjected to package visibility filtering, I added a <queries> tag in my manifest like this:

<queries>
        <intent>
            <action android:name="android.accessibilityservice.AccessibilityService" />
        </intent>
</queries>

Unfortunately there are one or two installed accessibility services that are still not showing up but I can see them from the Accessibility menu in my device settings screen (like the ones belonging to com.dashlane and Voice Access).

I have checked that these missing accessibility services do show up correctly if I declare the QUERY_ALL_PACKAGES permission in my app's manifest instead of using the <queries> tag to get visibility to installed apps, so this seems like a package visibility filtering issue. Does anyone know why the <queries> tag is somehow filtering out these missing packages and their accessibility services?

huthut28
  • 71
  • 5
  • That does not look like a normal `Intent` action string. Where did you come up with it? Is it documented the every `AccessibilityService` will have an `` using that action string? – CommonsWare Jul 21 '22 at 10:40
  • 1
    @CommonsWare I got the `` declaration from [here](https://developer.android.com/reference/android/accessibilityservice/AccessibilityService#declaration). This other [page](https://developer.android.com/guide/topics/ui/accessibility/service#service-declaration) also mentions that it is necessary for an `AccessibilityService` (deployed on Android 1.6 or higher), thus I understood it as every accessibility service would have an intent filter using that action string and I could use it to filter for packages that have accessibility services implemented. – huthut28 Jul 27 '22 at 03:26
  • 1
    I agree, that does look good. "there are one or two installed accessibility services that are still not showing up" -- when you say "installed", do you mean ones installed by you? Or are they pre-installed? If they are pre-installed, it is possible that the device manufacturer has these accessibility options baked into the OS, and so they are not packages that `PackageManager` might find. – CommonsWare Jul 27 '22 at 10:59
  • 1
    Yes they were installed by me and I could uninstall them completely too. (both app and accessibility service removed) The unusual thing is that `PackageManager` was able to find these accessibility if I declared the `QUERY_ALL_PACKAGES` permission or if I used another action string like ``. Thus I'm not sure if the problem is with the `AccessibilityService` action string's behaviour or if it is due to some other setting elsewhere.. – huthut28 Aug 02 '22 at 02:37
  • 1
    Install [this app](https://f-droid.org/en/packages/com.oF2pks.applicationsinfo/) (also available on the Play Store IIRC) and examine the manifest of the two apps that are not showing up as expected. – CommonsWare Aug 02 '22 at 12:11

1 Answers1

0

The reason why it was not working may be because the accessibility service of the apps that are not showing up is not exported (android:exported="false") in the manifest, which interfered with the output somehow.

For example:

<service android:enabled="@bool/is_accessibility_supported" android:exported="false" android:name="com.random.name.AccessibilityService" android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
    <intent-filter>
        <action android:name="android.accessibilityservice.AccessibilityService"/>
    </intent-filter>
    <meta-data android:name="android.accessibilityservice" android:resource="@xml/accessibility_service_meta"/>
</service>

The workaround is to use a combination of some other tags in the manifest like <action android:name="android.intent.action.MAIN" />, or as mentioned in the question, to declare the QUERY_ALL_PACKAGES permission.

huthut28
  • 71
  • 5