What does QUERY_ALL_PACKAGES permission do?

Sam picture Sam · Mar 14, 2020 · Viewed 12.2k times · Source

Android R Preview 1 introduced a new permission called QUERY_ALL_PACKAGES. The documentation for the permission says the following:

Allows query of any normal app on the device, regardless of manifest declarations.

Has anyone worked out what this actually does?

I've tried running the following on the emulator image, and the permission had no effect on either of them:

  • packageManager.queryIntentActivities(intent, 0)
  • packageManager.getInstalledPackages(0)

Answer

Flovettee picture Flovettee · Mar 8, 2021

Even when permission QUERY_ALL_PACKAGES is added, you still need to add <queries> filter to your AndroidManifest.

E.g. for the launcher app it might be:

<permission android:name="android.permission.QUERY_ALL_PACKAGES" />

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