diff --git a/CHANGELOG.md b/CHANGELOG.md index d18f4f863..b24c41ef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,18 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. ## master + +### Features +- Introduce OfflineManager.runPackDatabaseAutomatically(boolean) and remove the redundant OfflineRegion.deleteAndSkipPackDatabase() method [#78](https://github.com/mapbox/mapbox-gl-native-android/pull/78) + ### Performance improvements - Make network requests for expired resources lower priority than requests for new resources. ([#15950](https://github.com/mapbox/mapbox-gl-native/pull/15950)) ### Bug fixes - Fixed a bug where location camera mode transition callback would not get notified if the requested mode was already set. [#80](https://github.com/mapbox/mapbox-gl-native-android/pull/80) - Fixed a bug where location tilt/zoom while tracking callback would not get notified if the request was ignored. [#83](https://github.com/mapbox/mapbox-gl-native-android/pull/83) +- Use -Oz to reduce binary size [#15984](https://github.com/mapbox/mapbox-gl-native/pull/15984) +- Use icf=all compile flag to reduce binary size [#15987](https://github.com/mapbox/mapbox-gl-native/pull/15987) ## 8.6.0-alpha.2 - November 22, 2019 [Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.6.0-alpha.1...android-v8.6.0-alpha.2) since [Mapbox Maps SDK for Android v8.6.0-alpha.1](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.6.0-alpha.1): diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java index dec234adf..b5f296a7a 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java @@ -310,6 +310,10 @@ public class OfflineManager { /** * Packs the existing database file into a minimal amount of disk space. *

+ * This operation has a performance impact as it will vacuum the database, + * forcing it to move pages on the filesystem. + *

+ *

* When the operation is complete or encounters an error, the given callback will be * executed on the database thread; it is the responsibility of the SDK bindings * to re-execute a user-provided callback on the main thread. @@ -397,9 +401,9 @@ public class OfflineManager { /** * Erase resources from the ambient cache, freeing storage space. *

- * Erases the ambient cache, freeing resources. This operation can be - * potentially slow because it will trigger a VACUUM on SQLite, - * forcing the database to move pages on the filesystem. + * Erases the ambient cache, freeing resources. + * Note that this operation can be potentially slow if packing the database + * occurs automatically ({@link OfflineManager#runPackDatabaseAutomatically(boolean)}). *

*

* Resources overlapping with offline regions will not be affected @@ -662,7 +666,7 @@ public class OfflineManager { *

* Once this limit is reached, {@link OfflineRegion.OfflineRegionObserver#mapboxTileCountLimitExceeded(long)} * fires every additional attempt to download additional tiles until already downloaded tiles are removed - * by calling {@link OfflineRegion#deleteOfflineRegion(OfflineRegion.OfflineRegionDeleteCallback)}. + * by calling {@link OfflineRegion#delete(OfflineRegion.OfflineRegionDeleteCallback)}. *

* * @param limit the maximum number of tiles allowed to be downloaded @@ -670,6 +674,25 @@ public class OfflineManager { @Keep public native void setOfflineMapboxTileCountLimit(long limit); + + /** + * Sets whether database file packing occurs automatically. + * By default, the automatic database file packing is enabled. + *

+ * If packing is enabled, database file packing occurs automatically + * after an offline region is deleted by calling + * {@link OfflineRegion#delete(OfflineRegion.OfflineRegionDeleteCallback)} + * or the ambient cache is cleared by calling {@link OfflineManager#clearAmbientCache()}. + * + * If packing is disabled, disk space will not be freed after + * resources are removed unless {@link OfflineManager#packDatabase()} is explicitly called. + *

+ * + * @param autopack flag setting the automatic database file packing. + */ + @Keep + public native void runPackDatabaseAutomatically(boolean autopack); + @Keep private native void initialize(FileSource fileSource); diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java index 2ad66f044..79928c649 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java @@ -391,6 +391,8 @@ public class OfflineRegion { * When the operation is complete or encounters an error, the given callback will be * executed on the main thread. *

+ * Note that this operation can be potentially slow if packing the database + * occurs automatically ({@link OfflineManager#runPackDatabaseAutomatically(boolean)}) *

* After you call this method, you may not call any additional methods on this object. *

@@ -401,55 +403,7 @@ public class OfflineRegion { if (!isDeleted) { isDeleted = true; fileSource.activate(); - deleteOfflineRegion(true /*pack*/, new OfflineRegionDeleteCallback() { - @Override - public void onDelete() { - handler.post(new Runnable() { - @Override - public void run() { - fileSource.deactivate(); - callback.onDelete(); - OfflineRegion.this.finalize(); - } - }); - } - - @Override - public void onError(final String error) { - handler.post(new Runnable() { - @Override - public void run() { - isDeleted = false; - fileSource.deactivate(); - callback.onError(error); - } - }); - } - }); - } - } - - /** - * Same as {@link OfflineRegion#delete} but skipping database file packing for performance reasons. - *

- * Database file packing can be done later with {@link OfflineManager#packDatabase}. - * This method is a useful optimization e.g. when several regions should be deleted in a row. - *

- *

- * When the operation is complete or encounters an error, the given callback will be - * executed on the main thread. - *

- *

- * After you call this method, you may not call any additional methods on this object. - *

- * - * @param callback the callback to be invoked - */ - public void deleteAndSkipPackDatabase(@NonNull final OfflineRegionDeleteCallback callback) { - if (!isDeleted) { - isDeleted = true; - fileSource.activate(); - deleteOfflineRegion(false /*pack*/, new OfflineRegionDeleteCallback() { + deleteOfflineRegion(new OfflineRegionDeleteCallback() { @Override public void onDelete() { handler.post(new Runnable() { @@ -569,7 +523,7 @@ public class OfflineRegion { private native void getOfflineRegionStatus(OfflineRegionStatusCallback callback); @Keep - private native void deleteOfflineRegion(boolean pack, OfflineRegionDeleteCallback callback); + private native void deleteOfflineRegion(OfflineRegionDeleteCallback callback); @Keep private native void updateOfflineRegionMetadata(byte[] metadata, OfflineRegionUpdateMetadataCallback callback); diff --git a/vendor/mapbox-gl-native b/vendor/mapbox-gl-native index f10097640..e373d8a59 160000 --- a/vendor/mapbox-gl-native +++ b/vendor/mapbox-gl-native @@ -1 +1 @@ -Subproject commit f10097640a8a62f9a139952844a75ac9b0b12543 +Subproject commit e373d8a5924e4f4cf3904ecacbf1d1cf86a5d60f