feat(android): 添加 CH934X USB 转串口芯片支持

- 在 AndroidManifest.xml 中添加 USB Host 权限声明
- 集成 CH934X Android SDK 并通过反射调用原生功能
- 实现设备查找、串口读写、GPIO 和 Modem 控制功能
- 添加异常回调机制处理设备拔出等情况
- 提供 Stream 数据流支持实时串口数据监听
- 完善单元测试覆盖所有核心功能模块
This commit is contained in:
Developer
2026-07-06 16:06:54 +08:00
parent 6efaf5671f
commit e0d1a1775d
26 changed files with 2055 additions and 184 deletions
@@ -1,24 +1,20 @@
// This is a basic Flutter integration test.
// CH934X 插件的集成测试入口。
//
// Since integration tests run in a full Flutter application, they can interact
// with the host side of a plugin implementation, unlike Dart unit tests.
//
// For more information about Flutter integration tests, please see
// https://flutter.dev/to/integration-testing
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
// 集成测试运行在完整的 Flutter 应用中,可以与原生层通信;
// 当前插件主要覆盖 Android 平台,因此以下用例仅在连接真实
// USB 设备时才有意义。CI 中通常会跳过该测试。
import 'package:ch934x_serial/ch934x_serial.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('getPlatformVersion test', (WidgetTester tester) async {
testWidgets('plugin 暴露 deviceList API', (tester) async {
final Ch934xSerial plugin = Ch934xSerial();
final String? version = await plugin.getPlatformVersion();
// The version string depends on the host platform running the test, so
// just assert that some non-empty string is returned.
expect(version?.isNotEmpty, true);
final devices = await plugin.getDeviceList();
// 集成测试环境下可能没有真实设备,允许为空。
expect(devices, isA<List<Ch934xDeviceInfo>>());
});
}