GET_TASKS 权限已弃用

GET_TASKS Permission Deprecated

我有一个使用此权限的安全应用程序 (App Locker):

android.permission.GET_TASKS

在 android Lollipop 中,此权限已弃用,我希望我的应用程序在 +21 API.
中运行 谁能指导我怎么做?

谢谢:)

它被弃用是有原因的。 android.permission.GET_TASKS 的保护级别已提升到 signatureOrSystem。 对此没有简单且无害的解决方案。

As of LOLLIPOP, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak personal information to the caller. For backwards compatibility, it will still return a small subset of its data: at least the caller's own tasks (though see getAppTasks() for the correct supported way to retrieve that information), and possibly some other tasks such as home that are known to not be sensitive.

http://developer.android.com/reference/android/app/ActivityManager.html#getRecentTasks(int,%20int)

我看到了一个新的权限REAL_GET_TASKS,据说用来代替GET_TASKS:

New version of GET_TASKS that apps can request, since GET_TASKS doesn't really give access to task information. We need this new one because there are many existing apps that use add libraries and such that have validation code to ensure the app has requested the GET_TASKS permission by seeing if it has been granted the permission... if it hasn't, it kills the app with a message about being upset. So we need to have it continue to look like the app is getting that permission, even though it will never be checked, and new privileged apps can now request this one for real access.

查看 Android 代码差异:https://android.googlesource.com/platform/frameworks/base/+/2d7576b%5E!/