Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion recipes/python/patches/custom-loader.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
+ /* Ensure we have access to libpymodules. */
+ if (libpymodules == NULL) {
+ printf("ANDROID_PRIVATE = %s\n", getenv("ANDROID_PRIVATE"));
+ PyOS_snprintf(pathbuf, sizeof(pathbuf), "%s/libpymodules.so", getenv("ANDROID_PRIVATE"));
+ PyOS_snprintf(pathbuf, sizeof(pathbuf), "%s/app/libpymodules.so", getenv("ANDROID_PRIVATE"));
+ libpymodules = dlopen(pathbuf, RTLD_NOW);
+
+ if (libpymodules == NULL) {
Expand Down
8 changes: 4 additions & 4 deletions src/jni/application/python/start.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ int main(int argc, char **argv) {
"private = posix.environ['ANDROID_PRIVATE']\n" \
"argument = posix.environ['ANDROID_ARGUMENT']\n" \
"sys.path[:] = [ \n" \
" private + '/lib/python27.zip', \n" \
" private + '/lib/python2.7/', \n" \
" private + '/lib/python2.7/lib-dynload/', \n" \
" private + '/lib/python2.7/site-packages/', \n" \
" private + '/app/lib/python27.zip', \n" \
" private + '/app/lib/python2.7/', \n" \
" private + '/app/lib/python2.7/lib-dynload/', \n" \
" private + '/app/lib/python2.7/site-packages/', \n" \
" argument ]\n" \
"import androidembed\n" \
"class LogFile(object):\n" \
Expand Down
34 changes: 23 additions & 11 deletions src/src/org/renpy/android/PythonActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected void onCreate(Bundle savedInstanceState) {
} else if (resourceManager.getString("public_version") != null) {
mPath = externalStorage;
} else {
mPath = getFilesDir();
mPath = new File(getKivyRoot());
}

requestWindowFeature(Window.FEATURE_NO_TITLE);
Expand Down Expand Up @@ -185,6 +185,14 @@ public void recursiveDelete(File f) {
}


public String getKivyRoot() {
return getFilesDir().getAbsolutePath() + "/app";
}

public String getKivyPublicRoot() {
return externalStorage.getAbsolutePath() + "/app";
}

/**
* This determines if unpacking one the zip files included in
* the .apk is necessary. If it is, the zip file is unpacked.
Expand Down Expand Up @@ -243,9 +251,12 @@ public void unpackData(final String resource, File target) {
}

public void run() {
String kivy_root = getKivyRoot();
File kivy_root_dir = new File(kivy_root);
File kivy_public_root_dir = new File(getKivyPublicRoot());

unpackData("private", getFilesDir());
unpackData("public", externalStorage);
unpackData("private", kivy_root_dir);
unpackData("public", kivy_public_root_dir);

System.loadLibrary("sdl");
System.loadLibrary("sdl_image");
Expand All @@ -255,19 +266,19 @@ public void run() {
System.loadLibrary("application");
System.loadLibrary("sdl_main");

System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_io.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/unicodedata.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_io.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/unicodedata.so");

try {
System.loadLibrary("sqlite3");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_sqlite3.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_sqlite3.so");
} catch(UnsatisfiedLinkError e) {
}

try {
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imaging.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingft.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingmath.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_imaging.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_imagingft.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_imagingmath.so");
} catch(UnsatisfiedLinkError e) {
}

Expand Down Expand Up @@ -349,10 +360,11 @@ public static void start_service(String serviceTitle, String serviceDescription,
Intent serviceIntent = new Intent(PythonActivity.mActivity, PythonService.class);
String argument = PythonActivity.mActivity.getFilesDir().getAbsolutePath();
String filesDirectory = PythonActivity.mActivity.mPath.getAbsolutePath();
String kivy_root = PythonActivity.mActivity.getKivyRoot();
serviceIntent.putExtra("androidPrivate", argument);
serviceIntent.putExtra("androidArgument", filesDirectory);
serviceIntent.putExtra("pythonHome", argument);
serviceIntent.putExtra("pythonPath", argument + ":" + filesDirectory + "/lib");
serviceIntent.putExtra("pythonHome", kivy_root);
serviceIntent.putExtra("pythonPath", kivy_root + ":" + kivy_root + "/lib");
serviceIntent.putExtra("serviceTitle", serviceTitle);
serviceIntent.putExtra("serviceDescription", serviceDescription);
serviceIntent.putExtra("pythonServiceArgument", pythonServiceArgument);
Expand Down
23 changes: 15 additions & 8 deletions src/src/org/renpy/android/PythonService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.renpy.android;

import java.io.File;

import android.app.Service;
import android.os.IBinder;
import android.os.Bundle;
Expand Down Expand Up @@ -74,8 +76,14 @@ public void onDestroy() {
Process.killProcess(Process.myPid());
}

public String getKivyRoot() {
return getFilesDir().getAbsolutePath() + "/app";
}

@Override
public void run(){
String kivy_root = getKivyRoot();
File kivy_root_dir = new File(kivy_root);

// libraries loading, the same way PythonActivity.run() do
System.loadLibrary("sdl");
Expand All @@ -86,26 +94,25 @@ public void run(){
System.loadLibrary("application");
System.loadLibrary("sdl_main");


System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_io.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/unicodedata.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_io.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/unicodedata.so");

try {
System.loadLibrary("ctypes");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_ctypes.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_ctypes.so");
} catch(UnsatisfiedLinkError e) {
}

try {
System.loadLibrary("sqlite3");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_sqlite3.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_sqlite3.so");
} catch(UnsatisfiedLinkError e) {
}

try {
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imaging.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingft.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingmath.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_imaging.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_imagingft.so");
System.load(kivy_root + "/lib/python2.7/lib-dynload/_imagingmath.so");
} catch(UnsatisfiedLinkError e) {
}

Expand Down