mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-12-25 12:28:50 +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/widgets/safe_state.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/ui_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -147,6 +148,9 @@ class _CallScreenState extends SafeState<CallScreen> {
|
||||
await this._memberReady(peer.userID);
|
||||
|
||||
setState(() {});
|
||||
|
||||
// Lock device await
|
||||
await setWakeLock(true);
|
||||
} catch (e, stack) {
|
||||
print("Could not initialize call! $e\n$stack");
|
||||
setState(() => _error = true);
|
||||
@ -156,6 +160,8 @@ class _CallScreenState extends SafeState<CallScreen> {
|
||||
/// Do clean up operations when call screen is destroyed
|
||||
void _endCall() async {
|
||||
try {
|
||||
await setWakeLock(false);
|
||||
|
||||
// Close all ready members
|
||||
for (final member in _membersList.readyPeers)
|
||||
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"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -78,6 +78,9 @@ dependencies:
|
||||
# WebRTC calls
|
||||
flutter_webrtc: ^0.2.7
|
||||
|
||||
# Prevent phone from auto-locking during calls
|
||||
wakelock: ^0.1.4+1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
Loading…
Reference in New Issue
Block a user