From 61433f961a20757907ade6bfa81919ad1bab355e Mon Sep 17 00:00:00 2001 From: vshcherb Date: Sat, 17 Aug 2013 23:33:19 +0200 Subject: [PATCH] Update native interface --- OsmAnd-java/src/net/osmand/NativeLibrary.java | 29 +++++++++++------ .../osmand/binary/BinaryInspectorNative.java | 7 ----- .../activities/SettingsGeneralActivity.java | 2 -- .../plus/render/NativeOsmandLibrary.java | 31 +++++++++++-------- 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/NativeLibrary.java b/OsmAnd-java/src/net/osmand/NativeLibrary.java index e9e2531083..c9629fa970 100644 --- a/OsmAnd-java/src/net/osmand/NativeLibrary.java +++ b/OsmAnd-java/src/net/osmand/NativeLibrary.java @@ -28,7 +28,13 @@ import net.osmand.router.RoutingConfiguration; public class NativeLibrary { - public static class RenderingGenerationResult { + protected final boolean newLibrary; + + public NativeLibrary(boolean newLibrary) { + this.newLibrary = newLibrary; + } + + public static class RenderingGenerationResult { public RenderingGenerationResult(ByteBuffer bitmap) { bitmapBuffer = bitmap; } @@ -84,7 +90,7 @@ public class NativeLibrary { } /** - * @param searchResultHandle + * @param * - must be null if there is no need to append to previous results returns native handle to results */ public NativeSearchResult searchObjectsForRendering(int sleft, int sright, int stop, int sbottom, int zoom, @@ -106,7 +112,12 @@ public class NativeLibrary { } public boolean initMapFile(String filePath) { - return initBinaryMapFile(filePath); + if(newLibrary) { + // TODO + return initBinaryMapFile(filePath); + } else { + return initBinaryMapFile(filePath); + } } public boolean initCacheMapFile(String filePath) { @@ -221,13 +232,10 @@ public class NativeLibrary { */ private static final Log log = PlatformUtil.getLog(NativeLibrary.class); - public static boolean loadAllLibs(String path) { - boolean b = true; - b &= load("Qt5Core", path); - b &= load("OsmAndCore", path); - b &= load("OsmAndCoreUtils", path); - b &= load("OsmAndJNI", path); - return b; + + + public static boolean loadNewLib(String path) { + return load("OsmAndJNI", path); } public static boolean loadOldLib(String path) { @@ -289,4 +297,5 @@ public class NativeLibrary { } // fall through return false; } + } diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryInspectorNative.java b/OsmAnd-java/src/net/osmand/binary/BinaryInspectorNative.java index 5fdd613fcc..cc9710b53c 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryInspectorNative.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryInspectorNative.java @@ -2,9 +2,6 @@ package net.osmand.binary; import java.io.IOException; -import java.util.Collections; - -import net.osmand.NativeLibrary; public class BinaryInspectorNative { @@ -18,10 +15,6 @@ public class BinaryInspectorNative { } args = new String[]{"-vmap", "-bbox=11.3,47.1,11.6,47", "/home/victor/projects/OsmAnd/data/osm-gen/Austria_2.obf"}; // test cases show info - NativeLibrary.loadAllLibs(null); -// StringVector vector = new StringVector(); -// Collections.addAll(vector, args); -// ObfInspector.inspector(vector); } public static void printUsage(String warning) { diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index f94311cfea..0c402bd3ea 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -44,7 +44,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { private Preference applicationDir; private ListPreference applicationModePreference; private ListPreference drivingRegionPreference; - private ListPreference metricsAndConstantsPreference; @Override @@ -211,7 +210,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { applicationModePreference = (ListPreference) screen.findPreference(settings.APPLICATION_MODE.getId()); applicationModePreference.setOnPreferenceChangeListener(this); drivingRegionPreference = (ListPreference) screen.findPreference(settings.DRIVING_REGION.getId()); - metricsAndConstantsPreference = (ListPreference) screen.findPreference(settings.METRIC_SYSTEM.getId()); } diff --git a/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java b/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java index d0116a41d1..ab7ad31577 100644 --- a/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java +++ b/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java @@ -17,14 +17,19 @@ public class NativeOsmandLibrary extends NativeLibrary { private static NativeOsmandLibrary library; private static Boolean isNativeSupported = null; - - public static NativeOsmandLibrary getLoadedLibrary(){ + + public NativeOsmandLibrary(boolean newLibrary) { + super(newLibrary); + } + + public static NativeOsmandLibrary getLoadedLibrary(){ synchronized (NativeOsmandLibrary.class) { return library; } } - public static NativeOsmandLibrary getLibrary(RenderingRulesStorage storage, ClientContext ctx) { + + public static NativeOsmandLibrary getLibrary(RenderingRulesStorage storage, ClientContext ctx) { if (!isLoaded()) { synchronized (NativeOsmandLibrary.class) { if (!isLoaded()) { @@ -43,7 +48,7 @@ public class NativeOsmandLibrary extends NativeLibrary { try { loadNewCore(libCpuSuffix); log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$ - library = new NativeOsmandLibrary(); + library = new NativeOsmandLibrary(true); isNativeSupported = true; } catch(Throwable e) { log.error("Failed to load new native library", e); //$NON-NLS-1$ @@ -51,7 +56,7 @@ public class NativeOsmandLibrary extends NativeLibrary { if(!isNativeSupported) { loadOldCore(libCpuSuffix); log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$ - library = new NativeOsmandLibrary(); + library = new NativeOsmandLibrary(false); log.debug("Initializing rendering rules storage..."); //$NON-NLS-1$ NativeOsmandLibrary.initRenderingRulesStorage(storage); isNativeSupported = true; @@ -70,13 +75,13 @@ public class NativeOsmandLibrary extends NativeLibrary { } private static void loadNewCore(final String libCpuSuffix) { - System.loadLibrary("Qt5Core" + libCpuSuffix); - System.loadLibrary("Qt5Network" + libCpuSuffix); - System.loadLibrary("Qt5Concurrent" + libCpuSuffix); - System.loadLibrary("Qt5Sql" + libCpuSuffix); - System.loadLibrary("Qt5Xml" + libCpuSuffix); - System.loadLibrary("OsmAndCore" + libCpuSuffix); - System.loadLibrary("OsmAndCoreUtils" + libCpuSuffix); +// System.loadLibrary("Qt5Core" + libCpuSuffix); +// System.loadLibrary("Qt5Network" + libCpuSuffix); +// System.loadLibrary("Qt5Concurrent" + libCpuSuffix); +// System.loadLibrary("Qt5Sql" + libCpuSuffix); +// System.loadLibrary("Qt5Xml" + libCpuSuffix); +// System.loadLibrary("OsmAndCore" + libCpuSuffix); +// System.loadLibrary("OsmAndCoreUtils" + libCpuSuffix); System.loadLibrary("OsmAndJNI" + libCpuSuffix); } @@ -103,7 +108,7 @@ public class NativeOsmandLibrary extends NativeLibrary { public RenderingGenerationResult generateRendering(RenderingContext rc, NativeSearchResult searchResultHandler, Bitmap bitmap, boolean isTransparent, RenderingRuleSearchRequest render) { if (searchResultHandler == null) { - log.error("Error searchresult = null"); //$NON-NLS-1$ + log.error("Error search result = null"); //$NON-NLS-1$ return new RenderingGenerationResult(null); }