gpt4 book ai didi

android - 为什么我的应用程序要求电话 ID 权限?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:22:45 25 4
gpt4 key购买 nike

在我的 list 中,我只要求这两个权限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

但是当我在手机上安装该应用程序时,我也会收到此通知:

Low-risk permissions
Phone ID
Get your phone ID, including IMEI, IMSI, etc.

根据我从 this SO answer 收集到的信息,我应该需要使用 TelephonyManager 并调用

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

需要此权限。但我没有使用 TelephonyManager 或调用该权限。我不想要求用户授予此权限。我查看了我的 list 和 gradle 文件。会不会是我使用的某些代码在没有我特别要求的情况下触发了此权限?我知道我不会给你很多继续的东西,因为我不知道还有什么地方可以看。

更新 1

我在 Android Studio 中创建了一个全新的项目,并从中生成了一个签名的 APK。我安装了它,但没有询问任何权限。 (这至少让我确认,并不是 Android Studio 中的某些“新功能”自动请求此权限。)

更新 2

在@antonio 的回答中,我找到了 app/build/outputs/logs/manifest-merger-release-report.txt 但是,我没有发现任何隐含的权限请求。

更新 3

以下是我的应用使用的依赖项(来自 gradle.build):

dependencies {
compile 'com.android.support:support-v4:21.0.3'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
}

我用这两个依赖项测试了一个新应用程序,没有请求任何权限。

我的下一步是从头开始重新添加每个 Activity ,看看我是否可以找到开始调用此权限的位置。待续……

更新 4

我试过将所有内容复制到一个新项目并重构项目名称并删除部分,但事实证明它非常复杂。我无法找出原因。

更新 5

我将 targetSdkVersion 设置为 1。这会在安装应用程序之前宣布权限时给出一条新消息:

read phone status and identity

Allows the app to access the phone features of the device. This permission allows the app to determine the phone number and device IDs, whether the call is active, and the remote number connected by a call.

我在开头写的旧电话 ID 权限通知仍然存在(安装应用程序后显示)。这让我想知道它是否与操作系统有关(我在小米手机上使用 MIUI Android)。仍然有一些关于应用程序的东西导致它显示在这个应用程序中而不是在其他应用程序中。接下来我需要在其他设备上对此进行测试。

最佳答案

发生这种情况是因为您导入的库的 targetSdkVersion 低于应用程序的 targetSdkVersion

来自Manifest Merger documentation :

When importing a library with a targetSdkVersion lower than the importing application targetSdkVersion, some permissions maybe automatically added to the resulting merged manifest file. This is necessary since such libraries targeted runtimes where such permissions were implicitly granted. Therefore declaring such permission was not necessary. However in more recent Android releases, these permissions are not automatically granted. Therefore, a library targeting such old runtime without the permissions would not work properly once merged in the application targeting a more recent runtime.

可以添加的权限有:

  • WRITE_EXTERNAL_STORAGE 在导入 targetSdkVersion < 4
  • 的库时添加
  • READ_EXTERNAL_STORAGE 在导入声明了 WRITE_EXTERNAL_STORAGE 的库时添加
  • READ_PHONE_STATE 在导入 targetSdkVersion < 4 的库时添加
  • READ_CALL_LOG 在导入 targetSdkVersion < 16 的库并使用 READ_CONTACTS 权限时添加
  • WRITE_CALL_LOG 在导入 targetSdkVersion < 16 的库并使用 WRITE_CONTACTS 权限时添加

您可以检查 Manifest Merger 生成的报告(在\app\build\outputs\logs\manifest-merger-XXX-report 中)以查看是哪个库导致添加了 READ_PHONE_STATE 权限。你会看到类似这样的东西:

android:uses-permission#android.permission.READ_PHONE_STATE
IMPLIED from AndroidManifest.xml:2:1 reason: the.library has a targetSdkVersion < 4

在多模块 gradle-project 中,必须应用匹配的配置,如 defaultConfig{ ... },其中应指定 targetSdkVersion 以解析这些 IMPLIED 权限。

关于android - 为什么我的应用程序要求电话 ID 权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30277242/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com