| 1 | import 'package:cw_core/utils/print_verbose.dart'; |
| 2 | import 'package:flutter/services.dart'; |
| 3 | |
| 4 | const MethodChannel _channel = MethodChannel('com.cake_wallet/native_utils'); |
| 5 | |
| 6 | Future<void> requestDisableBatteryOptimization() async { |
| 7 | try { |
| 8 | await _channel.invokeMethod('disableBatteryOptimization'); |
| 9 | } on PlatformException catch (e) { |
| 10 | printV("Failed to disable battery optimization: '${e.message}'."); |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | Future<bool> isBatteryOptimizationDisabled() async { |
| 15 | try { |
| 16 | final bool isDisabled = await _channel.invokeMethod('isBatteryOptimizationDisabled') as bool; |
| 17 | printV('It\'s actually disabled? $isDisabled'); |
| 18 | return isDisabled; |
| 19 | } on PlatformException catch (e) { |
| 20 | printV("Failed to check battery optimization status: '${e.message}'."); |
| 21 | return false; |
| 22 | } |
| 23 | } |