Android,创建前授予的自定义权限
Android, Custom permission granted before creation
我正在尝试在我的应用程序中使用另一个应用程序 (Bazaar) 创建的自定义权限(这是使用市场 com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR
的权限)。通常它工作正常。
但是如果Bazaar是在我申请之后安装的。我的应用程序不会获得自定义权限(由 Bazaar 创建)并抛出异常。我想知道是否有其他人遇到过类似的问题,您有什么解决方案?
这是期望的行为。
在教科书中,Android 安全内幕:Android 安全架构的深入指南,作者 Nikolay Elenkov(2014 年)说:
The system can only grant a permission that it knows about, which
means that applications that define custom permissions need to be
installed before the applications that make use of those permissions
are installed. If an application requests a permission unknown to the
system, it is ignored and not granted.
顺便说一句,PackageManager 在安装时为每个应用程序分配权限,它维护已安装包的一些信息,例如包名、版本和权限,这些信息存储在 /data/system/packages.xml
中。如果想查询设备的所有权限,可以尝试pm list permissions
.
我正在尝试在我的应用程序中使用另一个应用程序 (Bazaar) 创建的自定义权限(这是使用市场 com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR
的权限)。通常它工作正常。
但是如果Bazaar是在我申请之后安装的。我的应用程序不会获得自定义权限(由 Bazaar 创建)并抛出异常。我想知道是否有其他人遇到过类似的问题,您有什么解决方案?
这是期望的行为。
在教科书中,Android 安全内幕:Android 安全架构的深入指南,作者 Nikolay Elenkov(2014 年)说:
The system can only grant a permission that it knows about, which means that applications that define custom permissions need to be installed before the applications that make use of those permissions are installed. If an application requests a permission unknown to the system, it is ignored and not granted.
顺便说一句,PackageManager 在安装时为每个应用程序分配权限,它维护已安装包的一些信息,例如包名、版本和权限,这些信息存储在 /data/system/packages.xml
中。如果想查询设备的所有权限,可以尝试pm list permissions
.