Merge "Removes unnecessary weak reference on the java object associated with" am: 244406a4f5 am: 7c40bef8d7 am: d60c6365fa am: be1237a0b4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1404077 Change-Id: I593393e4d901c04a081aa146cef5c3e6ab0e9ae8
This commit is contained in:
@@ -269,22 +269,9 @@ jobject JHwRemoteBinder::NewObject(
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
JHwRemoteBinder::JHwRemoteBinder(
|
JHwRemoteBinder::JHwRemoteBinder(JNIEnv* env, jobject /* thiz */,
|
||||||
JNIEnv *env, jobject thiz, const sp<hardware::IBinder> &binder)
|
const sp<hardware::IBinder>& binder)
|
||||||
: mBinder(binder) {
|
: mBinder(binder), mDeathRecipientList(new HwBinderDeathRecipientList()) {}
|
||||||
mDeathRecipientList = new HwBinderDeathRecipientList();
|
|
||||||
jclass clazz = env->GetObjectClass(thiz);
|
|
||||||
CHECK(clazz != NULL);
|
|
||||||
|
|
||||||
mObject = env->NewWeakGlobalRef(thiz);
|
|
||||||
}
|
|
||||||
|
|
||||||
JHwRemoteBinder::~JHwRemoteBinder() {
|
|
||||||
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
|
||||||
|
|
||||||
env->DeleteWeakGlobalRef(mObject);
|
|
||||||
mObject = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sp<hardware::IBinder> JHwRemoteBinder::getBinder() const {
|
sp<hardware::IBinder> JHwRemoteBinder::getBinder() const {
|
||||||
return mBinder;
|
return mBinder;
|
||||||
|
|||||||
@@ -36,9 +36,13 @@ class HwBinderDeathRecipientList : public RefBase {
|
|||||||
std::vector<sp<HwBinderDeathRecipient>> mList;
|
std::vector<sp<HwBinderDeathRecipient>> mList;
|
||||||
Mutex mLock;
|
Mutex mLock;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~HwBinderDeathRecipientList() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HwBinderDeathRecipientList();
|
explicit HwBinderDeathRecipientList();
|
||||||
~HwBinderDeathRecipientList();
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(HwBinderDeathRecipientList);
|
||||||
|
|
||||||
void add(const sp<HwBinderDeathRecipient>& recipient);
|
void add(const sp<HwBinderDeathRecipient>& recipient);
|
||||||
void remove(const sp<HwBinderDeathRecipient>& recipient);
|
void remove(const sp<HwBinderDeathRecipient>& recipient);
|
||||||
@@ -66,12 +70,7 @@ struct JHwRemoteBinder : public RefBase {
|
|||||||
void setBinder(const sp<hardware::IBinder> &binder);
|
void setBinder(const sp<hardware::IBinder> &binder);
|
||||||
sp<HwBinderDeathRecipientList> getDeathRecipientList() const;
|
sp<HwBinderDeathRecipientList> getDeathRecipientList() const;
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~JHwRemoteBinder();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
jobject mObject;
|
|
||||||
|
|
||||||
sp<hardware::IBinder> mBinder;
|
sp<hardware::IBinder> mBinder;
|
||||||
sp<HwBinderDeathRecipientList> mDeathRecipientList;
|
sp<HwBinderDeathRecipientList> mDeathRecipientList;
|
||||||
DISALLOW_COPY_AND_ASSIGN(JHwRemoteBinder);
|
DISALLOW_COPY_AND_ASSIGN(JHwRemoteBinder);
|
||||||
|
|||||||
Reference in New Issue
Block a user