Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/#1289_2 - normalizing user agent and disabling preventive downloads #1293

Merged
merged 1 commit into from Mar 9, 2019

Conversation

Projects
None yet
3 participants
@monsieurtanuki
Copy link
Collaborator

monsieurtanuki commented Mar 8, 2019

… for MAPNIK

Around TileSourcePolicy:

  • "normalized" user agent (package name + "/" + version)
  • disabling preventive download

Impacted classes:

  • DefaultConfigurationProvider: new member String mNormalizedUserAgent and its getter; new method computeNormalizedUserAgent(Context) to compute its value
  • IConfigurationProvider: added method String getNormalizedUserAgent()
  • MapTilePreCache: added a check in method search - if the tile source policy says "we don't try to preventively download tiles", there won't be any download attempt
  • MapTileProviderBasic: added the MapTileDownloader in the pre-cache tile providers
  • TileDownloader: in downloadTile, uses the normalized user agent if the tile source policy says so
  • TileSourceFactory: edited the TileSourcePolicy related to MAPNIK (new parameters)
  • TileSourcePolicy: now using int flags instead of booleans (therefore new constructor); new methods acceptsPreventive and normalizesUserAgent
feature/#1289_2 - normalizing user agent and disabling preventive dow…
…nloads for MAPNIK

Around `TileSourcePolicy`:
* "normalized" user agent (package name + "/" + version)
* disabling preventive download

Impacted classes:
* `DefaultConfigurationProvider`: new member `String mNormalizedUserAgent` and its getter; new method `computeNormalizedUserAgent(Context)` to compute its value
* `IConfigurationProvider`: added method `String getNormalizedUserAgent()`
* `MapTilePreCache`: added a check in method `search` - if the tile source policy says "we don't try to preventively download tiles", there won't be any download attempt
* `MapTileProviderBasic`: added the `MapTileDownloader` in the pre-cache tile providers
* `TileDownloader`: in `downloadTile`, uses the normalized user agent if the tile source policy says so
* `TileSourceFactory`: edited the `TileSourcePolicy` related to MAPNIK (new parameters)
* `TileSourcePolicy`: now using `int` flags instead of `boolean`s (therefore new constructor); new methods `acceptsPreventive` and `normalizesUserAgent`

@monsieurtanuki monsieurtanuki merged commit 7292c99 into master Mar 9, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@akoua

This comment has been minimized.

Copy link

akoua commented Mar 9, 2019

Please @monsieurtanuki how can I modify these classes in my project ? (I ask this question because I know that it's impossible to modify a class of OSMdroid in an android project)

@monsieurtanuki

This comment has been minimized.

Copy link
Collaborator Author

monsieurtanuki commented Mar 10, 2019

@akoua

  • if you have a problem with the maps not being displayed, the fix is probably just to set a relevant user agent, using something like this: Configuration.getInstance().setUserAgentValue(context.getPackageName());
  • if you really want the latest version of those classes, you can get the full sources and include them in your code (which makes obvious the fact that I'm not a git expert)
  • if you want to modify those classes in order to contribute to osmdroid, welcome!

I hope this helps.

@ambrose-at-cordic

This comment has been minimized.

Copy link

ambrose-at-cordic commented Mar 13, 2019

I have an app which was being blocked as it was using a unique string rather than the package name for the user-agent value,

Once I used: OpenStreetMapTileProviderConstants.setUserAgentValue(getApplicationContext().getPackageName()): instead, that resolved the problem. The problem is, when our tested tried reporduce the problem on the same device with version of the app without the aforemenioned change, it wasn't blocked. Why would this happen? shouldn't it have blocked it once it had seen the invalid user-agent value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.