register static method
Register the QHexRT backend with the C++ plugin registry. Safe to call multiple times; on unsupported devices registration is rejected.
Implementation
static Future<bool> register() async {
if (_isRegistered) {
_logger.debug('QHexRT already registered');
return true;
}
if (!isAvailable) {
_logger.error('QHexRT native library not available');
return false;
}
try {
_bindings ??= QhexrtBindings();
final skelDirectory = Platform.isAndroid
? await _platformChannel.invokeMethod<String>('prepareSkelDirectory')
: null;
_bindings!.setSkelDirectory(skelDirectory);
final result = _bindings!.register();
_logger.info('rac_backend_qhexrt_register() returned: $result');
if (result == RacResultCode.errorBackendUnavailable ||
result == RacResultCode.errorCapabilityUnsupported) {
_logger.error(
'QHexRT unavailable; a supported Hexagon V75/V79/V81 NPU is required.',
);
return false;
}
if (result != RacResultCode.success &&
result != RacResultCode.errorModuleAlreadyRegistered) {
_logger.error('QHexRT registration failed with code: $result');
return false;
}
_isRegistered = true;
_logger.info('QHexRT backend registered (LLM/VLM/STT/TTS)');
return true;
} catch (e) {
_logger.error('QHexRT registration error: $e');
return false;
}
}