我自己构建ROM后未授予应用程序签名权限

时间:2018-10-24 08:39:52

标签: android

我正在计算机上构建LineageOS(接近AOSP的自定义rom),并希望内置的下载管理器(com.android.providers.downloads)检查是否允许请求实体访问网络。因此,我向DownloadThread.java添加了一些演示代码片段,并向下载管理器的AndroidManifest.xml添加了权限MANAGE_NETWORK_POLICY(保护级别签名)。

演示代码段(相关部分是android.net.NetworkPolicyManager.getUidPolicy):

if ((mNetworkPolicy.getUidPolicy(mInfo.mUid) & POLICY_REJECT_ON_WLAN) == 1) {
mInfoDelta.mNumFailed = Constants.MAX_RETRIES;
throw new StopRequestException(STATUS_HTTP_DATA_ERROR, 
        "App is not allowed to access the internet");
}

执行此操作

Failed: java.lang.SecurityException: NetworkPolicy: Neither user 10010 (this is Download Manager) nor current process has android.permission.MANAGE_NETWORK_POLICY [...] at android.net.NetworkPolicyManager.getUidPolicy at com.android.providers.downloads.DownloadThread.run

我选中了“ adb shell pm dump com.android.providers.downloads”并获得

  requested permissions:
    android.permission.RECEIVE_BOOT_COMPLETED
    android.permission.ACCESS_DOWNLOAD_MANAGER
    android.permission.ACCESS_CACHE_FILESYSTEM
    android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS
    android.permission.ACCESS_NETWORK_STATE
    android.permission.INTERNET
    android.permission.WRITE_EXTERNAL_STORAGE
    android.permission.ACCESS_ALL_DOWNLOADS
    android.permission.UPDATE_DEVICE_STATS
    android.permission.CONNECTIVITY_INTERNAL
    android.permission.CLEAR_APP_CACHE
    android.permission.WAKE_LOCK
    android.permission.UPDATE_APP_OPS_STATS
    android.permission.MANAGE_NETWORK_POLICY
    android.permission.READ_EXTERNAL_STORAGE
  install permissions:
    android.permission.ACCESS_CACHE_FILESYSTEM: granted=true
    android.permission.WRITE_SETTINGS: granted=true
    android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS: granted=true
    android.permission.RECEIVE_BOOT_COMPLETED: granted=true
    android.permission.WRITE_MEDIA_STORAGE: granted=true
    android.permission.INTERNET: granted=true
    android.permission.UPDATE_DEVICE_STATS: granted=true
    android.permission.MANAGE_USB: granted=true
    android.permission.ACCESS_ALL_DOWNLOADS: granted=true
    android.permission.ACCESS_DOWNLOAD_MANAGER: granted=true
    android.permission.MANAGE_USERS: granted=true
    android.permission.ACCESS_NETWORK_STATE: granted=true
    android.permission.ACCESS_MTP: granted=true
    android.permission.INTERACT_ACROSS_USERS: granted=true
    android.permission.CLEAR_APP_CACHE: granted=true
    android.permission.CONNECTIVITY_INTERNAL: granted=true
    android.permission.WAKE_LOCK: granted=true
    android.permission.UPDATE_APP_OPS_STATS: granted=true
Shared users:
  SharedUser [android.media] (d3accd7):
    userId=10010
      install permissions:
        android.permission.ACCESS_CACHE_FILESYSTEM: granted=true
        android.permission.WRITE_SETTINGS: granted=true
        android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS: granted=true
        android.permission.RECEIVE_BOOT_COMPLETED: granted=true
        android.permission.WRITE_MEDIA_STORAGE: granted=true
        android.permission.INTERNET: granted=true
        android.permission.UPDATE_DEVICE_STATS: granted=true
        android.permission.MANAGE_USB: granted=true
        android.permission.ACCESS_ALL_DOWNLOADS: granted=true
        android.permission.ACCESS_DOWNLOAD_MANAGER: granted=true
        android.permission.MANAGE_USERS: granted=true
        android.permission.ACCESS_NETWORK_STATE: granted=true
        android.permission.ACCESS_MTP: granted=true
        android.permission.INTERACT_ACROSS_USERS: granted=true
        android.permission.CLEAR_APP_CACHE: granted=true
        android.permission.CONNECTIVITY_INTERNAL: granted=true
        android.permission.WAKE_LOCK: granted=true
        android.permission.UPDATE_APP_OPS_STATS: granted=true

为什么未授予下载管理器所请求的权限?最重要的是:我该如何更改?

显然“ pm授予com.android.providers.downloads android.permission.MANAGE_NETWORK_POLICY”无效:

Operation not allowed: java.lang.SecurityException: Permission android.permission.MANAGE_NETWORK_POLICY is not a changeable permission type

0 个答案:

没有答案