• Lv0
    粉丝0

积分2 / 贡献0

提问2答案被采纳0文章0

作者动态

settings申请权限ohos.permission.GET_NETWORK_INFO,运行时提示201

Balaur 显示全部楼层 发表于 9 小时前

【问题描述】

  1. 我想在OpenHarmony4.1 release版本的源码中对settings系统设置进行功能调整,为了便于迁移测试,提供了一个获取ip地址的子页面,需要使用到ohos.permission.GET_NETWORK_INFO权限,我已经通过module.json添加了对应的权限内容,但是安装后通过bm dump获取包权限列表不存在且运行时会提示getDefaultNetSync()接口权限不足。

  2. 相关的代码

        "requestPermissions": [
          {
            "name" : "ohos.permission.GET_NETWORK_INFO",
            "reason" : "$string:GET_NETWORK_INFO_PERMISSION"
          },
          {
            "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
            "reason": "$string:MANAGE_LOCAL_ACCOUNTS"
          },
          {
            "name": "ohos.permission.DISTRIBUTED_DATASYNC",
            "reason": "$string:DISTRIBUTED_DATASYNC"
          },
          {
            "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
            "reason": "$string:INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
          },
          {
            "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
            "reason": "$string:INTERACT_ACROSS_LOCAL_ACCOUNTS"
          },
          {
            "name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES",
            "reason": "$string:CLEAN_BACKGROUND_PROCESSES"
          },
          {
            "name": "ohos.permission.GET_RUNNING_INFO",
            "reason": "$string:GET_RUNNING_INFO"
          },
          {
            "name": "ohos.permission.CLEAN_APPLICATION_DATA",
            "reason": "$string:CLEAN_APPLICATION_DATA"
          },
          {
            "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
            "reason": "$string:GET_BUNDLE_INFO_PRIVILEGED"
          },
          {
            "name": "ohos.permission.INSTALL_BUNDLE",
            "reason": "$string:INSTALL_BUNDLE"
          },
          {
            "name": "ohos.permission.REMOVE_CACHE_FILES",
            "reason": "$string:REMOVE_CACHE_FILES"
          },
          {
            "name": "ohos.permission.USE_USER_IDM",
            "reason": "$string:USE_USER_IDM"
          },
          {
            "name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL",
            "reason": "$string:ACCESS_USER_AUTH_INTERNAL"
          },
          {
            "name": "ohos.permission.ACCESS_PIN_AUTH",
            "reason": "$string:ACCESS_PIN_AUTH"
          },
          {
            "name": "ohos.permission.MANAGE_USER_IDM",
            "reason": "$string:MANAGE_USER_IDM"
          },
          {
            "name": "ohos.permission.GET_WIFI_INFO",
            "reason": "$string:GET_WIFI_INFO"
          },
          {
            "name": "ohos.permission.SET_WIFI_INFO",
            "reason": "$string:SET_WIFI_INFO"
          },
          {
            "name": "ohos.permission.MANAGE_WIFI_CONNECTION",
            "reason": "$string:MANAGE_WIFI_CONNECTION"
          },
          {
            "name": "ohos.permission.SET_WIFI_CONFIG",
            "reason": "$string:SET_WIFI_CONFIG"
          },
          {
            "name": "ohos.permission.GET_WIFI_CONFIG",
            "reason": "$string:GET_WIFI_CONFIG"
          },
          {
            "name": "ohos.permission.GET_WIFI_INFO_INTERNAL",
            "reason": "$string:GET_WIFI_INFO_INTERNAL"
          },
          {
            "name": "ohos.permission.GET_WIFI_PEERS_MAC",
            "reason": "$string:GET_WIFI_PEERS_MAC"
          },
          {
            "name": "ohos.permission.USE_BLUETOOTH",
            "reason": "$string:USE_BLUETOOTH"
          },
          {
            "name": "ohos.permission.DISCOVER_BLUETOOTH",
            "reason": "$string:DISCOVER_BLUETOOTH"
          },
          {
            "name": "ohos.permission.LOCATION",
            "reason": "$string:LOCATION"
          },
          {
            "name": "ohos.permission.MANAGE_BLUETOOTH",
            "reason": "$string:MANAGE_BLUETOOTH"
          },
          {
            "name": "ohos.permission.MANAGE_SECURE_SETTINGS",
            "reason": "$string:MANAGE_SECURE_SETTINGS"
          },
          {
            "name": "ohos.permission.SET_TIME",
            "reason": "$string:SET_TIME"
          },
          {
            "name": "ohos.permission.SET_TIME_ZONE",
            "reason": "$string:SET_TIME_ZONE"
          },
          {
            "name": "ohos.permission.UPDATE_CONFIGURATION",
            "reason": "$string:UPDATE_CONFIGURATION"
          },
          {
            "name": "ohos.permission.FACTORY_RESET",
            "reason": "$string:FACTORY_RESET"
          },
          {
            "name": "ohos.permission.ACCESS_NOTIFICATION_POLICY",
            "reason": "$string:ACCESS_NOTIFICATION_POLICY"
          },
          {
            "name": "ohos.permission.MODIFY_AUDIO_SETTINGS",
            "reason": "$string:MODIFY_AUDIO_SETTINGS"
          },
          {
            "name": "ohos.permission.CONNECTIVITY_INTERNAL",
            "reason": "$string:CONNECTIVITY_INTERNAL"
          },
          {
            "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST",
            "reason": "$string:GET_INSTALLED_BUNDLE_LIST"
          },
          {
            "name": "ohos.permission.WRITE_ACCESSIBILITY_CONFIG",
            "reason": "$string:WRITE_ACCESSIBILITY_CONFIG_PERMISSION"
          },
          {
            "name": "ohos.permission.START_INVISIBLE_ABILITY",
            "reason": "$string:START_INVISIBLE_ABILITY"
          },
          {
            "name": "ohos.permission.LISTEN_BUNDLE_CHANGE",
            "reason": "$string:APPLICATION_EXTENDED_SERVICE_ACCESS"
          },
          {
            "name": "ohos.permission.READ_ACCESSIBILITY_CONFIG",
            "reason": "$string:READ_ACCESSIBILITY_CONFIG_PERMISSION"
          },
          {
            "name": "ohos.permission.sec.ACCESS_UDID",
            "reason": "$string:GET_ACCESS_UDID"
          }
        ]
  3. 运行结果、错误截图

    image.png

  4. 我尝试过的解决方法和结果

    我使用demo进行测试过,通过dev eco创建的项目添加了权限后也同样提示权限不足,只有在设置应用权限为system_base以上可以正常运行,不会出现权限不足的提示,这里为了确保不是其他权限引起,只申请了ohos.permission.GET_NETWORK_INFO,但是我查看文档说明,其中提到了关于ohos.permission.GET_NETWORK_INFO这个权限,是normal的,所以不明确为什么会出现这个情况。

    image.png

  5. 我想要达到的结果

    正常使用ohos.permission.GET_NETWORK_INFO,即可正常使用其接口,而不存在权限不足的情况。

【运行环境】

硬件: ROM版本:

OH版本:4.1 release DevEvoStudio版本:5.0.3.900 SDK版本:4.1.7.5 API 11

您尚未登录,无法参与评论,登录后可以:
参与开源共建问题交流
认同或收藏高质量问答
获取积分成为开源共建先驱

Copyright   ©2023  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

返回顶部