Fixed Core references being held in different places in the app, preventing from being unref'ed at native level
This commit is contained in:
parent
91c1230eef
commit
e653ce2fe7
4 changed files with 38 additions and 4 deletions
|
@ -413,15 +413,23 @@ public final class LinphoneService extends Service {
|
|||
getApplication().unregisterActivityLifecycleCallbacks(mActivityCallbacks);
|
||||
mActivityCallbacks = null;
|
||||
}
|
||||
|
||||
destroyOverlay();
|
||||
|
||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc != null) {
|
||||
lc.removeListener(mListener);
|
||||
lc = null; // To allow the gc calls below to free the Core
|
||||
}
|
||||
|
||||
sInstance = null;
|
||||
LinphoneManager.destroy();
|
||||
// The following are required if we want for the Core's finalize() method to be called
|
||||
// before the super.onDestroy() call.
|
||||
// We have to so there are no more ref on the native LinphoneCore object and thus call
|
||||
// it's uninit() method which will free the AndroidPlatformHelper resources...
|
||||
// Problem is both the below methods do not guaranty the finalize will be called in time...
|
||||
//System.gc();
|
||||
//System.runFinalization();
|
||||
|
||||
// Make sure our notification is gone.
|
||||
mNotificationManager.destroy();
|
||||
|
@ -432,7 +440,9 @@ public final class LinphoneService extends Service {
|
|||
LinphoneActivity.instance().finish();
|
||||
}
|
||||
|
||||
if (LinphonePreferences.instance().useJavaLogger()) {
|
||||
Factory.instance().getLoggingService().removeListener(mJavaLoggingService);
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
|
|
@ -122,6 +122,20 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
|||
}
|
||||
|
||||
public void destroy() {
|
||||
if (mLoadContactTask != null) {
|
||||
mLoadContactTask.cancel(true);
|
||||
}
|
||||
// LinphoneContact has a Friend field and Friend can have a LinphoneContact has userData
|
||||
// Friend also keeps a ref on the Core, so we have to clean them
|
||||
for (LinphoneContact c : mContacts) {
|
||||
c.setFriend(null);
|
||||
}
|
||||
mContacts.clear();
|
||||
for (LinphoneContact c : mSipContacts) {
|
||||
c.setFriend(null);
|
||||
}
|
||||
mSipContacts.clear();
|
||||
|
||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc != null) {
|
||||
for (FriendList list : lc.getFriendsLists()) {
|
||||
|
|
|
@ -393,9 +393,14 @@ public class LinphoneContact extends AndroidContact
|
|||
}
|
||||
|
||||
public void setFriend(Friend f) {
|
||||
if (mFriend != null && (f == null || f != mFriend)) {
|
||||
mFriend.setUserData(null);
|
||||
}
|
||||
mFriend = f;
|
||||
if (mFriend != null) {
|
||||
mFriend.setUserData(this);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInFriendList() {
|
||||
if (mFriend == null) return false;
|
||||
|
|
|
@ -112,7 +112,12 @@ public class StatusFragment extends Fragment {
|
|||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
lc.refreshRegisters();
|
||||
Core core =
|
||||
LinphoneManager
|
||||
.getLcIfManagerNotDestroyedOrNull();
|
||||
if (core != null) {
|
||||
core.refreshRegisters();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (IllegalStateException ise) {
|
||||
|
|
Loading…
Reference in a new issue