Add intent wedge scanner, MDM support for Android (#863)

Add Android intent wedge scanner support with auto configuration for supported Zebra and Datalogic devices.
Intent wedge scans can be done without pressing the scan button first.

Adds the ability for an MDM server to push settings on Android.
This commit is contained in:
Reza Fouladian
2026-08-16 13:59:20 +10:00
committed by GitHub
parent 2cc5d37f71
commit ca655f36fe
12 changed files with 1114 additions and 1 deletions
+67
View File
@@ -0,0 +1,67 @@
import "dart:io";
import "package:flutter/foundation.dart";
import "package:flutter/services.dart";
import "package:inventree/preferences.dart";
const MethodChannel _channel = MethodChannel("inventree/wedge");
class WedgeDetectionResult {
const WedgeDetectionResult({this.vendor = "none", this.supported = false});
final String vendor;
final bool supported;
}
Future<WedgeDetectionResult> detectWedgeScanner() async {
if (kIsWeb || !Platform.isAndroid) {
return const WedgeDetectionResult();
}
try {
final Map<String, dynamic>? result = await _channel
.invokeMapMethod<String, dynamic>("detectWedge");
if (result == null) return const WedgeDetectionResult();
return WedgeDetectionResult(
vendor: (result["vendor"] ?? "none").toString(),
supported: result["supported"] == true,
);
} catch (error) {
return const WedgeDetectionResult();
}
}
Future<void> applyWedgeDetection(WedgeDetectionResult result) async {
if (result.supported) {
await InvenTreeSettingsManager().setValue(
INV_BARCODE_SCAN_TYPE,
BARCODE_CONTROLLER_INTENT,
);
}
await InvenTreeSettingsManager().setValue(INV_BARCODE_WEDGE_DETECTED, true);
}
Future<void> initWedgeScannerDefault() async {
if (await InvenTreeSettingsManager().getBool(
INV_BARCODE_WEDGE_DETECTED,
false,
)) {
return;
}
final dynamic existing = await InvenTreeSettingsManager().getValue(
INV_BARCODE_SCAN_TYPE,
null,
);
if (existing != null) {
await InvenTreeSettingsManager().setValue(INV_BARCODE_WEDGE_DETECTED, true);
return;
}
await applyWedgeDetection(await detectWedgeScanner());
}