feat: background and terminated calls [android]

This commit is contained in:
td 2022-09-10 15:42:52 +05:30
commit 34b039a6c0
18 changed files with 421 additions and 195 deletions

View file

@ -13,6 +13,7 @@ import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/utils/client_manager.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/voip/callkeep_manager.dart';
Future<void> pushHelper(
PushNotification notification, {
@ -110,11 +111,29 @@ Future<void> _tryPushHelper(
}
return;
}
Logs().v('Push helper got notification event.');
Logs().v('Push helper got notification event of type ${event.type}.');
if (!event.isEventTypeKnown) {
Logs()
.v('Push message event is from an unknown event type. Do not display.');
if (event.type.startsWith('m.call')) {
// make sure bg sync is on (needed to update hold, unhold events)
// prevent over write from app life cycle change
client.backgroundSync = true;
}
if (event.type == EventTypes.CallInvite) {
CallKeepManager().initialize();
} else if (event.type == EventTypes.CallHangup) {
client.backgroundSync = false;
}
if (event.type.startsWith('m.call') && event.type != EventTypes.CallInvite) {
Logs().v('Push message is a m.call but not invite. Do not display.');
return;
}
if ((event.type.startsWith('m.call') &&
event.type != EventTypes.CallInvite) ||
event.type == 'org.matrix.call.sdp_stream_metadata_changed') {
Logs().v('Push message was for a call, but not call invite.');
return;
}