QUERY_ALL_PACKAGES 权限有什么作用?
What does QUERY_ALL_PACKAGES permission do?
Android R 预览版 1 引入了一个名为 QUERY_ALL_PACKAGES
的新权限。该许可的文档说明如下:
Allows query of any normal app on the device, regardless of manifest declarations.
有没有人知道这到底是做什么的?
我已经 运行 在模拟器图像上尝试了以下操作,但权限对它们都没有影响:
packageManager.queryIntentActivities(intent, 0)
packageManager.getInstalledPackages(0)
他们 cover this more 现在 DP2 已经出来了。
引用 myself:
While I haven't tested
this aspect of R DP2 yet, it appears that your app now can't find out what other apps are installed,
on a general basis. The cited example is queryIntentActivities()
, but to make
this really work you would need to seriously lobotomize PackageManager
.
You can whitelist certain packages and certain <intent-filter>
structures to try to get by this for certain use cases. And, this is where
the mysterious QUERY_ALL_PACKAGES
permission seen in DP1 comes into play —
this permission removes these new restrictions. Given the "look for Google Play
to provide guidelines for apps that need this permission" caveat, it is safest to assume
that if you try using it, eventually you will be banned from the Play Store by a
bot.
因此,您可能想在 DP2 上重新尝试您的实验。我计划在接下来的几周内做同样的事情。
即使添加了权限 QUERY_ALL_PACKAGES
,您仍然需要将 <queries>
过滤器添加到您的 AndroidManifest
。
例如对于启动器应用程序,它可能是:
<permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
</intent>
</queries>
如果该应用试图与另一个应用通信,则应为 Android 11+ 添加此权限,否则这些应用不会 work/trigger
Android 11 引入了与包可见性相关的更改。只有当应用程序以 Android 11 为目标时,这些更改才会影响它们。有关这些更改的更多信息,请查看 Android.
上关于包可见性的指南
https://developer.android.com/training/package-visibility
https://developer.android.com/about/versions/11/privacy/package-visibility
https://developer.android.com/training/package-visibility
对于我的情况,Cordova-android 10.1.1,targetSdkVersion 30
我加了
<queries>
<package android:name="com.google.android.gm" />
<package android:name="com.facebook.katana" />
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
在AndroidManifest.xml
Android R 预览版 1 引入了一个名为 QUERY_ALL_PACKAGES
的新权限。该许可的文档说明如下:
Allows query of any normal app on the device, regardless of manifest declarations.
有没有人知道这到底是做什么的?
我已经 运行 在模拟器图像上尝试了以下操作,但权限对它们都没有影响:
packageManager.queryIntentActivities(intent, 0)
packageManager.getInstalledPackages(0)
他们 cover this more 现在 DP2 已经出来了。
引用 myself:
While I haven't tested this aspect of R DP2 yet, it appears that your app now can't find out what other apps are installed, on a general basis. The cited example is
queryIntentActivities()
, but to make this really work you would need to seriously lobotomizePackageManager
. You can whitelist certain packages and certain<intent-filter>
structures to try to get by this for certain use cases. And, this is where the mysteriousQUERY_ALL_PACKAGES
permission seen in DP1 comes into play — this permission removes these new restrictions. Given the "look for Google Play to provide guidelines for apps that need this permission" caveat, it is safest to assume that if you try using it, eventually you will be banned from the Play Store by a bot.
因此,您可能想在 DP2 上重新尝试您的实验。我计划在接下来的几周内做同样的事情。
即使添加了权限 QUERY_ALL_PACKAGES
,您仍然需要将 <queries>
过滤器添加到您的 AndroidManifest
。
例如对于启动器应用程序,它可能是:
<permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
</intent>
</queries>
如果该应用试图与另一个应用通信,则应为 Android 11+ 添加此权限,否则这些应用不会 work/trigger
Android 11 引入了与包可见性相关的更改。只有当应用程序以 Android 11 为目标时,这些更改才会影响它们。有关这些更改的更多信息,请查看 Android.
上关于包可见性的指南https://developer.android.com/training/package-visibility
https://developer.android.com/about/versions/11/privacy/package-visibility
https://developer.android.com/training/package-visibility
对于我的情况,Cordova-android 10.1.1,targetSdkVersion 30
我加了
<queries>
<package android:name="com.google.android.gm" />
<package android:name="com.facebook.katana" />
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
在AndroidManifest.xml