Ad

Android Replace System/lib/lib.so Does Not Work

- 1 answer

I want to replace a system library by one where I made some small changes. Both libraries were compiled with the same version of cyanogenmod source. The one I copied to the sdcard worked on an earlier flash of CM.

Now I try to run the following:

$ adb shell
[email protected]:/ $ su 
[email protected]:/ # mount -o rw,remount /system
[email protected]:/ # chmod 777 /system/lib/libwilhelm.so
[email protected]:/ # cp /sdcard/libwilhelm.so /system/lib/libwilhelm.so
[email protected]:/ # chmod 644 /system/lib/libwilhelm.so
[email protected]:/ # mount -o ro,remount /system
[email protected]:/ # reboot

However even after reboot the old libwilhelm.so is used

I know this because I log something in the not-overriden version in frameworks/wilhelm/src/sl_entry.c:

#include <android/log.h>
 #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "frameworks/wilhelm/src/sl_entry.c", __VA_ARGS__))

// ...

SL_API SLresult SLAPIENTRY slCreateEngine(SLObjectItf *pEngine, SLuint32 numOptions,
    const SLEngineOption *pEngineOptions, SLuint32 numInterfaces,
    const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
{ 


    LOGI("qqqqqqqqqqqqqqqqqqqq in slCreateEngine");

 //... continue original code

This log is then different in the other library that is on the sdcard. So the logcat should display something else once I replaced the library and rebooted but it still prints the original log message.

Also the library doesn't seem to be read from another location:

[email protected]:/ # find . -name "libwilhelm*"
./mnt/shell/emulated/0/libwilhelm.so
./system/lib/libwilhelm.so
find: ./proc/1897/task/2088/fd/49: No such file or directory
find: ./proc/1897/task/2088/fd/57: No such file or directory
find: ./proc/1897/task/2100/fd/42: No such file or directory
find: ./proc/2466/task/2471/fd/88: No such file or directory
find: ./proc/2466/task/2741/fd/85: No such file or directory
find: ./proc/2466/task/2741/fd/95: No such file or directory
./data/media/0/libwilhelm.so

What did I miss?

Ad

Answer

Turns out frameworks/wilhelm/src/sl_entry.c is not part of the libwilhelm.so but the libOpenSLES.so

Moreover it is safer to replace the library by an updater-script that can be executed from a recovery program like TWRP. The script could look like:

ui_print("mounting /system");
mount("ext4", "EMMC", "/dev/block/mmcblk0p9", "/system");
ui_print("/system now mounted");
ui_print("adding new shared library libOpenSLES.so");
package_extract_file("libOpenSLES.so", "/system/lib/libOpenSLES.so");
ui_print("done adding new shared library libOpenSLES.so");
ui_print("unmounting /system");
unmount("/system");
ui_print("/system now unmounted");
ui_print("finished");
Ad
source: stackoverflow.com
Ad