Commit baacbe2b authored by Thomas Guillem's avatar Thomas Guillem

LibVLC: link with true compat lib for old devices (SDK 7 & 8)

Build the true libcompat.7.so and copy it into assets folder.
On first run, the lib will be copied from the assets to the data dir.
This lib will be linked instead of the dummy one.
parent ca3fcde3
......@@ -676,6 +676,17 @@ $ANDROID_NDK/ndk-build -C libvlc \
checkfail "ndk-build failed"
if [ "${ANDROID_API}" = "android-9" ] && [ "${ANDROID_ABI}" = "armeabi-v7a" -o "${ANDROID_ABI}" = "armeabi" ] ; then
$ANDROID_NDK/ndk-build -C libvlc \
APP_BUILD_SCRIPT=libcompat/Android.mk \
APP_PLATFORM=${ANDROID_API} \
APP_ABI="armeabi" \
NDK_PROJECT_PATH=libcompat \
NDK_TOOLCHAIN_VERSION=${GCCVER} \
NDK_DEBUG=${NDK_DEBUG}
checkfail "ndk-build compat failed"
fi
DBG_LIB_DIR=libvlc/jni/obj/local/${ANDROID_ABI}
OUT_LIB_DIR=libvlc/jni/libs/${ANDROID_ABI}
VERSION=$(grep "android:versionName" vlc-android/AndroidManifest.xml|cut -d\" -f 2)
......
......@@ -14,7 +14,7 @@ android {
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
assets.srcDirs = ['assets', 'libcompat/libs/armeabi']
}
}
......
......@@ -22,6 +22,7 @@ package org.videolan.vlc.util;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;
import org.videolan.libvlc.LibVLC;
......@@ -31,11 +32,59 @@ import org.videolan.vlc.VLCCrashHandler;
import org.videolan.vlc.gui.CompatErrorActivity;
import org.videolan.vlc.gui.NativeCrashActivity;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class VLCInstance {
public final static String TAG = "VLC/UiTools/VLCInstance";
private static LibVLC sLibVLC = null;
public static void linkCompatLib(Context context) {
final File outDir = new File(context.getFilesDir(), "compat");
if (!outDir.exists())
outDir.mkdir();
final File outFile = new File(outDir, "libcompat.7.so");
/* The file may had been already copied from the asset, try to load it */
if (outFile.exists()) {
try {
System.load(outFile.getPath());
return;
} catch (UnsatisfiedLinkError ule) {
/* the file can be invalid, try to copy it again */
}
}
/* copy libcompat.7.so from assert to a data dir */
InputStream is = null;
FileOutputStream fos = null;
boolean success = false;
try {
is = VLCApplication.getAppResources().getAssets().open("libcompat.7.so");
fos = new FileOutputStream(outFile);
final byte[] buffer = new byte[16*1024];
int read;
while ((read = is.read(buffer)) != -1)
fos.write(buffer, 0, read);
success = true;
} catch (IOException e) {
} finally {
Util.close(is);
Util.close(fos);
}
/* load the lib coming from the asset */
if (success) {
try {
System.load(outFile.getPath());
} catch (UnsatisfiedLinkError ule) {
}
}
}
/** A set of utility functions for the VLC application */
public synchronized static LibVLC get() throws IllegalStateException {
if (sLibVLC == null) {
......@@ -46,6 +95,10 @@ public class VLCInstance {
Log.e(TAG, VLCUtil.getErrorMsg());
throw new IllegalStateException("LibVLC initialisation failed: " + VLCUtil.getErrorMsg());
}
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.FROYO) {
Log.w(TAG, "linking with true compat lib...");
linkCompatLib(context);
}
sLibVLC = new LibVLC(VLCOptions.getLibOptions());
LibVLC.setOnNativeCrashListener(new LibVLC.OnNativeCrashListener() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment