From: Marcus Comstedt Date: Sun, 6 Jul 2014 15:24:30 +0000 (+0200) Subject: sigrok-cross-android: Use Java glue for PV from github X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3c45ba19ab7f102be9ca217a3b9288cfd908df37;p=sigrok-util.git sigrok-cross-android: Use Java glue for PV from github --- diff --git a/cross-compile/android/pulseview-java.patch b/cross-compile/android/pulseview-java.patch deleted file mode 100644 index 6d7d04f..0000000 --- a/cross-compile/android/pulseview-java.patch +++ /dev/null @@ -1,181 +0,0 @@ -diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml -index 0564a8d..0356f33 100644 ---- a/java/AndroidManifest.xml -+++ b/java/AndroidManifest.xml -@@ -1,5 +1,5 @@ - -- -- -+ -+ - - - -- -+ - - - - - -- -+ - - - -- -+ - -- -- -- -+ -+ -+ - - - -diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml -index bd6928f..68f017e 100644 ---- a/java/res/values/strings.xml -+++ b/java/res/values/strings.xml -@@ -1,6 +1,6 @@ - - -- -+ PulseView - - Can\'t find Ministro service.\nThe application can\'t start. - This application requires Ministro service. Would you like to install it? -diff --git a/java/res/values/libs.xml b/java/res/values/libs.xml ---- a/java/res/values/libs.xml 2014-05-17 11:09:29.855631921 +0200 -+++ b/java/res/values/libs.xml 2014-05-17 11:13:04.380841784 +0200 -@@ -13,6 +13,10 @@ - - - -+ Qt5Core -+ Qt5Gui -+ Qt5Widgets -+ Qt5Svg - - - -diff --git a/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/java/src/org/qtproject/qt5/android/bindings/QtActivity.java -index 4ebf1f6..f4e3598 100644 ---- a/java/src/org/qtproject/qt5/android/bindings/QtActivity.java -+++ b/java/src/org/qtproject/qt5/android/bindings/QtActivity.java -@@ -187,6 +187,14 @@ - private void loadApplication(Bundle loaderParams) - { - try { -+ org.sigrok.androidutils.Environment.initEnvironment( -+ getApplicationInfo().sourceDir); -+ System.loadLibrary("gnustl_shared"); -+ org.sigrok.androidutils.LibWrangler.setupLibs( -+ getAssets().open("liblist.txt"), -+ new File(getApplicationInfo().nativeLibraryDir), -+ new File(getFilesDir(), "lib")); -+ - final int errorCode = loaderParams.getInt(ERROR_CODE_KEY); - if (errorCode != 0) { - if (errorCode == INCOMPATIBLE_MINISTRO_VERSION) { -diff --git a/java/src/org/sigrok/androidutils/LibWrangler.java b/java/src/org/sigrok/androidutils/LibWrangler.java -new file mode 100644 -index 0000000..0c9effe ---- /dev/null -+++ b/java/src/org/sigrok/androidutils/LibWrangler.java -@@ -0,0 +1,63 @@ -+package org.sigrok.androidutils; -+ -+import java.io.InputStream; -+import java.io.InputStreamReader; -+import java.io.BufferedReader; -+import java.io.IOException; -+import java.io.File; -+ -+public final class LibWrangler -+{ -+ protected static String stripSoVersion(String s) -+ { -+ int p = s.lastIndexOf(".so."); -+ if (p >= 0) -+ s = s.substring(0, p+3); -+ return s; -+ } -+ -+ protected static void makeLink(File from, File to) -+ throws IOException -+ { -+ if (to.equals(from.getCanonicalFile())) { -+ // Symlink already correct -+ return; -+ } -+ from.delete(); -+ int rc; -+ Process proc = -+ Runtime.getRuntime().exec(new String[]{"ln", "-s", -+ to.getAbsolutePath(), -+ from.getAbsolutePath()}); -+ for(;;) { -+ try { -+ rc = proc.waitFor(); -+ break; -+ } catch(InterruptedException ie) { -+ } -+ } -+ if (rc != 0) -+ throw new IOException("Failed to create symlink "+from); -+ } -+ -+ public static void setupLibs(BufferedReader reader, File libDir1, File libDir2) -+ throws IOException -+ { -+ if (!libDir2.exists()) -+ libDir2.mkdir(); -+ -+ String libname; -+ while ((libname = reader.readLine()) != null) { -+ File shlib = new File(libDir2, libname); -+ makeLink(shlib, new File(libDir1, stripSoVersion(libname))); -+ System.load(shlib.getAbsolutePath()); -+ } -+ } -+ -+ public static void setupLibs(InputStream is, File libDir1, File libDir2) -+ throws IOException -+ { -+ setupLibs(new BufferedReader(new InputStreamReader(is, "US-ASCII")), -+ libDir1, libDir2); -+ } -+} -diff --git a/java/src/org/sigrok/androidutils/Environment.java b/java/src/org/sigrok/androidutils/Environment.java -new file mode 100644 -index 0000000..0c9effe ---- /dev/null 2014-04-15 00:13:35.543030287 +0200 -+++ b/java/src/org/sigrok/androidutils/Environment.java 2014-04-27 00:09:23.073513663 +0200 -@@ -0,0 +1,21 @@ -+package org.sigrok.androidutils; -+ -+public final class Environment -+{ -+ static private String[] environment; -+ -+ public static String[] getEnvironment() -+ { -+ return environment; -+ } -+ -+ public static void initEnvironment(String apkFile) -+ { -+ environment = new String[] -+ { -+ "PYTHONHOME", ".", -+ "PYTHONPATH", apkFile+"/assets/python3.3", -+ "SIGROKDECODE_DIR", apkFile+"/assets/libsigrokdecode/decoders", -+ }; -+ } -+} diff --git a/cross-compile/android/sigrok-cross-android b/cross-compile/android/sigrok-cross-android index f270f14..95dffb3 100755 --- a/cross-compile/android/sigrok-cross-android +++ b/cross-compile/android/sigrok-cross-android @@ -318,12 +318,11 @@ cd pulseview patch -p1 < ../../pulseview-cpp.patch cmake $CM -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl . make $PARALLEL -cp -r "$PREFIX"/src/android/java . +git clone https://github.com/zeldin/pulseview_android_java java cp -r libs java/ mkdir -p java/res/drawable cp icons/sigrok-logo-notext.png java/res/drawable/logo.png cd java -patch -p2 < ../../../pulseview-java.patch cp "$PREFIX"/jar/QtAndroid-bundled.jar libs/ cp "$PREFIX"/jar/QtAndroidAccessibility-bundled.jar libs/ mkdir -p assets