如何在Android的媒体服务器上使用LD_PRELOAD? [英] How to use LD_PRELOAD with Android's mediaserver?

查看:87
本文介绍了如何在Android的媒体服务器上使用LD_PRELOAD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将LD_PRELOAD用于普通的本机应用程序,例如ls:

I can use LD_PRELOAD with normal native apps like e.g. ls:

LD_PRELOAD=/path/to/my/library.so ls

经过一些搜索,我还可以通过设置以下属性将其与java应用程序一起使用:

After some searching I was also able to use it with java apps by setting such property:

adb shell setprop wrap.com.some.app LD_PRELOAD=/path/to/my/library.so

但是我对在 mediaserver 进程中使用LD_PRELOAD感兴趣.这很棘手,因为它始终在后台运行.如果您杀死它,它将自动重新启动.我可以使用以下命令启动第二个实例":

However I'm interested in using LD_PRELOAD with mediaserver process. This is tricky because it constantly works in the background. If you kill it, it will be started again automatically. I can start "second instance" with:

LD_PRELOAD=/path/to/my/library.so /system/bin/mediaserver

,它会加载我的媒体库,尽管在任何播放中都不会使用第二实例".始终由原始媒体服务器处理媒体操作.那么,有什么方法可以在媒体服务器上不修改设备上的init.rc文件的情况下对媒体服务器使用LD_PRELOAD吗?

and it will load my library although "second instance" won't be used in any playback. Always original mediaserver will handle media operations. So is there any way to use LD_PRELOAD with mediaserver without modifying init.rc files on device?

推荐答案

事实证明,有一种方法可以做到这一点.我必须做以下事情:

It turned out that there is a way to do that. I had to do following things:

adb root
adb remount
adb pull /system/bin/mediaserver
echo "LD_PRELOAD=/path/to/my/library.so /system/bin/mediaserver_orig" > mediaserver
adb shell mv /system/bin/mediaserver /system/bin/mediaserver_orig
adb push mediaserver /system/bin/mediaserver

然后我杀死了mediaserver,它(不是令人惊讶地)不是自动启动的,所以我还必须手动启动它:

Then I have killed mediaserver, which (surprisingly) wasn't started automatically, so I also had to start it by hand:

adb shell
/system/bin/mediaserver &

无论如何,都可以这样做,所以如果没有人有更好的选择,我会接受我的回答.

Anyway it is possible to do that, so I will accept my answer if nobody has anything better.

只有一个警告-当我通过以下方式返回到先前的状态时:

Just one warning - when I have returned to previous state with:

adb shell mv /system/bin/mediaserver_orig /system/bin/mediaserver

并重新启动设备,mediaserver仍未自动启动!因此,这不是您要在您关心的设备上执行的操作,因为在这种状态下,如果您不手动启动媒体服务器,则设备将无法完成启动.尽管这种现象可能是由于我在玩chown而发生的,但无论如何,都可能会与所描述的过程无关.

and rebooted device, mediaserver was still not started automatically! So this is not something you would like to do on device you care about because in such state if you don't start mediaserver by hand boot will not be completed by device. Although this phenomenon could have happen because I was playing with chown, so may be not related to described procedure, anyway you have been warned.

这篇关于如何在Android的媒体服务器上使用LD_PRELOAD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆