forked from cory/tildefriends
Fix some issues with multiple supported android architectures.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4554 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -8,8 +8,8 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.StrictMode;
|
||||
import android.os.strictmode.Violation;
|
||||
import android.os.SystemClock;
|
||||
import android.os.strictmode.Violation;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
@ -27,6 +27,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStream;
|
||||
import java.lang.Process;
|
||||
import java.lang.Thread;
|
||||
import java.nio.file.FileSystems;
|
||||
@ -37,7 +38,7 @@ import java.nio.file.WatchKey;
|
||||
import java.nio.file.WatchService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
WebView web_view;
|
||||
@ -195,27 +196,25 @@ public class MainActivity extends Activity {
|
||||
|
||||
private boolean extract_executable()
|
||||
{
|
||||
try (ZipInputStream zip = new ZipInputStream(new BufferedInputStream(new FileInputStream(getPackageResourcePath().toString())))) {
|
||||
ZipEntry entry = null;
|
||||
try (ZipFile zip = new ZipFile(new File(getPackageResourcePath()))) {
|
||||
for (String abi : android.os.Build.SUPPORTED_ABIS)
|
||||
{
|
||||
String lookup = String.format("bin/%s/tildefriends", abi);
|
||||
Log.w("tildefriends", "Looking for " + lookup);
|
||||
while ((entry = zip.getNextEntry()) != null) {
|
||||
if (entry.getName().equals(lookup)) {
|
||||
Log.w("tildefriends", "Extracting " + entry.getName());
|
||||
try (FileOutputStream out = new FileOutputStream(getFilesDir().toString().concat("/tildefriends"))) {
|
||||
ZipEntry entry = zip.getEntry(lookup);
|
||||
if (entry != null) {
|
||||
Log.w("tildefriends", "Extracting " + entry.getName());
|
||||
try (FileOutputStream out = new FileOutputStream(getFilesDir().toString() + "/tildefriends")) {
|
||||
try (InputStream in = zip.getInputStream(entry)) {
|
||||
byte[] buffer = new byte[32768];
|
||||
int count;
|
||||
while ((count = zip.read(buffer)) != -1) {
|
||||
while ((count = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, count);
|
||||
}
|
||||
out.close();
|
||||
new File(getFilesDir().toString() + "/tildefriends").setExecutable(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
zip.closeEntry();
|
||||
}
|
||||
}
|
||||
} catch (java.io.FileNotFoundException e) {
|
||||
|
Reference in New Issue
Block a user