forked from cory/tildefriends
Steps toward following all the inconvenient, changing android rules:
* Set android:debuggable=false. * Call native code through JNI only. Having a native executable on disk and exec-ing it no longer seems possible. * Do all the Tilde Friends things in one process, without a proper sandbox, until I can wire up a restricted service worker process. * Jam Android App Bundle (.aab) building into the makefile. * Yuck.
This commit is contained in:
@ -1,15 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.unprompted.tildefriends"
|
||||
android:versionCode="21"
|
||||
android:versionCode="22"
|
||||
android:versionName="0.0.21-wip">
|
||||
<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"
|
||||
android:extractNativeLibs="true">
|
||||
android:debuggable="false">
|
||||
<meta-data android:name="android.max_aspect" android:value="2.1"/>
|
||||
<activity
|
||||
android:name=".TildeFriendsActivity"
|
||||
|
5
src/android/BundleConfig.json
Normal file
5
src/android/BundleConfig.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"optimizations" : {
|
||||
"uncompress_native_libraries" : {}
|
||||
}
|
||||
}
|
@ -53,13 +53,23 @@ import java.util.concurrent.TimeUnit;
|
||||
public class TildeFriendsActivity extends Activity {
|
||||
TildeFriendsWebView web_view;
|
||||
String base_url;
|
||||
String port_file_path;
|
||||
Process process;
|
||||
Thread thread;
|
||||
Thread server_thread;
|
||||
|
||||
private ValueCallback<Uri[]> upload_message;
|
||||
private final static int FILECHOOSER_RESULT = 1;
|
||||
private float touch_down_y;
|
||||
|
||||
static {
|
||||
Log.w("tildefriends", "Calling system.loadLibrary().");
|
||||
System.loadLibrary("tildefriends");
|
||||
Log.w("tildefriends", "system.loadLibrary() completed.");
|
||||
}
|
||||
|
||||
static native int tf_server_main(String files_dir, String apk_path, String out_port_file_path);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
|
||||
@ -76,7 +86,7 @@ public class TildeFriendsActivity extends Activity {
|
||||
Log.w("tildefriends", String.format("getPackageResourcePath() is %s", getPackageResourcePath().toString()));
|
||||
Log.w("tildefriends", String.format("nativeLibraryDir is %s", getApplicationInfo().nativeLibraryDir));
|
||||
|
||||
String port_file_path = getFilesDir().toString() + "/port.txt";
|
||||
port_file_path = getFilesDir().toString() + "/port.txt";
|
||||
new File(port_file_path).delete();
|
||||
base_url = "http://127.0.0.1:12345/";
|
||||
|
||||
@ -134,17 +144,15 @@ public class TildeFriendsActivity extends Activity {
|
||||
thread.start();
|
||||
|
||||
set_status("Starting server...");
|
||||
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);
|
||||
builder.directory(getFilesDir());
|
||||
builder.inheritIO();
|
||||
try {
|
||||
process = builder.start();
|
||||
} catch (java.io.IOException e) {
|
||||
Log.w("tildefriends", "IOException starting process: " + e.toString());
|
||||
}
|
||||
server_thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.w("tildefriends", "Calling tf_server_main.");
|
||||
int result = tf_server_main(getFilesDir().toString(), getPackageResourcePath().toString(), port_file_path);
|
||||
Log.w("tildefriends", "tf_server_main returned " + result + ".");
|
||||
}
|
||||
});
|
||||
server_thread.start();
|
||||
|
||||
web_view.getSettings().setJavaScriptEnabled(true);
|
||||
web_view.getSettings().setDatabaseEnabled(true);
|
||||
|
Reference in New Issue
Block a user