Put the native executable in the lib directory, to appease recent R^X requirements, and bump the Android target version back up to 34.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4572 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-10-22 18:52:20 +00:00
parent 0550aa4e98
commit 566d00f0df
4 changed files with 20 additions and 56 deletions

View File

@ -3,9 +3,13 @@
package="com.unprompted.tildefriends"
android:versionCode="12"
android:versionName="0.0.12-wip">
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="28"/>
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="34"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application android:label="Tilde Friends" android:usesCleartextTraffic="true" android:debuggable="true">
<application
android:label="Tilde Friends"
android:usesCleartextTraffic="true"
android:debuggable="true"
android:extractNativeLibs="true">
<meta-data android:name="android.max_aspect" android:value="2.1"/>
<activity
android:name=".MainActivity"

View File

@ -37,8 +37,6 @@ import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.util.concurrent.TimeUnit;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class MainActivity extends Activity {
WebView web_view;
@ -60,12 +58,7 @@ public class MainActivity extends Activity {
set_status("Extracting executable...");
Log.w("tildefriends", String.format("getFilesDir() is %s", getFilesDir().toString()));
Log.w("tildefriends", String.format("getPackageResourcePath() is %s", getPackageResourcePath().toString()));
if (!extract_executable()) {
Log.w("tildefriends", "Failed to extract a compatible executable.");
set_status("No compatible ABI found.");
return;
}
Log.w("tildefriends", String.format("nativeLibraryDir is %s", getApplicationInfo().nativeLibraryDir));
String port_file_path = getFilesDir().toString() + "/port.txt";
new File(port_file_path).delete();
@ -125,7 +118,7 @@ public class MainActivity extends Activity {
thread.start();
set_status("Starting server...");
String exe = getFilesDir().toString() + "/tildefriends";
String exe = getApplicationInfo().nativeLibraryDir + "/tildefriends.so";
ProcessBuilder builder = new ProcessBuilder(exe, "run", "-z", getPackageResourcePath().toString(), "-a", "out_http_port_file=" + port_file_path, "-p", "0");
Log.w("tildefriends", "files = " + getFilesDir().toString());
Log.w("tildefriends", "exe = " + exe);
@ -194,39 +187,6 @@ public class MainActivity extends Activity {
});
}
private boolean extract_executable()
{
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);
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 = in.read(buffer)) != -1) {
out.write(buffer, 0, count);
}
new File(getFilesDir().toString() + "/tildefriends").setExecutable(true);
return true;
}
}
}
}
} catch (java.io.FileNotFoundException e) {
Log.w("tildefriends", "FileNotFoundException extracting executable");
Log.w("tildefriends", e.toString());
} catch (java.io.IOException e) {
Log.w("tildefriends", "IOException extracting executable");
Log.w("tildefriends", e.toString());
}
return false;
}
@Override
protected void onDestroy()
{