Trying to fix checkStateLoss crash + Stopping contacts fetch task if we stop linphone
This commit is contained in:
parent
49c98c9ebd
commit
81d0a0b21e
3 changed files with 43 additions and 15 deletions
|
@ -157,7 +157,6 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
|
||||||
}
|
}
|
||||||
if (mCall == null) {
|
if (mCall == null) {
|
||||||
Log.e("Couldn't find outgoing call");
|
Log.e("Couldn't find outgoing call");
|
||||||
LinphoneActivity.instance().goToDialerFragment();
|
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -249,6 +248,8 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void checkAndRequestCallPermissions() {
|
private void checkAndRequestCallPermissions() {
|
||||||
ArrayList<String> permissionsList = new ArrayList<String>();
|
ArrayList<String> permissionsList = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,11 @@ public class ContactsManager extends ContentObserver {
|
||||||
List<LinphoneContact> contacts = new ArrayList<LinphoneContact>();
|
List<LinphoneContact> contacts = new ArrayList<LinphoneContact>();
|
||||||
Date contactsTime = new Date();
|
Date contactsTime = new Date();
|
||||||
|
|
||||||
|
//We need to check sometimes to know if Linphone was destroyed
|
||||||
|
if (this.isCancelled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasContactsAccess()) {
|
if (hasContactsAccess()) {
|
||||||
Cursor c = getContactsCursor(contentResolver);
|
Cursor c = getContactsCursor(contentResolver);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
|
@ -323,7 +328,10 @@ public class ContactsManager extends ContentObserver {
|
||||||
} else {
|
} else {
|
||||||
Log.w("[Permission] Read contacts permission wasn't granted, only fetch LinphoneFriends");
|
Log.w("[Permission] Read contacts permission wasn't granted, only fetch LinphoneFriends");
|
||||||
}
|
}
|
||||||
|
//We need to check sometimes to know if Linphone was destroyed
|
||||||
|
if (this.isCancelled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
for (LinphoneFriend friend : lc.getFriendList()) {
|
for (LinphoneFriend friend : lc.getFriendList()) {
|
||||||
|
@ -361,6 +369,10 @@ public class ContactsManager extends ContentObserver {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (LinphoneContact contact : contacts) {
|
for (LinphoneContact contact : contacts) {
|
||||||
|
//We need to check sometimes to know if Linphone was destroyed
|
||||||
|
if (this.isCancelled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// This will only get name & picture informations to be able to quickly display contacts list
|
// This will only get name & picture informations to be able to quickly display contacts list
|
||||||
contact.minimalRefresh();
|
contact.minimalRefresh();
|
||||||
i++;
|
i++;
|
||||||
|
@ -382,6 +394,10 @@ public class ContactsManager extends ContentObserver {
|
||||||
publishProgress(contacts);
|
publishProgress(contacts);
|
||||||
|
|
||||||
for (LinphoneContact contact : contacts) {
|
for (LinphoneContact contact : contacts) {
|
||||||
|
//We need to check sometimes to know if Linphone was destroyed
|
||||||
|
if (this.isCancelled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// This time fetch all informations including phone numbers and SIP addresses
|
// This time fetch all informations including phone numbers and SIP addresses
|
||||||
contact.refresh();
|
contact.refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -671,7 +671,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
|
|
||||||
public synchronized final void destroyLinphoneCore() {
|
public synchronized final void destroyLinphoneCore() {
|
||||||
sExited = true;
|
sExited = true;
|
||||||
BluetoothManager.getInstance().destroy();
|
ContactsManagerDestroy();
|
||||||
|
BluetoothManagerDestroy();
|
||||||
try {
|
try {
|
||||||
mTimer.cancel();
|
mTimer.cancel();
|
||||||
mLc.destroy();
|
mLc.destroy();
|
||||||
|
@ -936,7 +937,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
private void doDestroy() {
|
private void doDestroy() {
|
||||||
BluetoothManager.getInstance().destroy();
|
ContactsManagerDestroy();
|
||||||
|
BluetoothManagerDestroy();
|
||||||
try {
|
try {
|
||||||
mTimer.cancel();
|
mTimer.cancel();
|
||||||
mLc.destroy();
|
mLc.destroy();
|
||||||
|
@ -952,9 +954,18 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ContactsManagerDestroy() {
|
||||||
|
if (ContactsManager.getInstance() != null)
|
||||||
|
ContactsManager.getInstance().destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BluetoothManagerDestroy() {
|
||||||
|
if (BluetoothManager.getInstance() != null)
|
||||||
|
BluetoothManager.getInstance().destroy();
|
||||||
|
}
|
||||||
|
|
||||||
public static synchronized void destroy() {
|
public static synchronized void destroy() {
|
||||||
if (instance == null) return;
|
if (instance == null) return;
|
||||||
ContactsManager.getInstance().destroy();
|
|
||||||
getInstance().changeStatusToOffline();
|
getInstance().changeStatusToOffline();
|
||||||
sExited = true;
|
sExited = true;
|
||||||
instance.doDestroy();
|
instance.doDestroy();
|
||||||
|
|
Loading…
Reference in a new issue