Skip to content

Commit

Permalink
ignored internal databases support (including ue3.db)
Browse files Browse the repository at this point in the history
  • Loading branch information
bosborn committed Feb 12, 2024
1 parent 3ea3c90 commit 465d1eb
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Adheres to [Semantic Versioning](http://semver.org/).
## 6.7.4 (TBD)

* geopackage-core version 6.6.7
* Ignored internal databases support for non GeoPackages (preconfigured to ignore ue3.db for Google Maps)

## [6.7.3](https://github.com/ngageoint/geopackage-android/releases/tag/6.7.3) (11-30-2023)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,39 @@ public boolean importGeoPackage(String name, URL url, boolean override,
*/
public void setSqliteWriteAheadLogging(boolean enabled);

/**
* Get the ignored internal databases
*
* @return databases
* @since 6.7.4
*/
public Set<String> getIgnoredInternals();

/**
* Is the database an ignored internal database by name
*
* @param database database name
* @return true if ignored
* @since 6.7.4
*/
public boolean isIgnoredInternal(String database);

/**
* Ignore an internal database by name
*
* @param database database name
* @since 6.7.4
*/
public void ignoreInternal(String database);

/**
* Do not ignore an internal database by name
*
* @param database database name
* @since 6.7.4
*/
public void includeInternal(String database);

/**
* Validate the database header and integrity.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -82,6 +83,11 @@ public class GeoPackageManagerImpl implements GeoPackageManager {
*/
private boolean sqliteWriteAheadLogging = false;

/**
* Ignore internal database names
*/
private Set<String> ignoredInternals = new HashSet<>();

/**
* Constructor
*
Expand All @@ -97,6 +103,11 @@ protected GeoPackageManagerImpl(Context context) {
openHeaderValidation = resources.getBoolean(R.bool.manager_validation_open_header);
openIntegrityValidation = resources.getBoolean(R.bool.manager_validation_open_integrity);
sqliteWriteAheadLogging = resources.getBoolean(R.bool.sqlite_write_ahead_logging);

ignoreInternal(GeoPackageMetadataDb.DATABASE_NAME);
for (String database: resources.getStringArray(R.array.geopackage_ignored_internals)) {
ignoreInternal(database);
}
}
}

Expand Down Expand Up @@ -1245,6 +1256,34 @@ public void setSqliteWriteAheadLogging(boolean enabled) {
this.sqliteWriteAheadLogging = enabled;
}

/**
* {@inheritDoc}
*/
public Set<String> getIgnoredInternals(){
return Collections.unmodifiableSet(ignoredInternals);
}

/**
* {@inheritDoc}
*/
public boolean isIgnoredInternal(String database){
return ignoredInternals.contains(database.toLowerCase());
}

/**
* {@inheritDoc}
*/
public void ignoreInternal(String database){
ignoredInternals.add(database.toLowerCase());
}

/**
* {@inheritDoc}
*/
public void includeInternal(String database){
ignoredInternals.remove(database.toLowerCase());
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -1544,8 +1583,7 @@ private void addInternalDatabases(Collection<String> databases) {
String[] databaseArray = getRequiredContext().databaseList();
for (String database : databaseArray) {
if (!isTemporary(database)
&& !database
.equalsIgnoreCase(GeoPackageMetadataDb.DATABASE_NAME)) {
&& !isIgnoredInternal(database)) {
databases.add(database);
}
}
Expand Down
4 changes: 4 additions & 0 deletions geopackage-sdk/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<string name="geopackage_db_write_ahead_log_suffix">-wal</string>
<string name="geopackage_db_shared_memory_suffix">-shm</string>

<array name="geopackage_ignored_internals">
<item>ue3.db</item>
</array>

<string name="tile_generator_variable_z">\\{z\\}</string>
<string name="tile_generator_variable_x">\\{x\\}</string>
<string name="tile_generator_variable_y">\\{y\\}</string>
Expand Down

0 comments on commit 465d1eb

Please sign in to comment.