fix crash when applicationDidEnterBackground is called twice

This commit is contained in:
Danmei Chen 2020-05-22 16:01:28 +02:00
parent 88a0d9302d
commit 3e191259aa

View file

@ -57,9 +57,6 @@
- (void)applicationDidEnterBackground:(UIApplication *)application {
LOGI(@"%@", NSStringFromSelector(_cmd));
[LinphoneManager.instance enterBackgroundMode];
[LinphoneManager.instance.fastAddressBook clearFriends];
[CoreManager.instance stopLinphoneCore];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
@ -73,17 +70,20 @@
LOGI(@"%@", NSStringFromSelector(_cmd));
LinphoneCall *call = linphone_core_get_current_call(LC);
if (!call)
return;
if (call) {
/* save call context */
LinphoneManager *instance = LinphoneManager.instance;
instance->currentCallContextBeforeGoingBackground.call = call;
instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call);
/* save call context */
LinphoneManager *instance = LinphoneManager.instance;
instance->currentCallContextBeforeGoingBackground.call = call;
instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call);
const LinphoneCallParams *params = linphone_call_get_current_params(call);
if (linphone_call_params_video_enabled(params))
linphone_call_enable_camera(call, false);
}
const LinphoneCallParams *params = linphone_call_get_current_params(call);
if (linphone_call_params_video_enabled(params))
linphone_call_enable_camera(call, false);
[LinphoneManager.instance enterBackgroundMode];
[LinphoneManager.instance.fastAddressBook clearFriends];
[CoreManager.instance stopLinphoneCore];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {