从挂起的意图中获取意向会导致安全异常



我们有一些可以工作很长时间的旧代码:

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;
}

我们现在收到一个安全异常:

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!/

任何帮助获得意图将不胜感激。

没有解决方法:根据错误消息和提交,从未属于公共 API 的隐藏方法现在需要只有使用系统签名签名的应用程序才能持有的signature权限。

最新更新