import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'flutter_tool_android_platform_interface.dart';

/// An implementation of [FlutterToolAndroidPlatform] that uses method channels.
class MethodChannelFlutterToolAndroid extends FlutterToolAndroidPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('flutter_tool_android');

  @override
  Future<bool> isIgnoringBatteryOptimizations() async {
    final isIgnore = await methodChannel
        .invokeMethod<bool>('isIgnoringBatteryOptimizations');
    return isIgnore == true;
  }

  @override
  Future<void> openBatteryOptimizationSettings() async {
    return await methodChannel
        .invokeMethod<void>('openBatteryOptimizationSettings');
  }

  @override
  Future<void> openAppBackgroundSetting() async {
    return await methodChannel.invokeMethod<void>('openAppBackgroundSetting');
  }

  @override
  Future<void> backHome() async {
    return await methodChannel.invokeMethod<void>('backHome');
  }
}
