Update native interface

This commit is contained in:
vshcherb 2013-08-17 23:33:19 +02:00
parent dc9d7d2501
commit 61433f961a
4 changed files with 37 additions and 32 deletions

View file

@ -28,7 +28,13 @@ import net.osmand.router.RoutingConfiguration;
public class NativeLibrary { 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) { public RenderingGenerationResult(ByteBuffer bitmap) {
bitmapBuffer = 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 * - 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, 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) { public boolean initMapFile(String filePath) {
return initBinaryMapFile(filePath); if(newLibrary) {
// TODO
return initBinaryMapFile(filePath);
} else {
return initBinaryMapFile(filePath);
}
} }
public boolean initCacheMapFile(String filePath) { public boolean initCacheMapFile(String filePath) {
@ -221,13 +232,10 @@ public class NativeLibrary {
*/ */
private static final Log log = PlatformUtil.getLog(NativeLibrary.class); private static final Log log = PlatformUtil.getLog(NativeLibrary.class);
public static boolean loadAllLibs(String path) {
boolean b = true;
b &= load("Qt5Core", path); public static boolean loadNewLib(String path) {
b &= load("OsmAndCore", path); return load("OsmAndJNI", path);
b &= load("OsmAndCoreUtils", path);
b &= load("OsmAndJNI", path);
return b;
} }
public static boolean loadOldLib(String path) { public static boolean loadOldLib(String path) {
@ -289,4 +297,5 @@ public class NativeLibrary {
} // fall through } // fall through
return false; return false;
} }
} }

View file

@ -2,9 +2,6 @@ package net.osmand.binary;
import java.io.IOException; import java.io.IOException;
import java.util.Collections;
import net.osmand.NativeLibrary;
public class BinaryInspectorNative { 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"}; 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 // test cases show info
NativeLibrary.loadAllLibs(null);
// StringVector vector = new StringVector();
// Collections.addAll(vector, args);
// ObfInspector.inspector(vector);
} }
public static void printUsage(String warning) { public static void printUsage(String warning) {

View file

@ -44,7 +44,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
private Preference applicationDir; private Preference applicationDir;
private ListPreference applicationModePreference; private ListPreference applicationModePreference;
private ListPreference drivingRegionPreference; private ListPreference drivingRegionPreference;
private ListPreference metricsAndConstantsPreference;
@Override @Override
@ -211,7 +210,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
applicationModePreference = (ListPreference) screen.findPreference(settings.APPLICATION_MODE.getId()); applicationModePreference = (ListPreference) screen.findPreference(settings.APPLICATION_MODE.getId());
applicationModePreference.setOnPreferenceChangeListener(this); applicationModePreference.setOnPreferenceChangeListener(this);
drivingRegionPreference = (ListPreference) screen.findPreference(settings.DRIVING_REGION.getId()); drivingRegionPreference = (ListPreference) screen.findPreference(settings.DRIVING_REGION.getId());
metricsAndConstantsPreference = (ListPreference) screen.findPreference(settings.METRIC_SYSTEM.getId());
} }

View file

@ -17,14 +17,19 @@ public class NativeOsmandLibrary extends NativeLibrary {
private static NativeOsmandLibrary library; private static NativeOsmandLibrary library;
private static Boolean isNativeSupported = null; private static Boolean isNativeSupported = null;
public static NativeOsmandLibrary getLoadedLibrary(){ public NativeOsmandLibrary(boolean newLibrary) {
super(newLibrary);
}
public static NativeOsmandLibrary getLoadedLibrary(){
synchronized (NativeOsmandLibrary.class) { synchronized (NativeOsmandLibrary.class) {
return library; return library;
} }
} }
public static NativeOsmandLibrary getLibrary(RenderingRulesStorage storage, ClientContext ctx) {
public static NativeOsmandLibrary getLibrary(RenderingRulesStorage storage, ClientContext ctx) {
if (!isLoaded()) { if (!isLoaded()) {
synchronized (NativeOsmandLibrary.class) { synchronized (NativeOsmandLibrary.class) {
if (!isLoaded()) { if (!isLoaded()) {
@ -43,7 +48,7 @@ public class NativeOsmandLibrary extends NativeLibrary {
try { try {
loadNewCore(libCpuSuffix); loadNewCore(libCpuSuffix);
log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$ log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$
library = new NativeOsmandLibrary(); library = new NativeOsmandLibrary(true);
isNativeSupported = true; isNativeSupported = true;
} catch(Throwable e) { } catch(Throwable e) {
log.error("Failed to load new native library", e); //$NON-NLS-1$ log.error("Failed to load new native library", e); //$NON-NLS-1$
@ -51,7 +56,7 @@ public class NativeOsmandLibrary extends NativeLibrary {
if(!isNativeSupported) { if(!isNativeSupported) {
loadOldCore(libCpuSuffix); loadOldCore(libCpuSuffix);
log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$ log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$
library = new NativeOsmandLibrary(); library = new NativeOsmandLibrary(false);
log.debug("Initializing rendering rules storage..."); //$NON-NLS-1$ log.debug("Initializing rendering rules storage..."); //$NON-NLS-1$
NativeOsmandLibrary.initRenderingRulesStorage(storage); NativeOsmandLibrary.initRenderingRulesStorage(storage);
isNativeSupported = true; isNativeSupported = true;
@ -70,13 +75,13 @@ public class NativeOsmandLibrary extends NativeLibrary {
} }
private static void loadNewCore(final String libCpuSuffix) { private static void loadNewCore(final String libCpuSuffix) {
System.loadLibrary("Qt5Core" + libCpuSuffix); // System.loadLibrary("Qt5Core" + libCpuSuffix);
System.loadLibrary("Qt5Network" + libCpuSuffix); // System.loadLibrary("Qt5Network" + libCpuSuffix);
System.loadLibrary("Qt5Concurrent" + libCpuSuffix); // System.loadLibrary("Qt5Concurrent" + libCpuSuffix);
System.loadLibrary("Qt5Sql" + libCpuSuffix); // System.loadLibrary("Qt5Sql" + libCpuSuffix);
System.loadLibrary("Qt5Xml" + libCpuSuffix); // System.loadLibrary("Qt5Xml" + libCpuSuffix);
System.loadLibrary("OsmAndCore" + libCpuSuffix); // System.loadLibrary("OsmAndCore" + libCpuSuffix);
System.loadLibrary("OsmAndCoreUtils" + libCpuSuffix); // System.loadLibrary("OsmAndCoreUtils" + libCpuSuffix);
System.loadLibrary("OsmAndJNI" + libCpuSuffix); System.loadLibrary("OsmAndJNI" + libCpuSuffix);
} }
@ -103,7 +108,7 @@ public class NativeOsmandLibrary extends NativeLibrary {
public RenderingGenerationResult generateRendering(RenderingContext rc, NativeSearchResult searchResultHandler, public RenderingGenerationResult generateRendering(RenderingContext rc, NativeSearchResult searchResultHandler,
Bitmap bitmap, boolean isTransparent, RenderingRuleSearchRequest render) { Bitmap bitmap, boolean isTransparent, RenderingRuleSearchRequest render) {
if (searchResultHandler == null) { if (searchResultHandler == null) {
log.error("Error searchresult = null"); //$NON-NLS-1$ log.error("Error search result = null"); //$NON-NLS-1$
return new RenderingGenerationResult(null); return new RenderingGenerationResult(null);
} }