最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google maps - Is it possible to remove the location permission only from an SDK used in an Android app? - Stack Overflow

programmeradmin3浏览0评论

I know that you can remove the location permission from an app via the code below in AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
        tools:node="remove" />

But this removes the fine location permission from the entire app which needs it for its functionality. Is it possible to remove this permission only from a library dependency used in the app? I'm trying to prevent the ad SDKs in my app to access the user's fine location for privacy reasons.

I know that you can remove the location permission from an app via the code below in AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
        tools:node="remove" />

But this removes the fine location permission from the entire app which needs it for its functionality. Is it possible to remove this permission only from a library dependency used in the app? I'm trying to prevent the ad SDKs in my app to access the user's fine location for privacy reasons.

Share Improve this question asked Feb 15 at 1:53 doctorramdoctorram 1,22017 silver badges15 bronze badges 1
  • You would need the developer of that SDK to remove it from the library's manifest. There might be also something you can when all the manifests merge (developer.android/build/manage-manifests), but am unsure if you actually do something there. – tomerpacific Commented Feb 15 at 8:11
Add a comment  | 

1 Answer 1

Reset to default 0

Is it possible to remove this permission only from a library dependency used in the app?

No. At runtime, there is no distinction between library code and other code. Permissions affect the entire app, regardless of where the code comes from.

I'm trying to prevent the ad SDKs in my app to access the user's fine location for privacy reasons

That is a noble objective. One hack you could try is to block the ad SDK's access to LocationManager. If you pass a Context into the SDK, rather than just passing the Application singleton or an Activity or something, you could pass a ContextWrapper subclass around that context, where your subclass overrides the flavors of getSystemService() and returns null or a fake for requests for LocationManager. This might screw up other things in the SDK, and the SDK might be able to obtain a Context by other means (e.g., registering a ContentProvider).

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论