当前位置:   article > 正文

Android O(android 8.1) SYSTEM_UID应用无法使用FileProvider_for security reasons, the system cannot issue a ur

for security reasons, the system cannot issue a uri permission grant to cont

报错信息:

For security reasons, the system cannot issue a Uri permission grant to content://com.joson.adphonelauncher.fileProvider/name/DBoothLayout/AdPhoneLauncher.apk [user 0]; use startActivityAsCaller() instead
java.lang.SecurityException: Permission Denial: opening provider com.joson.adphonelauncher.MyProvider from ProcessRecord{8d253bb 1430:com.android.packageinstaller/u0a18} (pid=1430, uid=10018) that is not exported from UID 1000

原因是系统把provider给过滤了一下,最简单办法就是修改一下源码。

文件路径:

frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
在 ActivityManagerService.java  (AMS) 中的checkGrantUriPermissionLocked()方 法内的如下代码块中打印的:
  1. // Bail early if system is trying to hand out permissions directly; it
  2. // must always grant permissions on behalf of someone explicit.
  3. final int callingAppId = UserHandle.getAppId(callingUid);
  4. if ((callingAppId == SYSTEM_UID) || (callingAppId == ROOT_UID)) {
  5. if ("com.android.settings.files".equals(grantUri.uri.getAuthority())) {
  6. // Exempted authority for cropping user photos in Settings app
  7. } else if ("com.joson.adphonelauncher.fileProvider".equals(grantUri.uri.getAuthority())) {
  8. }else {
  9. Slog.w(TAG, "For security reasons, the system cannot issue a Uri permission"
  10. + " grant to " + grantUri + "; use startActivityAsCaller() instead");
  11. return -1;
  12. }
  13. }

参考:

https://blog.csdn.net/hanhan1016/article/details/79421570

https://blog.csdn.net/qq_36118367/article/details/79700198 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/188973
推荐阅读
相关标签
  

闽ICP备14008679号