Introduce OfflineManager.runPackDatabaseAutomatically(boolean) API (#78)

* [offline] Introduce OfflineManager.runPackDatabaseAutomatically(boolean) API

* [doc]  update changelog

* [doc] add note to offline region delete API
This commit is contained in:
Tobrun
2019-12-03 16:28:16 +01:00
committed by GitHub
parent 8fe32cc8ac
commit e8678922e4
4 changed files with 38 additions and 55 deletions

View File

@@ -310,6 +310,10 @@ public class OfflineManager {
/**
* Packs the existing database file into a minimal amount of disk space.
* <p>
* This operation has a performance impact as it will vacuum the database,
* forcing it to move pages on the filesystem.
* </p>
* <p>
* 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.
* <p>
* 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)}).
* </p>
* <p>
* Resources overlapping with offline regions will not be affected
@@ -662,7 +666,7 @@ public class OfflineManager {
* <p>
* 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)}.
* </p>
*
* @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.
* <p>
* 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.
* </p>
*
* @param autopack flag setting the automatic database file packing.
*/
@Keep
public native void runPackDatabaseAutomatically(boolean autopack);
@Keep
private native void initialize(FileSource fileSource);