I am trying to intercept some native library calls through LD_PRELOAD.
This works fine for simple libraries written in C, but now I'm trying to go further and override some more complex class methods from AOSP written in C ++.
Here is my example:
#include <rs/cpp/util/RefBase.h>
namespace android {
sp<MediaCodec> MediaCodec::CreateByType(const sp<ALooper> &looper, const char *mime, bool encoder) {
return NULL;
}
}
In my Application.mk, I got the following code snippet:
APP_STL := gnustl_static
and inside Android.mk:
LOCAL_STATIC_LIBRARIES += libstlport_static
Unfortunately, the error I get is the following:
jni / libhook / ld_preload.cpp: 88: 1: error: 'sp' does not name type
Does anyone know how to use sp <..> here? I assume that this is not Android-specific, but standard C ++ - the thing is that I am completely new in C ++, I just started today :)
I know this can be bad practice, so I welcome any other idea.