【问题标题】:Get Intent from PendingIntent causes SecurityException从 PendingIntent 获取 Intent 导致 SecurityException
【发布时间】:2017-02-22 20:45:09
【问题描述】:

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

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

我们将不胜感激。

【问题讨论】:

  • “我们现在遇到了一个安全异常”——太好了!我之前曾抱怨过这个安全问题,我很高兴看到这个问题得到了加强。
  • 我们并不是在尝试做任何恶意的事情,我们只是想通过设备重置或应用程序重启来持久化缓存的 PendingIntent。
  • 你不能保存一个一开始就不是你自己的缓存PendingIntent,因为你不能创建另一个应用程序的安全上下文(除非有一些other 这里的安全漏洞...)。对于您自己的应用程序,而不是侵入 PendingIntent,通过其他方式跟踪哪些是优秀的,因为您是创建这些 PendingIntents 的人。
  • @CubePirate - 你找到解决办法了吗?
  • @Libin 抱歉,我们最终改变了需求和实现

标签: android android-intent android-pendingintent


【解决方案1】:

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

【讨论】:

  • 嗯,这不是很甜蜜吗?在这里,我有征服世界的计划。
  • 有时您需要知道待处理的意图会做什么。
  • 如果您从 seap 获得权限,可能适用于三星。
猜你喜欢
  • 2014-07-06
  • 2012-12-23
  • 1970-01-01
  • 2011-02-22
  • 2014-08-07
  • 1970-01-01
  • 1970-01-01
  • 2016-10-21
  • 1970-01-01
相关资源
最近更新 更多