DroidFish: Use a prebuilt stockfish engine for Android 1.5, because the version built by the NDK fails to start.

This commit is contained in:
Peter Osterlund 2012-01-15 01:43:08 +00:00
parent ca1482a80a
commit 97ff270ee5
3 changed files with 6 additions and 1 deletions
DroidFish
assets
src/org/petero/droidfish/engine

BIN
DroidFish/assets/stockfish15.mygz Executable file

Binary file not shown.

@ -37,7 +37,7 @@ public class EngineUtil {
public static String internalStockFishName() { public static String internalStockFishName() {
final int sdkVersion = Integer.parseInt(Build.VERSION.SDK); final int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
if (sdkVersion < 4) if (sdkVersion < 4)
return null; return "stockfish15.mygz";
return "stockfish-" + CpuAbi.get(); return "stockfish-" + CpuAbi.get();
} }
} }

@ -28,6 +28,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.zip.GZIPInputStream;
import android.content.Context; import android.content.Context;
@ -73,6 +74,8 @@ public class InternalStockFish extends ExternalEngine {
InputStream is = null; InputStream is = null;
try { try {
is = context.getAssets().open(sfExe); is = context.getAssets().open(sfExe);
if (sfExe.endsWith(".mygz"))
is = new GZIPInputStream(is);
MessageDigest md = MessageDigest.getInstance("SHA-1"); MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] buf = new byte[8192]; byte[] buf = new byte[8192];
while (true) { while (true) {
@ -112,6 +115,8 @@ public class InternalStockFish extends ExternalEngine {
to.createNewFile(); to.createNewFile();
InputStream is = context.getAssets().open(sfExe); InputStream is = context.getAssets().open(sfExe);
if (sfExe.endsWith(".mygz"))
is = new GZIPInputStream(is);
OutputStream os = new FileOutputStream(to); OutputStream os = new FileOutputStream(to);
try { try {