SDL: renamed libcrypto and libssl to avoid clashing with system libraries, fixed crashes in SD card Java code
This commit is contained in:
@@ -32,6 +32,7 @@ class Globals
|
||||
public static String ApplicationName = "CommanderGenius";
|
||||
public static String AppLibraries[] = { "sdl-1.2", };
|
||||
public static String AppMainLibraries[] = { "application", "sdl_main" };
|
||||
public static String LibraryNamesMap[][] = { { "crypto", "crypto.so.sdl.0" }, { "ssl", "ssl.so.sdl.0" }, { "curl", "curl-sdl" } }; // Because some libraries are named differently to not clash with system libs
|
||||
public static final boolean Using_SDL_1_3 = false;
|
||||
public static final boolean Using_SDL_2_0 = false;
|
||||
public static String[] DataDownloadUrl = { "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download", "High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download" };
|
||||
|
||||
@@ -1241,8 +1241,9 @@ public class MainActivity extends Activity
|
||||
// Load all libraries
|
||||
try
|
||||
{
|
||||
for(String l : Globals.AppLibraries)
|
||||
for(String l_unmapped : Globals.AppLibraries)
|
||||
{
|
||||
String l = GetMappedLibraryName(l_unmapped);
|
||||
try
|
||||
{
|
||||
String libname = System.mapLibraryName(l);
|
||||
@@ -1342,8 +1343,9 @@ public class MainActivity extends Activity
|
||||
out.close();
|
||||
}
|
||||
|
||||
for(String l : Globals.AppLibraries)
|
||||
for(String l_unmapped : Globals.AppLibraries)
|
||||
{
|
||||
String l = GetMappedLibraryName(l_unmapped);
|
||||
String libname = System.mapLibraryName(l);
|
||||
File libpath = new File(libDir, libname);
|
||||
Log.i("SDL", "libSDL: loading lib " + libpath.getPath());
|
||||
@@ -1467,10 +1469,20 @@ public class MainActivity extends Activity
|
||||
}
|
||||
};
|
||||
|
||||
public static String GetMappedLibraryName(final String s)
|
||||
{
|
||||
for (int i = 0; i < Globals.LibraryNamesMap.length; i++)
|
||||
{
|
||||
if( Globals.LibraryNamesMap[i][0].equals(s) )
|
||||
return Globals.LibraryNamesMap[i][1];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static void LoadApplicationLibrary(final Context context)
|
||||
{
|
||||
Settings.nativeChdir(Globals.DataDir);
|
||||
for(String l : Globals.AppMainLibraries)
|
||||
for(String l: Globals.AppMainLibraries)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -773,6 +773,12 @@ class Settings
|
||||
@Override
|
||||
public String path(final Context p)
|
||||
{
|
||||
if( p.getExternalFilesDir(null) == null )
|
||||
{
|
||||
if( Environment.getExternalStorageDirectory() == null )
|
||||
return "/sdcard/Android/data/" + p.getPackageName() + "/files";
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + p.getPackageName() + "/files";
|
||||
}
|
||||
return p.getExternalFilesDir(null).getAbsolutePath();
|
||||
}
|
||||
@Override
|
||||
@@ -807,8 +813,11 @@ class Settings
|
||||
{
|
||||
if( path == null )
|
||||
continue;
|
||||
StatFs stat = new StatFs(path.getPath());
|
||||
long size = (long)stat.getAvailableBlocks() * stat.getBlockSize() / 1024 / 1024;
|
||||
long size = -1;
|
||||
try {
|
||||
StatFs stat = new StatFs(path.getPath());
|
||||
size = (long)stat.getAvailableBlocks() * stat.getBlockSize() / 1024 / 1024;
|
||||
} catch (Exception ee) {} // Can throw an exception if we cannot read from SD card
|
||||
|
||||
try {
|
||||
path.mkdirs();
|
||||
|
||||
@@ -91,10 +91,10 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
long freePhone = 0;
|
||||
try
|
||||
{
|
||||
StatFs sdcard = new StatFs(Settings.SdcardAppPath.get().bestPath(p));
|
||||
StatFs phone = new StatFs(p.getFilesDir().getAbsolutePath());
|
||||
freeSdcard = (long)sdcard.getAvailableBlocks() * sdcard.getBlockSize() / 1024 / 1024;
|
||||
freePhone = (long)phone.getAvailableBlocks() * phone.getBlockSize() / 1024 / 1024;
|
||||
StatFs sdcard = new StatFs(Settings.SdcardAppPath.get().bestPath(p));
|
||||
freeSdcard = (long)sdcard.getAvailableBlocks() * sdcard.getBlockSize() / 1024 / 1024;
|
||||
}
|
||||
catch(Exception e) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user