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
1 Answer
Reset to default 0Is 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
).