Use "sp" in Android NDK

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) {
        // TODO this will be implemented by me
        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.

+4
1

sp<> Android. sp<> - , wp<> - ; IPC Binder.

- RefBase.h, ++. , , API, NDK, , , , , , .

+6

All Articles