java.lang.Object | |
↳ | com.carto.packagemanager.PackageManager |
![]() |
Base class for offline map package manager. Package manager supports downloading/removing packages.
It can be queried about available packages and status of the packages. It works asynchronously in
the background and can inform app when packages have been updated.
It works persistently. If a package download is started and app is closed, the download will resume
when the package manager is started next time.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
PackageManager(String packageListURL, String dataFolder, String serverEncKey, String localEncKey)
Constructs a new package manager, given URL for package list and data folder.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
cancelPackageTasks(String packageId)
Cancels the current/pending tasks involving of the specified package.
| ||||||||||
synchronized void | delete() | ||||||||||
boolean |
equals(Object obj)
Checks if this object is equal to the specified object.
| ||||||||||
PackageInfo |
getLocalPackage(String packageId)
Returns the specified local package.
| ||||||||||
PackageStatus |
getLocalPackageStatus(String packageId, int version)
Returns the status of the specified package.
| ||||||||||
PackageInfoVector |
getLocalPackages()
Returns the list of available local downloaded packages.
| ||||||||||
PackageManagerListener |
getPackageManagerListener()
Returns the current listener for package manager events.
| ||||||||||
PackageInfo |
getServerPackage(String packageId)
Returns the specified server package.
| ||||||||||
int |
getServerPackageListAge()
Returns the age of server package list.
| ||||||||||
PackageMetaInfo |
getServerPackageListMetaInfo()
Returns the metainfo of server packages.
| ||||||||||
PackageInfoVector |
getServerPackages()
Returns the list of available server packages.
| ||||||||||
int |
hashCode()
Returns the hash value of this object.
| ||||||||||
boolean |
isAreaDownloaded(MapBounds mapBounds, int zoom, Projection projection)
Tests if the specified map area at specified zoom level is downloaded.
| ||||||||||
void |
setPackageManagerListener(PackageManagerListener listener)
Sets the package manager listener.
| ||||||||||
void |
setPackagePriority(String packageId, int priority)
Sets the priority of the specific package.
| ||||||||||
boolean |
start()
Starts the package manager.
| ||||||||||
boolean |
startPackageDownload(String packageId)
Starts downloading specified package asynchronously.
| ||||||||||
boolean |
startPackageImport(String packageId, int version, String packageFileName)
Starts importing the specified package asynchronously.
| ||||||||||
boolean |
startPackageListDownload()
Starts downloading package list asynchronously.
| ||||||||||
boolean |
startPackageRemove(String packageId)
Starts the removal of specified package asynchronously.
| ||||||||||
void |
stop(boolean wait)
Stops the package manager.
| ||||||||||
PackageInfoVector |
suggestPackages(MapPos mapPos, Projection projection)
Suggests packages for given map position.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Constructs a new package manager, given URL for package list and data folder.
The data folder must exist before creating a new package manager and it is assumed to be persistent.
Note: the package manager must be explicitly started using start() method!
packageListURL | The URL that defines all packages. |
---|---|
dataFolder | The folder where downloaded packages are kept. It must exist and must be writable. |
serverEncKey | Encryption key for server packages |
localEncKey | Encryption key for local packages |
Exception | If package manager fails to open or create package database. |
---|---|
IOException |
Cancels the current/pending tasks involving of the specified package.
packageId | The id of the package to cancel. |
---|
Checks if this object is equal to the specified object.
obj | The reference object. |
---|
Returns the specified local package.
packageId | The id of the package. |
---|
Returns the status of the specified package.
packageId | The id of the package. |
---|---|
version | The version of the package. Use -1 for the latest version. |
Returns the list of available local downloaded packages.
Returns the current listener for package manager events.
Returns the specified server package.
Note that the list must be retrieved from the server first, using startPackageListDownload.
packageId | The id of the package. |
---|
Returns the age of server package list. This method can be used to measure the time of the download and check whether the list should be updated.
Returns the metainfo of server packages.
Returns the list of available server packages.
Note that the list must be retrieved from the server first, using startPackageListDownload.
Returns the hash value of this object.
Tests if the specified map area at specified zoom level is downloaded.
mapBounds | The area bounding box. |
---|---|
zoom | The zoom level to check. |
projection | The projection for the bounding box. |
Sets the package manager listener.
listener | The new package manager listener to use. |
---|
Sets the priority of the specific package.
If the given priority is higher than priority of any other package, other operations will be paused and this package is processed immediately.
If the given priority is set to negative value, package download will be paused until priority is reset to non-negative value.
packageId | The id of the download package. |
---|---|
priority | The priority of the download package. If it is less than zero, package download is paused. |
Starts the package manager. All previous tasks will be resumed after this.
Starts downloading specified package asynchronously. When this task finishes, listener is called and local package list is updated.
Note: In general, package manager may need temporary storage equal to the size of the package during download. It is the responsibility of the app to perform such checks.
packageId | The id of the package to download. |
---|
Starts importing the specified package asynchronously. When this task finishes, listener is called and local package list is updated.
Note 1: In general, package manager may need temporary storage equal to the size of the package during import. It is the responsibility of the app to perform such checks.
Note 2: the package may not be deleted after this call, as the import is asynchronous operation. It is safe to delete the original file once import is complete (this is notified via manager listener).
packageId | The id of the package to download. |
---|---|
version | The version of the package. |
packageFileName | The fully qualified path of the package. The file name may also refer to URL or asset (using 'asset://' prefix). |
Starts downloading package list asynchronously. When this task finishes, listener is called and server package list is updated.
Starts the removal of specified package asynchronously. When this task finishes, listener is called and local package list is updated.
packageId | The id of the package to remove. |
---|
Stops the package manager. The stopping can be asynchronous or synchronous.
wait | If set to true, then synchronous stopping is performed and the operation may take a while. |
---|
Suggests packages for given map position. Note that in order this to work, local package list must be available first.
mapPos | The map position. |
---|---|
projection | The projection for the map position. |