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);
|
getApplication().unregisterActivityLifecycleCallbacks(mActivityCallbacks);
|
||||||
mActivityCallbacks = null;
|
mActivityCallbacks = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyOverlay();
|
destroyOverlay();
|
||||||
|
|
||||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(mListener);
|
lc.removeListener(mListener);
|
||||||
|
lc = null; // To allow the gc calls below to free the Core
|
||||||
}
|
}
|
||||||
|
|
||||||
sInstance = null;
|
sInstance = null;
|
||||||
LinphoneManager.destroy();
|
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.
|
// Make sure our notification is gone.
|
||||||
mNotificationManager.destroy();
|
mNotificationManager.destroy();
|
||||||
|
@ -432,7 +440,9 @@ public final class LinphoneService extends Service {
|
||||||
LinphoneActivity.instance().finish();
|
LinphoneActivity.instance().finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory.instance().getLoggingService().removeListener(mJavaLoggingService);
|
if (LinphonePreferences.instance().useJavaLogger()) {
|
||||||
|
Factory.instance().getLoggingService().removeListener(mJavaLoggingService);
|
||||||
|
}
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,20 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
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();
|
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
for (FriendList list : lc.getFriendsLists()) {
|
for (FriendList list : lc.getFriendsLists()) {
|
||||||
|
|
|
@ -393,8 +393,13 @@ public class LinphoneContact extends AndroidContact
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFriend(Friend f) {
|
public void setFriend(Friend f) {
|
||||||
|
if (mFriend != null && (f == null || f != mFriend)) {
|
||||||
|
mFriend.setUserData(null);
|
||||||
|
}
|
||||||
mFriend = f;
|
mFriend = f;
|
||||||
mFriend.setUserData(this);
|
if (mFriend != null) {
|
||||||
|
mFriend.setUserData(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInFriendList() {
|
public boolean isInFriendList() {
|
||||||
|
|
|
@ -112,7 +112,12 @@ public class StatusFragment extends Fragment {
|
||||||
new OnClickListener() {
|
new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
lc.refreshRegisters();
|
Core core =
|
||||||
|
LinphoneManager
|
||||||
|
.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (core != null) {
|
||||||
|
core.refreshRegisters();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IllegalStateException ise) {
|
} catch (IllegalStateException ise) {
|
||||||
|
|
Loading…
Reference in a new issue