refactor(android): 重构Android端实现使用官方SDK替代反射调用

- 移除反射机制,直接集成CH934XLib.jar官方SDK
- 添加CH934XManager初始化逻辑并处理Application上下文兼容性
- 实现设备枚举、串口打开关闭等核心功能的直接调用
- 集成IDataCallback和IModemStatus回调处理
- 更新异常回调机制,支持原生层主动推送异常事件
- 优化设备连接状态管理和USB权限处理
- 为Dart模型类添加相等性比较和哈希码实现
- 更新示例应用UI以适配新的串口索引选择逻辑
This commit is contained in:
Developer
2026-07-06 16:48:14 +08:00
parent e0d1a1775d
commit 90de9121ff
4 changed files with 468 additions and 267 deletions
+34
View File
@@ -30,6 +30,16 @@ class Ch934xSerialPortInfo {
driverName: map['driverName'] as String?,
);
}
@override
bool operator ==(Object other) =>
other is Ch934xSerialPortInfo &&
other.portIndex == portIndex &&
other.devicePath == devicePath &&
other.driverName == driverName;
@override
int get hashCode => Object.hash(portIndex, devicePath, driverName);
}
/// 文档 4.1.4 中 `UsbHelper.getCH934XDeviceList` 返回的设备信息。
@@ -104,4 +114,28 @@ class Ch934xDeviceInfo {
serialPorts: ports,
);
}
@override
bool operator ==(Object other) =>
other is Ch934xDeviceInfo &&
other.deviceId == deviceId &&
other.vendorId == vendorId &&
other.productId == productId &&
other.deviceType == deviceType &&
other.serialNumber == serialNumber &&
other.productName == productName &&
other.manufacturerName == manufacturerName &&
other.interfaceCount == interfaceCount;
@override
int get hashCode => Object.hash(
deviceId,
vendorId,
productId,
deviceType,
serialNumber,
productName,
manufacturerName,
interfaceCount,
);
}