registerService static method

Future<int> registerService(
  1. AccessibilityService serviceHandler
)

Implementation

static Future<int> registerService(
    AccessibilityService serviceHandler) async {
  log("registering service");
  WidgetsFlutterBinding.ensureInitialized();
  if (_backgroundChannel == null) {
    _backgroundChannel =
        MethodChannel("com.mixaline.android_native/accessibility_background");
    _backgroundChannel!.setMethodCallHandler(onBackgroundMethodCall);
  }
  var id = _serviceId++;
  _serviceRegistry[id] = serviceHandler;

  final running = await _backgroundChannel!.invokeMethod("isRunning");
  if (running != _running) {
    _running = running;
  }

  if (_running) {
    log("service is already running calling onServiceConected immediatly");
    serviceHandler.onServiceConnected();
  }
  return id;
}