diff --git a/Makefile b/Makefile index 4048918b8..97fec3cf8 100644 --- a/Makefile +++ b/Makefile @@ -656,15 +656,15 @@ out/apk/TildeFriends-debug.unsigned.apk: out/apk/classes.dex out/androiddebug/ti out/apk/TildeFriends-release.unsigned.apk: out/apk/classes.dex out/androidrelease/tildefriends out/androidrelease-x86_64/tildefriends out/androidrelease-x86/tildefriends out/androidrelease-armv7a/tildefriends $(RAW_FILES) out/apk/res.apk out/%.unsigned.apk: - @mkdir -p $(dir $@) out/apk$(BUILD_TYPE)/bin/arm64-v8a/ out/apk$(BUILD_TYPE)/bin/x86_64/ out/apk$(BUILD_TYPE)/bin/i686/ out/apk$(BUILD_TYPE)/bin/armv7a/ + @mkdir -p $(dir $@) out/apk$(BUILD_TYPE)/bin/arm64-v8a/ out/apk$(BUILD_TYPE)/bin/x86_64/ out/apk$(BUILD_TYPE)/bin/i686/ out/apk$(BUILD_TYPE)/bin/armeabi-v7a/ @echo [aapt] $@ @cp out/android$(BUILD_TYPE)/tildefriends out/apk$(BUILD_TYPE)/bin/arm64-v8a/ @cp out/android$(BUILD_TYPE)-x86_64/tildefriends out/apk$(BUILD_TYPE)/bin/x86_64/ #@cp out/android$(BUILD_TYPE)-x86/tildefriends out/apk$(BUILD_TYPE)/bin/i686/ - #@cp out/android$(BUILD_TYPE)-armv7a/tildefriends out/apk$(BUILD_TYPE)/bin/armv7a/ + #@cp out/android$(BUILD_TYPE)-armv7a/tildefriends out/apk$(BUILD_TYPE)/bin/armeabi-v7a/ @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/bin/arm64-v8a/tildefriends - #@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/bin/armv7a/tildefriends @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/bin/x86_64/tildefriends + #@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/bin/armeabi-v7a/tildefriends #@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/bin/i686/tildefriends @cp out/apk/res.apk $@ @cp out/apk/classes.dex out/apk$(BUILD_TYPE)/ diff --git a/src/android/com/unprompted/tildefriends/MainActivity.java b/src/android/com/unprompted/tildefriends/MainActivity.java index 370139201..0d4a02d73 100644 --- a/src/android/com/unprompted/tildefriends/MainActivity.java +++ b/src/android/com/unprompted/tildefriends/MainActivity.java @@ -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) {