mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 22:39:22 +00:00
Lock device awake during calls
This commit is contained in:
parent
0ebccf1075
commit
7768e36c62
@ -10,6 +10,7 @@ import 'package:comunic/models/conversation.dart';
|
|||||||
import 'package:comunic/ui/routes/main_route.dart';
|
import 'package:comunic/ui/routes/main_route.dart';
|
||||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||||
import 'package:comunic/utils/account_utils.dart';
|
import 'package:comunic/utils/account_utils.dart';
|
||||||
|
import 'package:comunic/utils/device_utils.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:comunic/utils/ui_utils.dart';
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -147,6 +148,9 @@ class _CallScreenState extends SafeState<CallScreen> {
|
|||||||
await this._memberReady(peer.userID);
|
await this._memberReady(peer.userID);
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
||||||
|
// Lock device await
|
||||||
|
await setWakeLock(true);
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
print("Could not initialize call! $e\n$stack");
|
print("Could not initialize call! $e\n$stack");
|
||||||
setState(() => _error = true);
|
setState(() => _error = true);
|
||||||
@ -156,6 +160,8 @@ class _CallScreenState extends SafeState<CallScreen> {
|
|||||||
/// Do clean up operations when call screen is destroyed
|
/// Do clean up operations when call screen is destroyed
|
||||||
void _endCall() async {
|
void _endCall() async {
|
||||||
try {
|
try {
|
||||||
|
await setWakeLock(false);
|
||||||
|
|
||||||
// Close all ready members
|
// Close all ready members
|
||||||
for (final member in _membersList.readyPeers)
|
for (final member in _membersList.readyPeers)
|
||||||
await _removeMember(member.userID);
|
await _removeMember(member.userID);
|
||||||
|
9
lib/utils/device_utils.dart
Normal file
9
lib/utils/device_utils.dart
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import 'package:wakelock/wakelock.dart';
|
||||||
|
|
||||||
|
/// Device utilities
|
||||||
|
///
|
||||||
|
/// @author Pierre Hubert
|
||||||
|
|
||||||
|
/// Interface for requesting device wake locking
|
||||||
|
Future<void> setWakeLock(bool enabled) async =>
|
||||||
|
await Wakelock.toggle(on: enabled);
|
@ -455,6 +455,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.8"
|
version: "2.0.8"
|
||||||
|
wakelock:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: wakelock
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.4+1"
|
||||||
web_socket_channel:
|
web_socket_channel:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -78,6 +78,9 @@ dependencies:
|
|||||||
# WebRTC calls
|
# WebRTC calls
|
||||||
flutter_webrtc: ^0.2.7
|
flutter_webrtc: ^0.2.7
|
||||||
|
|
||||||
|
# Prevent phone from auto-locking during calls
|
||||||
|
wakelock: ^0.1.4+1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
Loading…
Reference in New Issue
Block a user