| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef ANDROID_OS_HW_REMOTE_BINDER_H |
| 18 |
#define ANDROID_OS_HW_REMOTE_BINDER_H |
| 19 |
|
| 20 |
#include <android-base/macros.h> |
| 21 |
#include <hwbinder/Binder.h> |
| 22 |
#include <jni.h> |
| 23 |
#include <utils/Mutex.h> |
| 24 |
#include <utils/RefBase.h> |
| 25 |
#include <vector> |
| 26 |
|
| 27 |
namespace android { |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
class HwBinderDeathRecipient; |
| 34 |
|
| 35 |
class HwBinderDeathRecipientList : public RefBase { |
| 36 |
std::vector<sp<HwBinderDeathRecipient>> mList; |
| 37 |
Mutex mLock; |
| 38 |
|
| 39 |
protected: |
| 40 |
~HwBinderDeathRecipientList() override; |
| 41 |
|
| 42 |
public: |
| 43 |
explicit HwBinderDeathRecipientList(); |
| 44 |
|
| 45 |
DISALLOW_COPY_AND_ASSIGN(HwBinderDeathRecipientList); |
| 46 |
|
| 47 |
void add(const sp<HwBinderDeathRecipient>& recipient); |
| 48 |
void remove(const sp<HwBinderDeathRecipient>& recipient); |
| 49 |
|
| 50 |
|
| 51 |
sp<HwBinderDeathRecipient> find(jobject recipient); |
| 52 |
|
| 53 |
Mutex& lock(); |
| 54 |
}; |
| 55 |
|
| 56 |
struct JHwRemoteBinder : public RefBase { |
| 57 |
static void InitClass(JNIEnv *env); |
| 58 |
|
| 59 |
static sp<JHwRemoteBinder> SetNativeContext( |
| 60 |
JNIEnv *env, jobject thiz, const sp<JHwRemoteBinder> &context); |
| 61 |
|
| 62 |
static sp<JHwRemoteBinder> GetNativeContext(JNIEnv *env, jobject thiz); |
| 63 |
|
| 64 |
static jobject NewObject(JNIEnv *env, const sp<hardware::IBinder> &binder); |
| 65 |
|
| 66 |
JHwRemoteBinder( |
| 67 |
JNIEnv *env, jobject thiz, const sp<hardware::IBinder> &binder); |
| 68 |
|
| 69 |
sp<hardware::IBinder> getBinder() const; |
| 70 |
void setBinder(const sp<hardware::IBinder> &binder); |
| 71 |
sp<HwBinderDeathRecipientList> getDeathRecipientList() const; |
| 72 |
|
| 73 |
private: |
| 74 |
sp<hardware::IBinder> mBinder; |
| 75 |
sp<HwBinderDeathRecipientList> mDeathRecipientList; |
| 76 |
DISALLOW_COPY_AND_ASSIGN(JHwRemoteBinder); |
| 77 |
}; |
| 78 |
|
| 79 |
int register_android_os_HwRemoteBinder(JNIEnv *env); |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
#endif |
| 84 |
|