未更新的应用程序执行的代码需要用户在 Android 6.0 Marshmallow 中不允许的权限

What will happen to un-updated apps that executes code that requires a permission that the user dis-allowed in Android 6.0 Marshmallow

我想知道 Android 6.0 Marshmallow 的新功能,该功能允许用户明确设置允许应用程序使用的权限。我的问题是这会如何影响使用权限集的现有应用程序。

例如,未更新 应用程序 [Target-sdk-version < 23] 已显示使用相机的权限,但用户手动禁止它。当应用程序执行使用权限的代码时会发生什么?它会崩溃吗?

我假设新应用程序在执行依赖于权限的代码之前必须检查它们是否有权限 - 我的问题是关于应用程序没有改变来处理这些案例。

my question is about apps that are not changed to handle these cases

隐含的假设是 targetSdkVersion 将低于 23。任何将 targetSdkVersion 设置为 23 或更高 的人必须 将其应用更改为处理运行时权限,否则他们将永远无法获得 dangerous 权限。

在那种情况下,引用我自己的话 my book:

Apps with a targetSdkVersion below 23, on the surface, behave on Android 6.0+ as they would on an older device: the user is prompted for all permissions, and the app is granted those permissions if the app is installed.

However, the user will still be able to go into Settings and revoke permissions from these apps, for any permissions the app requests that are in one of the runtime permission groups.

Generally, you will wind up ignoring the issue. All your calls to methods protected by permissions that the user revoke will still "work", insofar as they will not throw a SecurityException. However, you just will not get any results back or have the intended effects. So, for example, if you try to query() the ContactsContract ContentProvider, and the user revoked your access to contact-related permissions, the query() will return an empty Cursor. This is a completely valid response, even ignoring the permission issue, as it is entirely possible that the user has no contacts. Your app should be handling these cases gracefully anyway. Hence, in theory, even if you do nothing special regarding the lost permissions, your app should survive, albeit with reduced functionality for the user. Dave Smith outlines the expected results for legacy apps calling methods sans permission.