从PendingIntent获取Intent导致SecurityException [英] Get Intent from PendingIntent causes SecurityException
问题描述
我们有一些可以工作很长时间的旧代码:
We have some old code that worked for a long time:
public static Intent getIntent(PendingIntent pendingIntent) {
Intent intent = null;
try {
Method getIntent = PendingIntent.class.getDeclaredMethod("getIntent");
intent = (Intent) getIntent.invoke(pendingIntent);
} catch (Exception e) {
// Log line
}
return intent;
}
我们现在收到一个安全异常:
We are now getting a security exception:
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.company.util.IntentUtils.getIntent(IntentUtils.java:160)
Caused by: java.lang.SecurityException: Permission Denial: getIntentForIntentSender() from pid=28128, uid=10127 requires android.permission.GET_INTENT_SENDER_INTENT
at android.os.Parcel.readException(Parcel.java:1683)
at android.os.Parcel.readException(Parcel.java:1636)
at android.app.ActivityManagerProxy.getIntentForIntentSender(ActivityManagerNative.java:5924)
at android.app.PendingIntent.getIntent(PendingIntent.java:987)
... 17 more
看起来可能与AOSP更改有关: https://android.googlesource.com/platform/frameworks/base/+/e5ad41b%5E!/
Looks like it might be related to AOSP change: https://android.googlesource.com/platform/frameworks/base/+/e5ad41b%5E!/
任何能帮助实现目标的人将不胜感激.
Any help getting the intend would be appreciated.
推荐答案
没有解决方法:根据错误消息和提交,该隐藏方法(从来都不是公共API的一部分)现在需要一个signature
权限,该权限仅适用于应用程序带有系统签名的签名可以保留.
There's no workaround: as per the error message and commit, that hidden method that was never part of the public API now requires a signature
permission that only apps that are signed with the system signature can hold.
这篇关于从PendingIntent获取Intent导致SecurityException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!