I make an app that installed in Android system, my app using native libraries, I try this code to load native libraries :
//Load Libffmpeg
try {
if (new File("/data/data/"+ packageName +"/lib/"+ "libffmpeg-linphone-" + ffmpegAbi+".so").exists()) {
System.load("/data/data/"+ packageName +"/lib/"+ "libffmpeg-linphone-" + ffmpegAbi+".so");
}else if(new File("/system/lib/"+ "libffmpeg-linphone-" + ffmpegAbi+".so").exists()){
System.load("/system/lib/"+ "libffmpeg-linphone-" + ffmpegAbi+".so");
} else if(new File("/system/app/"+ packageName +"/lib/"+ "libffmpeg-linphone-" + ffmpegAbi+".so").exists()){
System.load("/system/app/"+ packageName +"/lib/"+ "libffmpeg-linphone-" + ffmpegAbi+".so");
}else {
System.loadLibrary("ffmpeg-linphone-" + ffmpegAbi);
}
} catch (Throwable e) {
Log.w("LinphoneCoreFactoryImpl", "Unable to load optional library lib" + "ffmpeg-linphone-" + ffmpegAbi);
}
//Load Main Library
try {
if (new File("/data/data/"+ packageName +"/lib/"+ "linphone-" + abi+".so").exists()) {
System.load("/data/data/"+ packageName +"/lib/"+ "linphone-" + abi+".so");
}else if(new File("/system/lib/"+ "linphone-" + abi+".so").exists()){
System.load("/system/lib/"+ "linphone-" + abi+".so");
} else if(new File("/system/app/"+ packageName +"/lib/"+ "linphone-" + abi+".so").exists()){
System.load("/system/app/"+ packageName +"/lib/"+ "linphone-" + abi+".so");
}else {
System.loadLibrary("linphone-" + abi);
}
Log.i("LinphoneCoreFactoryImpl", "Loading done with " + abi);
libLoaded=true;
break;
}catch(Throwable e) {
if (firstException == null) firstException=e;
}
at first this error was appeared :
java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: dlopen failed: couldn't map "/system/lib/liblinphone-armeabi-v7a.so" segment 2: Permission denied
after that I try to put this code :
try {
process = Runtime.getRuntime().exec("su");
dataOutputStream = new DataOutputStream(process.getOutputStream());
dataOutputStream.writeBytes("chmod 644 /system/lib/\n");
dataOutputStream.writeBytes("exit\n");
dataOutputStream.flush();
process.waitFor();
} catch (Exception e) {
} finally {
try {
if (dataOutputStream != null) {
dataOutputStream.close();
}
process.destroy();
} catch (Exception e) {
}
}
but the same error appeared again, is that impossible to make system/lib accesible by android app in system or my code is wrong ?