diff --git a/android/app/build.gradle b/android/app/build.gradle index e8f0a10f..cb1b1441 100755 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -290,4 +290,8 @@ dependencies { // implementation(name: 'HiPushSDK-7.0.61.303', ext: 'aar') //接入 VIVO 厂商 implementation 'cn.jiguang.sdk.plugin:vivo:5.2.3' + + // Umeng统计 + implementation 'com.umeng.umsdk:common:9.3.7' + implementation 'com.umeng.umsdk:asms:1.4.1' } diff --git a/android/app/proguard-rules-sky.pro b/android/app/proguard-rules-sky.pro index d8df8d76..92eda14c 100644 --- a/android/app/proguard-rules-sky.pro +++ b/android/app/proguard-rules-sky.pro @@ -131,4 +131,9 @@ -keep class com.tencent.mm.opensdk.** { *; } -dontwarn com.tencent.bugly.** --keep public class com.tencent.bugly.**{*;} \ No newline at end of file +-keep public class com.tencent.bugly.**{*;} + +-keep class com.umeng.** { *; } +-keep class com.umeng.**$* { *; } +-keep class com.umeng.message.** { *; } +-keep class com.umeng.message.**$* { *; } \ No newline at end of file diff --git a/android/app/proguard-rules-xhj.pro b/android/app/proguard-rules-xhj.pro index 78db18c1..b48710ff 100644 --- a/android/app/proguard-rules-xhj.pro +++ b/android/app/proguard-rules-xhj.pro @@ -131,4 +131,9 @@ -keep class com.tencent.mm.opensdk.** { *; } -dontwarn com.tencent.bugly.** --keep public class com.tencent.bugly.**{*;} \ No newline at end of file +-keep public class com.tencent.bugly.**{*;} + +-keep class com.umeng.** { *; } +-keep class com.umeng.**$* { *; } +-keep class com.umeng.message.** { *; } +-keep class com.umeng.message.**$* { *; } \ No newline at end of file diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index de19f619..3934e6aa 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -128,4 +128,9 @@ } -keep class com.tencent.mm.sdk.** { *; } --keep class com.tencent.mm.opensdk.** { *; } \ No newline at end of file +-keep class com.tencent.mm.opensdk.** { *; } + +-keep class com.umeng.** { *; } +-keep class com.umeng.**$* { *; } +-keep class com.umeng.message.** { *; } +-keep class com.umeng.message.**$* { *; } \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a0c4547f..9e6d6868 100755 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -56,6 +56,14 @@ android:name="android.permission.QUERY_ALL_PACKAGES" tools:node="remove" /> + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/assets/umeng_config.xml b/android/app/src/main/assets/umeng_config.xml new file mode 100644 index 00000000..1ba6cc4c --- /dev/null +++ b/android/app/src/main/assets/umeng_config.xml @@ -0,0 +1,5 @@ + + + 671244cf80464b33f6df9648 + Product + \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt b/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt index dcd984c1..741b150f 100755 --- a/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt +++ b/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt @@ -12,10 +12,16 @@ import android.bluetooth.BluetoothAdapter; import androidx.core.content.FileProvider import java.io.File +import com.umeng.commonsdk.UMConfigure + class MainActivity : FlutterActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) GeneratedPluginRegistrant.registerWith(flutterEngine!!) + + // 初始化 Umeng SDK + UMConfigure.init(this, "671244cf80464b33f6df9648", "Product", UMConfigure.DEVICE_TYPE_PHONE, null) + MethodChannel(flutterEngine?.dartExecutor!!.binaryMessenger, "starLockFlutterSend").setMethodCallHandler { call, result -> if (call.method == "loadNativeShare") { val map = call.arguments as Map diff --git a/ios/Podfile b/ios/Podfile index f60e3f48..76407fa5 100755 --- a/ios/Podfile +++ b/ios/Podfile @@ -30,6 +30,9 @@ flutter_ios_podfile_setup target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + + pod 'UMCommon' + pod 'UMDevice' end # Plugin Pods diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 44634c20..ff057194 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -148,6 +148,13 @@ PODS: - system_settings (0.0.1): - Flutter - Toast (4.1.1) + - UMCommon (7.4.7): + - UMDevice + - UMDevice (3.4.0) + - umeng_common_sdk (0.0.1): + - Flutter + - UMCommon + - UMDevice - url_launcher_ios (0.0.1): - Flutter - video_player_avfoundation (0.0.1): @@ -194,6 +201,9 @@ DEPENDENCIES: - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite (from `.symlinks/plugins/sqflite/darwin`) - system_settings (from `.symlinks/plugins/system_settings/ios`) + - UMCommon + - UMDevice + - umeng_common_sdk (from `.symlinks/plugins/umeng_common_sdk/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`) - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) @@ -221,6 +231,8 @@ SPEC REPOS: - SDWebImage - SwiftyGif - Toast + - UMCommon + - UMDevice - WechatOpenSDK-XCFramework EXTERNAL SOURCES: @@ -292,6 +304,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/sqflite/darwin" system_settings: :path: ".symlinks/plugins/system_settings/ios" + umeng_common_sdk: + :path: ".symlinks/plugins/umeng_common_sdk/ios" url_launcher_ios: :path: ".symlinks/plugins/url_launcher_ios/ios" video_player_avfoundation: @@ -354,11 +368,14 @@ SPEC CHECKSUMS: SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 system_settings: 8f5cdbfa72c677fc8d665b863bcc20d393d87e9d Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e + UMCommon: 8b4cd0423297c39bca6eea1ec896558b40e5bcf7 + UMDevice: dcdf7ec167387837559d149fbc7d793d984faf82 + umeng_common_sdk: a8abd7f86dfd013dbbeeae587ee143760c6582f2 url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3 webview_flutter_wkwebview: 2a23822e9039b7b1bc52e5add778e5d89ad488d1 WechatOpenSDK-XCFramework: 36fb2bea0754266c17184adf4963d7e6ff98b69f -PODFILE CHECKSUM: 317f9473a5705c6fe4d79d95e81676f248048fdc +PODFILE CHECKSUM: a4d4747e9f246a7c5b9d643d5efa33799112963a COCOAPODS: 1.14.3 diff --git a/ios/Runner/AppDelegate.m b/ios/Runner/AppDelegate.m index 086a7d55..4b399780 100755 --- a/ios/Runner/AppDelegate.m +++ b/ios/Runner/AppDelegate.m @@ -5,7 +5,7 @@ #import "XSFlutterManager.h" #import - +#import @interface AppDelegate() @@ -19,6 +19,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [UMConfigure initWithAppkey:@"671244ae80464b33f6df9646" channel:@"Product"]; + XSFlutterManager *VC = [[XSFlutterManager alloc] init]; self.window.rootViewController = VC; [self.window makeKeyAndVisible]; diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index 805b7a79..e2581afb 100755 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -73,6 +73,7 @@ class BlueManage { List lastTimeData = []; int? dataLen; Timer? scanSingleTimer; + bool needScanSingle = false; static BlueManage? _manager; @@ -141,7 +142,8 @@ class BlueManage { } /// 开始指定设备名称的扫描蓝牙设备 - Future startScanSingle(String deviceName, int timeout, ScanDevicesCallBack scanDevicesCallBack) async { + Future startScanSingle(String deviceName, int timeout, + ScanDevicesCallBack scanDevicesCallBack) async { final DateTime start = DateTime.now(); FlutterBluePlus.isSupported.then((bool isAvailable) async { if (isAvailable) { @@ -151,8 +153,7 @@ class BlueManage { BuglyTool.uploadException( message: '开始指定设备名称的扫描蓝牙设备', detail: '调用方法是:startScanSingle 指定设备名称是:$deviceName', - upload: false - ); + upload: false); //android 扫描比较慢,取样只要 3 分之一 final int divisor = Platform.isAndroid ? 3 : 1; FlutterBluePlus.startScan( @@ -172,9 +173,9 @@ class BlueManage { '扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒'); BuglyTool.uploadException( message: '指定设备名称的扫描蓝牙设备 监听扫描结果', - detail: 'startScanSingle$deviceName 监听扫描结果 是否查找到 $isExit 以查找$milliseconds毫秒 扫描到的设备数:${results.length} results:$results', - upload: false - ); + detail: + 'startScanSingle$deviceName 监听扫描结果 是否查找到 $isExit 以查找$milliseconds毫秒 扫描到的设备数:${results.length} results:$results', + upload: false); if (isExit) { for (final ScanResult scanResult in results) { if (((scanResult.advertisementData.serviceUuids.isNotEmpty @@ -198,21 +199,22 @@ class BlueManage { } BuglyTool.uploadException( message: '遍历扫描到的结果跟缓存的结果对比,如果有最新的就更新缓存', - detail: 'startScanSingle deviceName:$deviceName 查询到的结果scanResult:$scanResult', - upload: false - ); + detail: + 'startScanSingle deviceName:$deviceName 查询到的结果scanResult:$scanResult', + upload: false); } } completer.complete(); } }, onError: (e) { - BuglyTool.uploadException( - message: '指定设备名称的扫描蓝牙设备 监听扫描结果失败', - detail: '打印失败问题 e:${e.toString()}', - upload: false - ); - AppLog.log('扫描失败:$e',); + BuglyTool.uploadException( + message: '指定设备名称的扫描蓝牙设备 监听扫描结果失败', + detail: '打印失败问题 e:${e.toString()}', + upload: false); + AppLog.log( + '扫描失败:$e', + ); }); FlutterBluePlus.cancelWhenScanComplete(subscription); await completer.future; @@ -222,8 +224,7 @@ class BlueManage { BuglyTool.uploadException( message: '指定设备名称的扫描蓝牙设备 内部逻辑整形失败', detail: 'tartScanSingle内部逻辑整形失败 e:${e.toString()}', - upload: false - ); + upload: false); AppLog.log('扫描失败'); } } else { @@ -311,26 +312,26 @@ class BlueManage { if (bluetoothConnectionState != BluetoothConnectionState.connected) { BuglyTool.uploadException( message: '点击按钮 蓝牙未连接 下一步扫描连接蓝牙', - detail: 'blueSendData 蓝牙连接状态 bluetoothConnectionState:$bluetoothConnectionState deviceName:$deviceName', - upload: false - ); + detail: + 'blueSendData 蓝牙连接状态 bluetoothConnectionState:$bluetoothConnectionState deviceName:$deviceName', + upload: false); _connect(deviceName, (BluetoothConnectionState state) { stateCallBack(bluetoothConnectionState!); }, isAddEquipment: isAddEquipment); } else { BuglyTool.uploadException( message: '点击按钮 蓝牙已经连接 下一步扫描连接蓝牙', - detail: 'blueSendData 直接回调状态 蓝牙连接状态bluetoothConnectionState:$bluetoothConnectionState deviceName:$deviceName', - upload: false - ); + detail: + 'blueSendData 直接回调状态 蓝牙连接状态bluetoothConnectionState:$bluetoothConnectionState deviceName:$deviceName', + upload: false); stateCallBack(bluetoothConnectionState!); } } else { BuglyTool.uploadException( message: '点击按钮 蓝牙未打开', - detail: 'blueSendData 蓝牙未打开--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName', - upload: false - ); + detail: + 'blueSendData 蓝牙未打开--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName', + upload: false); try { stateCallBack(BluetoothConnectionState.disconnected); openBlue(); @@ -338,17 +339,16 @@ class BlueManage { AppLog.log('蓝牙打开失败'); BuglyTool.uploadException( message: '点击按钮 蓝牙未打开 然后蓝牙打开失败', - detail: 'blueSendData 蓝牙打开失败--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName', - upload: false - ); + detail: + 'blueSendData 蓝牙打开失败--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName', + upload: false); } } } else { BuglyTool.uploadException( message: '点击按钮 蓝牙状态不可用', detail: 'blueSendData 蓝牙状态不可用--isAvailable:$isAvailable', - upload: false - ); + upload: false); stateCallBack(BluetoothConnectionState.disconnected); AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作'); } @@ -365,38 +365,74 @@ class BlueManage { // 是否有缓存设备 true是有缓存设备 final bool isExistDevice = isExistScanDevices(connectDeviceName); // 是否是当前设备 - final bool isCurrentDevice = CommonDataManage().currentKeyInfo.lockName == deviceName; + final bool isCurrentDevice = + CommonDataManage().currentKeyInfo.lockName == deviceName; // mac地址 final String? mac = CommonDataManage().currentKeyInfo.mac; AppLog.log('开始连接 是否存在缓存:$isExistDevice 是否是当前设备:$isCurrentDevice mac:$mac'); - if (GetPlatform.isAndroid && !isExistDevice && isCurrentDevice && mac != null) { + if (GetPlatform.isAndroid && + !isExistDevice && + isCurrentDevice && + mac != null) { // 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 BuglyTool.uploadException( message: '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是:_connect', - detail: '调用方法_connect deviceName:$deviceName GetPlatform.isAndroid:${GetPlatform.isAndroid} isExistDevice:$isExistDevice mac:$mac', - upload: false - ); - scanSingleTimer?.cancel(); + detail: + '调用方法_connect deviceName:$deviceName GetPlatform.isAndroid:${GetPlatform.isAndroid} isExistDevice:$isExistDevice mac:$mac needScanSingle:$needScanSingle', + upload: false); + // scanSingleTimer?.cancel(); // 兼容android 的低配手机 - await doNotSearchBLE(mac, connectStateCallBack, isAddEquipment: isAddEquipment); - // - scanSingleTimer = Timer(3.seconds, () { - scanSingleTimer?.cancel(); + try { + if (!needScanSingle) { + BuglyTool.uploadException( + message: + '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是:_connect', + detail: '调用方法doNotSearchBLE,直接连接,needScanSingle:$needScanSingle', + upload: false); + await doNotSearchBLE(mac, connectStateCallBack, + isAddEquipment: isAddEquipment); + } else { + BuglyTool.uploadException( + message: + '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是:_connect', + detail: + '调用方法startScanSingle,执行扫描函数,needScanSingle:$needScanSingle', + upload: false); + startScanSingle(deviceName, 15, (List scanDevices) { + _connectDevice(scanDevices, deviceName, connectStateCallBack, + isAddEquipment: isAddEquipment); + }); + } + } catch (e) { BuglyTool.uploadException( - message: '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 3秒以后调用startScanSingle 上传记录当前方法是:_connect', - detail: '_connect deviceName:$deviceName scanSingleTimer调用startScanSingle', - upload: false - ); - startScanSingle(deviceName, 15, (List scanDevices) => null); - }); + message: '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是:_connect', + detail: '调用方法doNotSearchBLE发生异常,执行扫描函数 startScanSingle,异常信息:$e', + upload: false); + startScanSingle(deviceName, 15, (List scanDevices) { + _connectDevice(scanDevices, deviceName, connectStateCallBack, + isAddEquipment: isAddEquipment); + }); + } + // + // scanSingleTimer = Timer(3.seconds, () { + // scanSingleTimer?.cancel(); + // BuglyTool.uploadException( + // message: + // '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 3秒以后调用startScanSingle 上传记录当前方法是:_connect', + // detail: + // '_connect deviceName:$deviceName scanSingleTimer调用startScanSingle', + // upload: false); + // startScanSingle(deviceName, 15, (List scanDevices) => null); + // });ƒ } else if (isAddEquipment == false && isExistDevice == false) { // 取消缓存直接使用,存在配对场景设备信息会更变 BuglyTool.uploadException( - message: '取消缓存直接使用,存在配对场景设备信息会更变 然后开始指定设备名称的扫描蓝牙设备 上传记录当前方法是:_connect', - detail: '符合条件(isAddEquipment == false && isExistDevice == false) 下一步调用startScanSingle', - upload: false - ); + message: + '取消缓存直接使用,存在配对场景设备信息会更变 然后开始指定设备名称的扫描蓝牙设备 上传记录当前方法是:_connect', + detail: + '符合条件(isAddEquipment == false && isExistDevice == false) 下一步调用startScanSingle', + upload: false); // AppLog.log('无存在设备需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment'); startScanSingle(deviceName, 15, (List scanDevices) { @@ -406,9 +442,9 @@ class BlueManage { } else { BuglyTool.uploadException( message: '没有扫描直接调用连接设备 上传记录当前方法是:_connect', - detail: '走这个方法是有缓存或者添加设备的时候以及不符合(GetPlatform.isAndroid && !isExistDevice && isCurrentDevice && mac != null) deviceName:$deviceName 直接调用_connectDevice', - upload: false - ); + detail: + '走这个方法是有缓存或者添加设备的时候以及不符合(GetPlatform.isAndroid && !isExistDevice && isCurrentDevice && mac != null) deviceName:$deviceName 直接调用_connectDevice', + upload: false); // AppLog.log('安卓或者iOS 存在设备不需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment'); _connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment); @@ -417,18 +453,19 @@ class BlueManage { //查找缓存里面是否有设备 bool isExistScanDevices(String connectDeviceName) { - final bool isExistDevice = scanDevices.any((ScanResult element) => element.device.platformName == connectDeviceName || element.advertisementData.advName == connectDeviceName); + final bool isExistDevice = scanDevices.any((ScanResult element) => + element.device.platformName == connectDeviceName || + element.advertisementData.advName == connectDeviceName); return isExistDevice; } Future _connectDevice( List devicesList, String deviceName, - ConnectStateCallBack connectStateCallBack, - { - bool isAddEquipment = false, // 是否是添加设备之前 - bool isReconnect = true, // 是否是重连 - }) async { + ConnectStateCallBack connectStateCallBack, { + bool isAddEquipment = false, // 是否是添加设备之前 + bool isReconnect = true, // 是否是重连 + }) async { // 判断数组列表里面是否有这个设备 // AppLog.log("devicesList:$devicesList"); @@ -453,25 +490,27 @@ class BlueManage { } if (scanResult == null || connectDeviceMacAddress.isEmpty) { BuglyTool.uploadException( - message: '扫描结果scanResult == null || connectDeviceMacAddress.isEmpty不往下执行 return 上传记录当前方法是:_connectDevice', - detail: 'scanResult:$scanResult connectDeviceMacAddress:$connectDeviceMacAddress', - upload: false - ); + message: + '扫描结果scanResult == null || connectDeviceMacAddress.isEmpty不往下执行 return 上传记录当前方法是:_connectDevice', + detail: + 'scanResult:$scanResult connectDeviceMacAddress:$connectDeviceMacAddress', + upload: false); return; } AppLog.log('调用了停止扫描的方法'); await stopScan(); - if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') && isAddEquipment == false) { + if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') && + isAddEquipment == false) { // 添加这个判断是因为有些苹果设备或者安卓等性能比较好的设备时,添加完锁之后,锁板未改变为已添加状态之前,就进行了蓝牙连接,导致添加完锁就失败,这里进行了判断,如果第一次连接失败,就清除缓存重新扫描连接 if (isReconnect == true) { AppLog.log('该锁已被重置, 重新发送扫描命令'); BuglyTool.uploadException( message: '该锁已被重置, 重新发送扫描命令startScanSingle 上传记录当前方法是:_connectDevice', - detail: '添加这个判断是因为有些苹果设备或者安卓等性能比较好的设备时,添加完锁之后,锁板未改变为已添加状态之前,就进行了蓝牙连接,导致添加完锁就失败,这里进行了判断,如果第一次连接失败,就清除缓存重新扫描连接 该锁已被重置, 重新发送扫描命令 serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}', - upload: false - ); + detail: + '添加这个判断是因为有些苹果设备或者安卓等性能比较好的设备时,添加完锁之后,锁板未改变为已添加状态之前,就进行了蓝牙连接,导致添加完锁就失败,这里进行了判断,如果第一次连接失败,就清除缓存重新扫描连接 该锁已被重置, 重新发送扫描命令 serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}', + upload: false); scanDevices.clear(); startScanSingle(deviceName, 15, (List scanDevices) { @@ -485,18 +524,18 @@ class BlueManage { BuglyTool.uploadException( message: '提示该锁已被重置, 回调断开连接, 清除缓存,上传记录当前方法是:_connectDevice', - detail: 'isReconnect:$isReconnect serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}', - upload: false - ); + detail: + 'isReconnect:$isReconnect serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}', + upload: false); } return; } BuglyTool.uploadException( message: '从devicesList里面查到了设备 下一步连接设备 上传记录当前方法是:_connectDevice', - detail: 'devicesList:$devicesList scanResult:${scanResult.toString()} bluetoothConnectDevice:${bluetoothConnectDevice.toString()} connectDeviceMacAddress:$connectDeviceMacAddress', - upload: false - ); + detail: + 'devicesList:$devicesList scanResult:${scanResult.toString()} bluetoothConnectDevice:${bluetoothConnectDevice.toString()} connectDeviceMacAddress:$connectDeviceMacAddress', + upload: false); //连接设备 await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack); @@ -516,14 +555,13 @@ class BlueManage { BuglyTool.uploadException( message: '直接给蓝牙设备写入 上传记录当前方法是:doNotSearchBLE', detail: '直接给蓝牙设备写入 通过fromId方法创建一个BluetoothDevice masAdds:$masAdds', - upload: false - ); - }else{ + upload: false); + } else { BuglyTool.uploadException( message: '直接给蓝牙设备写入 上传记录当前方法是:doNotSearchBLE', - detail: '直接给蓝牙设备写入 用传入的bluetoothConnectDevice:${bluetoothConnectDevice.toString()}连接 masAdds:$masAdds', - upload: false - ); + detail: + '直接给蓝牙设备写入 用传入的bluetoothConnectDevice:${bluetoothConnectDevice.toString()}连接 masAdds:$masAdds', + upload: false); } //尝试连接设备 await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack, @@ -554,54 +592,60 @@ class BlueManage { AppLog.log('$maxAttempts次后尝试连接失败'); BuglyTool.uploadException( message: '连接三次超时断开连接 回调断开连接 上传记录当前方法是:bluetoothDeviceConnect', - detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} $maxAttempts次后尝试连接失败', - upload: false - ); + detail: + 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} $maxAttempts次后尝试连接失败', + upload: false); + needScanSingle = true; connectStateCallBack(BluetoothConnectionState.disconnected); } if (bluetoothConnectionState == BluetoothConnectionState.connected) { try { - final List services = await bluetoothConnectDevice.discoverServices(); + needScanSingle = false; + final List services = + await bluetoothConnectDevice.discoverServices(); //循环判断服务 for (final BluetoothService service in services) { if (service.uuid == _serviceIdConnect) { - for (final BluetoothCharacteristic characteristic in service.characteristics) { - if (characteristic.characteristicUuid == _characteristicIdSubscription) { + for (final BluetoothCharacteristic characteristic + in service.characteristics) { + if (characteristic.characteristicUuid == + _characteristicIdSubscription) { _subScribeToCharacteristic(characteristic); bluetoothConnectionState = BluetoothConnectionState.connected; connectStateCallBack(bluetoothConnectionState!); BuglyTool.uploadException( message: '订阅成功 上传记录当前方法是:bluetoothDeviceConnect', - detail: '发现服务,连接成功,订阅数据 bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} ', - upload: false - ); - } else{ + detail: + '发现服务,连接成功,订阅数据 bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} ', + upload: false); + } else { BuglyTool.uploadException( message: '订阅失败 上传记录当前方法是:bluetoothDeviceConnect', - detail: '失败原因: characteristic.characteristicUuid:${characteristic.characteristicUuid} != _characteristicIdSubscription:$_characteristicIdSubscription bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}', - upload: false - ); + detail: + '失败原因: characteristic.characteristicUuid:${characteristic.characteristicUuid} != _characteristicIdSubscription:$_characteristicIdSubscription bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}', + upload: false); } } - }else{ + } else { BuglyTool.uploadException( message: '订阅失败 上传记录当前方法是:bluetoothDeviceConnect', - detail: '失败原因: service.uuid:${service.uuid} != _serviceIdConnect:$_serviceIdConnect bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}', - upload: false - ); + detail: + '失败原因: service.uuid:${service.uuid} != _serviceIdConnect:$_serviceIdConnect bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}', + upload: false); } } } on Exception catch (e) { + needScanSingle = true; bluetoothConnectionState = BluetoothConnectionState.disconnected; connectStateCallBack(bluetoothConnectionState!); AppLog.log( '发现设备时失败 e:$e bluetoothConnectionState:$bluetoothConnectionState'); BuglyTool.uploadException( message: '发现服务时失败', - detail: '发现服务时报错原因e:$e bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}', - upload: false - ); + detail: + '发现服务时报错原因e:$e bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}', + upload: false); rethrow; } } diff --git a/lib/flavors.dart b/lib/flavors.dart index d0f8cfa6..7d5ff25a 100755 --- a/lib/flavors.dart +++ b/lib/flavors.dart @@ -133,6 +133,9 @@ class F { static StarLockAMapKey get aMapKey { switch (appFlavor) { case Flavor.local: + return const StarLockAMapKey( + androidKey: '9388ca47f9674b447a17eff82bc0e2ea', + iosKey: 'cdec0512564baa58be26b2e2ac5ef3b7'); case Flavor.dev: return const StarLockAMapKey( androidKey: 'b56b681ee89f4db43a5aa1879ae8cbfe', diff --git a/lib/login/forgetPassword/starLock_forgetPassword_logic.dart b/lib/login/forgetPassword/starLock_forgetPassword_logic.dart index c9119cdf..3566ba34 100755 --- a/lib/login/forgetPassword/starLock_forgetPassword_logic.dart +++ b/lib/login/forgetPassword/starLock_forgetPassword_logic.dart @@ -6,9 +6,11 @@ import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/login/forgetPassword/starLock_forgetPassword_state.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../network/api_repository.dart'; import '../../tools/baseGetXController.dart'; +import '../../tools/dateTool.dart'; import '../../tools/regularExpression.dart'; import '../../tools/showTipView.dart'; import '../register/entity/checkIP_entity.dart'; @@ -53,8 +55,20 @@ class StarLockForgetPasswordLogic extends BaseGetXController { 'B748F838-94EE-4BDB-A0E6-7B2D16849792', state.verificationCode.value); if (entity.errorCode!.codeIsSuccessful) { + UmengCommonSdk.onEvent('resetPassword_result', { + 'account':state.phoneStr.value, + 'date':DateTool().getNowDateWithType(1), + 'resetPassword_res':'成功', + }); + showToast('重置成功'.tr); Get.back(); + }else{ + UmengCommonSdk.onEvent('resetPassword_result', { + 'account':state.phoneStr.value, + 'date':DateTool().getNowDateWithType(1), + 'resetPassword_res':'${entity.errorCode}--${entity.errorMsg}', + }); } } diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index ae3a46e1..2b5e797e 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -8,10 +8,12 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/mine/mine/starLockMine_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../main/lockMian/lockMain/lockMain_logic.dart'; import '../../mine/mine/starLockMine_logic.dart'; import '../../network/api_repository.dart'; +import '../../tools/dateTool.dart'; import '../../tools/eventBusEventManage.dart'; import '../../tools/showTipView.dart'; import '../../tools/storage.dart'; @@ -49,6 +51,12 @@ class StarLockLoginLogic extends BaseGetXController { username: state.emailOrPhone.value, deviceInfo: state.deviceInfoMap); if (entity.errorCode!.codeIsSuccessful) { + UmengCommonSdk.onEvent('login_result', { + 'account':state.emailOrPhone.value, + 'date':DateTool().getNowDateWithType(1), + 'login_res':'成功', + }); + Storage.saveLoginData(entity.data); Storage.setBool(saveIsVip, entity.data!.isVip == 1); eventBus.fire(MineInfoChangeRefreshUI()); @@ -57,6 +65,12 @@ class StarLockLoginLogic extends BaseGetXController { } Get.offNamedUntil(Routers.starLockMain, (Route route) => false); BlueManage().scanDevices.clear(); //清除设备缓存 + }else{ + UmengCommonSdk.onEvent('login_result', { + 'account':state.emailOrPhone.value, + 'date':DateTool().getNowDateWithType(1), + 'login_res':'${entity.errorCode}--${entity.errorMsg}', + }); } } diff --git a/lib/login/register/starLock_register_logic.dart b/lib/login/register/starLock_register_logic.dart index 42ad8ce1..69a653d7 100755 --- a/lib/login/register/starLock_register_logic.dart +++ b/lib/login/register/starLock_register_logic.dart @@ -12,9 +12,11 @@ import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; import 'package:star_lock/tools/push/xs_jPhush.dart'; import 'package:star_lock/tools/storage.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../network/api_repository.dart'; import '../../tools/baseGetXController.dart'; +import '../../tools/dateTool.dart'; import '../../tools/regularExpression.dart'; import '../../tools/showTipView.dart'; import 'entity/checkIP_entity.dart'; @@ -59,12 +61,24 @@ class StarLockRegisterLogic extends BaseGetXController { verificationCode: state.verificationCode.value, deviceInfo: state.deviceInfoMap.value); if (entity.errorCode!.codeIsSuccessful) { + UmengCommonSdk.onEvent('register_result', { + 'account':state.phoneOrEmailStr.value, + 'date':DateTool().getNowDateWithType(1), + 'register_res':'成功', + }); + Storage.saveLoginData(entity.data); Storage.setBool(saveIsVip, entity.data!.isVip == 1); eventBus.fire(MineInfoChangeRefreshUI()); XSJPushProvider().initLocalNotification(isCancelLocalPush: false); Get.offNamedUntil(Routers.starLockMain, (Route route) => false); BlueManage().scanDevices.clear(); //清除设备缓存 + }else{ + UmengCommonSdk.onEvent('register_result', { + 'account':state.phoneOrEmailStr.value, + 'date':DateTool().getNowDateWithType(1), + 'register_res':'${entity.errorCode}--${entity.errorMsg}', + }); } } diff --git a/lib/main.dart b/lib/main.dart index aa07e5a9..e9dcfe0b 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,6 +17,7 @@ import 'package:star_lock/tools/platform_info_services.dart'; import 'package:star_lock/tools/push/xs_jPhush.dart'; import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/translations/trans_lib.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import 'app.dart'; import 'app_settings/app_settings.dart'; @@ -73,6 +74,9 @@ Future _setCommonServices() async { //关于隐私协议的初始化 Future privacySDKInitialization() async { + UmengCommonSdk.initCommon('671244cf80464b33f6df9648', '671244ae80464b33f6df9646', 'Product'); + UmengCommonSdk.setPageCollectionModeManual(); + await Get.putAsync(() => PlatformInfoService().init()); await BuglyTool.init(); // 初始化JPush服务 diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index 037bf443..7ffa80a6 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -13,6 +13,7 @@ import 'package:star_lock/mine/valueAddedServices/valueAddedServicesHighFunction import 'package:star_lock/tools/NativeInteractionTool.dart'; import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_transferPermissions.dart'; @@ -34,86 +35,84 @@ class AuthorizedAdminLogic extends BaseGetXController { int? keyId; // 监听设备返回的数据 - late StreamSubscription _replySubscription; - - void _initReplySubscription() { - _replySubscription = - EventBusManager().eventBus!.on().listen((Reply reply) async { - // 转移权限 - if (reply is TransferPermissionsReply) { - final List token = reply.data.sublist(2, 6); - final List saveStrList = changeIntListToStringList(token); - Storage.setStringList(saveBlueToken, saveStrList); - - final int status = reply.data[6]; - - switch (status) { - case 0x00: - //成功 - break; - case 0x06: - //无权限 - final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = - changeStringListToIntList(privateKey!); - - final List? publicKey = - await Storage.getStringList(saveBluePublicKey); - final List publicKeyDataList = - changeStringListToIntList(publicKey!); - - final List? token = - await Storage.getStringList(saveBlueToken); - final List getTokenList = changeStringListToIntList(token!); - - IoSenderManage.senderFactoryDataReset( - lockID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - keyID: '1', - needAuthor: 1, - publicKey: publicKeyDataList, - privateKey: getPrivateKeyList, - token: getTokenList); - break; - default: - break; - } - } - }); - } + // late StreamSubscription _replySubscription; + // void _initReplySubscription() { + // _replySubscription = + // EventBusManager().eventBus!.on().listen((Reply reply) async { + // // 转移权限 + // if (reply is TransferPermissionsReply) { + // final List token = reply.data.sublist(2, 6); + // final List saveStrList = changeIntListToStringList(token); + // Storage.setStringList(saveBlueToken, saveStrList); + // + // final int status = reply.data[6]; + // switch (status) { + // case 0x00: + // //成功 + // break; + // case 0x06: + // //无权限 + // final List? privateKey = + // await Storage.getStringList(saveBluePrivateKey); + // final List getPrivateKeyList = + // changeStringListToIntList(privateKey!); + // + // final List? publicKey = + // await Storage.getStringList(saveBluePublicKey); + // final List publicKeyDataList = + // changeStringListToIntList(publicKey!); + // + // final List? token = + // await Storage.getStringList(saveBlueToken); + // final List getTokenList = changeStringListToIntList(token!); + // + // IoSenderManage.senderFactoryDataReset( + // lockID: BlueManage().connectDeviceName, + // userID: await Storage.getUid(), + // keyID: '1', + // needAuthor: 1, + // publicKey: publicKeyDataList, + // privateKey: getPrivateKeyList, + // token: getTokenList); + // break; + // default: + // break; + // } + // } + // }); + // } // 转移权限 - Future transferPermissionsAction() async { - BlueManage().blueSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState state) async { - if (state == BluetoothConnectionState.connected) { - final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = - changeStringListToIntList(privateKey!); - - final List? publicKey = - await Storage.getStringList(saveBluePublicKey); - final List publicKeyDataList = - changeStringListToIntList(publicKey!); - - final List? token = await Storage.getStringList(saveBlueToken); - final List getTokenList = changeStringListToIntList(token!); - - IoSenderManage.senderTransferPermissions( - lockID: BlueManage().connectDeviceName, - authUserID: await Storage.getUid(), - keyID: '1', - oldUserID: await Storage.getUid(), - newUserID: '100002', - needAuthor: 1, - publicKey: publicKeyDataList, - privateKey: getPrivateKeyList, - token: getTokenList); - } - }); - } + // Future transferPermissionsAction() async { + // BlueManage().blueSendData(BlueManage().connectDeviceName, + // (BluetoothConnectionState state) async { + // if (state == BluetoothConnectionState.connected) { + // final List? privateKey = + // await Storage.getStringList(saveBluePrivateKey); + // final List getPrivateKeyList = + // changeStringListToIntList(privateKey!); + // + // final List? publicKey = + // await Storage.getStringList(saveBluePublicKey); + // final List publicKeyDataList = + // changeStringListToIntList(publicKey!); + // + // final List? token = await Storage.getStringList(saveBlueToken); + // final List getTokenList = changeStringListToIntList(token!); + // + // IoSenderManage.senderTransferPermissions( + // lockID: BlueManage().connectDeviceName, + // authUserID: await Storage.getUid(), + // keyID: '1', + // oldUserID: await Storage.getUid(), + // newUserID: '100002', + // needAuthor: 1, + // publicKey: publicKeyDataList, + // privateKey: getPrivateKeyList, + // token: getTokenList); + // } + // }); + // } //发送授权管理员列表请求 Future sendElectronicKeyRequest() async { @@ -223,7 +222,15 @@ class AuthorizedAdminLogic extends BaseGetXController { idCardNumber: state.isRequireAuth.value == true ? state.idCardController.text : ''); + final String getMobile = (await Storage.getMobile())!; if (entity.errorCode!.codeIsSuccessful) { + UmengCommonSdk.onEvent('add_authorizedAdmin', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_password_result':'添加授权管理员成功', + }); + state.createUser.value = 0; state.isSendSuccess.value = true; state.addUserId.value = entity.data!.receiverUser!.id.toString(); @@ -238,6 +245,13 @@ class AuthorizedAdminLogic extends BaseGetXController { state.createUser.value = 1; sendElectronicKeyRequest(); }); + }else{ + UmengCommonSdk.onEvent('add_authorizedAdmin', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_password_result':'添加授权管理员失败:${entity.errorMsg}', + }); } } } @@ -328,11 +342,11 @@ class AuthorizedAdminLogic extends BaseGetXController { void onReady() { super.onReady(); - _initReplySubscription(); + // _initReplySubscription(); } @override void onClose() { - _replySubscription.cancel(); + // _replySubscription.cancel(); } } diff --git a/lib/main/lockDetail/card/addICCard/addICCard_logic.dart b/lib/main/lockDetail/card/addICCard/addICCard_logic.dart index 5b0b96f9..8e0df9c7 100755 --- a/lib/main/lockDetail/card/addICCard/addICCard_logic.dart +++ b/lib/main/lockDetail/card/addICCard/addICCard_logic.dart @@ -7,6 +7,7 @@ import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockDetail/card/addICCard/addICCard_entity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart'; @@ -15,6 +16,7 @@ import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; import '../../../../network/api_repository.dart'; +import '../../../../tools/bugly/bugly_tool.dart'; import '../../../../tools/dateTool.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; @@ -41,6 +43,11 @@ class AddICCardLogic extends BaseGetXController{ Future _replyAddICCardBegin(Reply reply) async { final int status = reply.data[2]; + BuglyTool.uploadException( + message: '添加卡开始,解析数据', + detail: '添加卡开始,解析数据 _replyAddICCardBegin:${reply.data}', + upload: false + ); switch(status){ case 0x00: @@ -101,10 +108,24 @@ class AddICCardLogic extends BaseGetXController{ Future _replyAddICCardConfirmation(Reply reply) async { final int status = reply.data[2]; state.ifAddState.value = false; + + BuglyTool.uploadException( + message: '添加卡结果,解析数据', + detail: '添加卡结果,解析数据 _replyAddICCardConfirmation:${reply.data}', + eventStr: '添加卡事件结果', + upload: true + ); + + final String getMobile = (await Storage.getMobile())!; switch(status){ case 0x00: //成功 - //成功 + UmengCommonSdk.onEvent('add_card', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_card_result':'成功', + }); switch(reply.data[5]){ case 0xff: // 注册指纹失败 @@ -139,28 +160,69 @@ class AddICCardLogic extends BaseGetXController{ break; default: //失败 + UmengCommonSdk.onEvent('add_card', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_card_result':reply.data[2], + }); break; } } // 添加卡片 Future senderAddICCard() async { - showBlueConnetctToastTimer(action: (){ + final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List signKeyDataList = changeStringListToIntList(signKey!); + + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); + + final String command = SenderAddICCardWithTimeCycleCoercionCommand( + keyID:'1', + userID:await Storage.getUid(), + cardNo:0, + useCountLimit:0xffff, + operate:0, // 0:注册 1:修改 2:删除 3:删除全部 + isAdmin:state.isAdministrator.value == '2' ? 1 : 0, + isForce:state.isCoerced.value == '1' ? 1 : 0, // 是否是胁迫 + isRound:state.selectType.value == '2' ? 1: 0, // 是否是循环 + weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 + startDate: int.parse(state.startDate.value)~/1000, + endDate: int.parse(state.endDate.value)~/1000, + startTime:DateTool().dateToHNString(state.effectiveDateTime.value), + endTime:DateTool().dateToHNString(state.failureDateTime.value), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList, + ).toString(); + + showBlueConnetctToastTimer(action: () async { + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('add_card', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_card_result':'添加卡超时', + }); + + BuglyTool.uploadException( + message: '添加卡超时处理-添加卡失败', + detail: '添加卡超时处理,断开连接,添加卡失败--SenderAddICCardWithTimeCycleCoercionCommand:$command', + eventStr: '添加卡事件超时', + upload: true + ); + Get.close(1); }); BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ cancelBlueConnetctToastTimer(); - final List? signKey = await Storage.getStringList(saveBlueSignKey); - final List signKeyDataList = changeStringListToIntList(signKey!); - - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); - - final List? token = await Storage.getStringList(saveBlueToken); - final List getTokenList = changeStringListToIntList(token!); - IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( keyID:'1', userID:await Storage.getUid(), @@ -182,6 +244,21 @@ class AddICCardLogic extends BaseGetXController{ isBeforeAddUser: false ); } else if (deviceConnectionState == BluetoothConnectionState.disconnected){ + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('add_card', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_card_result':'添加卡断开连接', + }); + + BuglyTool.uploadException( + message: '添加卡超时处理-添加卡失败', + detail: '添加卡超时处理,断开连接,添加卡失败--SenderAddICCardWithTimeCycleCoercionCommand:$command', + eventStr: '添加卡事件断开连接', + upload: true + ); + if(state.ifCurrentScreen.value == true){ showBlueConnetctToast(); } diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index 2271ed4e..3f87c4ea 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -2,12 +2,16 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart'; import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import 'package:star_lock/tools/commonDataManage.dart'; +import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_referEventRecordTime.dart'; @@ -17,6 +21,7 @@ import '../../../blue/io_tool/manager_event_bus.dart'; import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; +import '../../../tools/bugly/bugly_tool.dart'; import '../../../tools/storage.dart'; import '../lockOperatingRecord/keyOperationRecord_entity.dart'; @@ -38,8 +43,17 @@ class DoorLockLogLogic extends BaseGetXController { // 根据时间查解析数据 Future _replyReferEventRecordTime(Reply reply) async { + BuglyTool.uploadException( + message: '查询锁记录结果,解析数据', + detail: '查询锁记录结果,解析数据:${reply.data}', + eventStr: '查询锁记录事件结果', + upload: true + ); + + state.isLockReceiveResponse = true; cancelBlueConnetctToastTimer(); final int status = reply.data[2]; + switch (status) { case 0x00: //成功 @@ -76,8 +90,8 @@ class DoorLockLogLogic extends BaseGetXController { (0xff & indexList[4]) << 16 | (0xff & indexList[5]) << 8 | (0xFF & indexList[6]); - final operateDate = time * 1000; - final serverTime = state.currentDate; + final int operateDate = time * 1000; + final int serverTime = state.currentDate; if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter( DateTime.fromMillisecondsSinceEpoch(serverTime * 1000))) { // AppLog.log('operateDate:$operateDate state.currentDate:${state.currentDate}'); @@ -100,31 +114,67 @@ class DoorLockLogLogic extends BaseGetXController { break; default: //失败 + dismissEasyLoading(); break; } } // 查询事件记录(时间查询) Future senderReferEventRecordTime() async { + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); + + final List? publicKey = await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = changeStringListToIntList(publicKey!); + + final String command = SenderReferEventRecordTimeCommand( + keyID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + logsCount: state.logCountPage, + // time:DateTime.now().millisecondsSinceEpoch~/1000, + time: state.operateDate, + currentDate: state.currentDate, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, + ).toString(); + showEasyLoading(); - showBlueConnetctToastTimer(action: () { - dismissEasyLoading(); + showBlueConnetctToastTimer(isShowBlueConnetctToast:true, action: () async { + cancelBlueConnetctToastTimer(); + + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('check_doorLockLog', { + 'lockName':state.keyInfos.value.lockName!, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'open_lock_result':'超时', + }); + + BuglyTool.uploadException( + message: '查询锁记录超时-查询锁记录失败', + detail: '添加密码超时,查询锁记录失败--senderReferEventRecordTimeCommand:$command', + eventStr: '查询锁记录事件超时', + upload: true + ); + if(state.isLockReceiveResponse == false){ + dismissEasyLoading(); + } }); - BlueManage().blueSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState connectionStateState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { if (connectionStateState == BluetoothConnectionState.connected) { - final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = - changeStringListToIntList(privateKey!); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); - final List? publicKey = - await Storage.getStringList(saveBluePublicKey); - final List getPublicKeyList = - changeStringListToIntList(publicKey!); + final List? publicKey = await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = changeStringListToIntList(publicKey!); IoSenderManage.senderReferEventRecordTimeCommand( keyID: BlueManage().connectDeviceName, @@ -138,13 +188,26 @@ class DoorLockLogLogic extends BaseGetXController { publicKey: getPublicKeyList, privateKey: getPrivateKeyList, ); - } else if (connectionStateState == - BluetoothConnectionState.disconnected) { - dismissEasyLoading(); - cancelBlueConnetctToastTimer(); + } else if (connectionStateState == BluetoothConnectionState.disconnected) { if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } + cancelBlueConnetctToastTimer(); + + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('check_doorLockLog', { + 'lockName':state.keyInfos.value.lockName!, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'open_lock_result':'断开连接', + }); + + BuglyTool.uploadException( + message: '查询锁记录超时-查询锁记录失败', + detail: '添加密码超时,查询锁记录失败--senderReferEventRecordTimeCommand:$command', + eventStr: '查询锁记录事件断开连接', + upload: true + ); } }); } @@ -174,19 +237,18 @@ class DoorLockLogLogic extends BaseGetXController { /// 刷新门锁日志列表 StreamSubscription? _getDoorLockLogListRefreshUIEvent; - void _getDoorLockLogListRefreshUIAction() { - _getDoorLockLogListRefreshUIEvent = eventBus - .on() - .listen((DoorLockLogListRefreshUI event) { + _getDoorLockLogListRefreshUIEvent = eventBus.on().listen((DoorLockLogListRefreshUI event) { state.currentSelectDate.value = event.getDoorLockLogTime; -// 设置startDate为当天的0点 + + // 设置startDate为当天的0点 state.startDate.value = DateTime( state.currentSelectDate.value.year, state.currentSelectDate.value.month, state.currentSelectDate.value.day) .millisecondsSinceEpoch; -// 设置endDate为下一天的0点,然后减去1毫秒 + + // 设置endDate为下一天的0点,然后减去1毫秒 state.endDate.value = DateTime( state.currentSelectDate.value.year, state.currentSelectDate.value.month, @@ -219,15 +281,30 @@ class DoorLockLogLogic extends BaseGetXController { if (list.isEmpty) { return; } - final KeyOperationRecordEntity entity = await ApiRepository.to - .lockRecordUploadData( - lockId: state.keyInfos.value.lockId.toString(), records: list); + final KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordUploadData(lockId: state.keyInfos.value.lockId.toString(), records: list); + final String getMobile = (await Storage.getMobile())!; if (entity.errorCode!.codeIsSuccessful) { if (state.ifHaveNext == true) { + showEasyLoading(); getLockRecordLastUploadDataTime(); } else { + UmengCommonSdk.onEvent('check_doorLockLog', { + 'lockName':state.keyInfos.value.lockName!, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'open_lock_result':'成功', + }); mockNetworkDataRequest(isRefresh: true); } + dismissEasyLoading(); + }else{ + UmengCommonSdk.onEvent('check_doorLockLog', { + 'lockName':state.keyInfos.value.lockName!, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'open_lock_result':'上传数据接口失败', + }); + dismissEasyLoading(); } } @@ -265,9 +342,10 @@ class DoorLockLogLogic extends BaseGetXController { // 获取是否是演示模式 演示模式不获取接口 final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - getLockRecordLastUploadDataTime(); - _initReplySubscription(); mockNetworkDataRequest(isRefresh: true); + + // getLockRecordLastUploadDataTime(); + _initReplySubscription(); } } diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart index 5735e012..c4c8d94c 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart @@ -88,7 +88,7 @@ class _DoorLockLogPageState extends State with RouteAware { body: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ topAdvancedCalendarWidget(), Divider( height: 1, @@ -126,6 +126,17 @@ class _DoorLockLogPageState extends State with RouteAware { }else if(value == '清空记录'.tr){ ShowCupertinoAlertView().showClearOperationRecordAlert( clearClick: () { + switch (value) { + case '读取记录': + { + state.isLockReceiveResponse = false; + logic.getLockRecordLastUploadDataTime(); + } + break; + case '清空记录': + { + ShowCupertinoAlertView().showClearOperationRecordAlert( + clearClick: () { logic.clearOperationRecordRequest(); }); }else if(value == '导出记录'.tr){ @@ -198,7 +209,7 @@ class _DoorLockLogPageState extends State with RouteAware { disabledColor: Colors.grey, ), child: Stack( - children: [ + children: [ AdvancedCalendar( controller: state.calendarControllerCustom, events: state.events, @@ -384,7 +395,9 @@ class _DoorLockLogPageState extends State with RouteAware { void didPop() { super.didPop(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart index 20c2f98c..722e605e 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart @@ -68,4 +68,5 @@ class DoorLockLogState { bool ifHaveNext = false; // 页码 int logCountPage = 10; // 蓝牙记录一页多少个 Rx currentSelectDate = DateTime.now().obs; + bool isLockReceiveResponse = false; // 是否收到回复 } diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart index 76e2a730..e7eb9336 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart @@ -17,6 +17,9 @@ import 'package:star_lock/tools/regularExpression.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/showTipView.dart'; import 'package:star_lock/tools/storage.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; + +import '../../../../../../blue/blue_manage.dart'; class SendElectronicKeyViewLogic extends BaseGetXController { SendElectronicKeyViewLogic(this.type); @@ -180,7 +183,15 @@ class SendElectronicKeyViewLogic extends BaseGetXController { idCardNumber: state.isRequireAuth.value == true ? state.idCardController.text : ''); + final String getMobile = (await Storage.getMobile())!; if (entity.errorCode!.codeIsSuccessful) { + UmengCommonSdk.onEvent('add_electronic_key', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_electronic_key_result':'成功', + }); + emailOrPhone = state.emailOrPhoneController.text; state.createUser.value = 0; state.isSendSuccess = true; @@ -190,6 +201,13 @@ class SendElectronicKeyViewLogic extends BaseGetXController { update(); eventBus.fire(ElectronicKeyListRefreshUI()); } else { + UmengCommonSdk.onEvent('add_electronic_key', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_electronic_key_result':'${entity.errorCode}--${entity.errorMsg}', + }); + emailOrPhone = null; if (entity.errorCode == 425) { //用户未注册 diff --git a/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart b/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart index f2c187b2..b657a491 100755 --- a/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart +++ b/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart @@ -3,9 +3,11 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockDetail/fingerprint/addFingerprint/addFingerprint_entity.dart'; import 'package:star_lock/tools/dateTool.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../../../../blue/blue_manage.dart'; import '../../../../../blue/io_reply.dart'; @@ -17,6 +19,7 @@ import '../../../../../tools/baseGetXController.dart'; import '../../../../../tools/eventBusEventManage.dart'; import '../../../../../tools/storage.dart'; import '../../../../blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart'; +import '../../../../tools/bugly/bugly_tool.dart'; import 'addFingerprint_state.dart'; class AddFingerprintLogic extends BaseGetXController { @@ -44,8 +47,13 @@ class AddFingerprintLogic extends BaseGetXController { } Future _replyAddFingerprintBegin(Reply reply) async { - final int status = reply.data[2]; + BuglyTool.uploadException( + message: '添加指纹开始,解析数据', + detail: '添加指纹开始,解析数据 _replyAddFingerprintBegin:${reply.data}', + upload: false + ); + final int status = reply.data[2]; switch(status){ case 0x00: //成功 @@ -102,8 +110,12 @@ class AddFingerprintLogic extends BaseGetXController { } Future _replyAddFingerprintProcess(Reply reply) async { + BuglyTool.uploadException( + message: '添加指纹过程,解析数据', + detail: '添加指纹过程,解析数据 _replyAddFingerprintProcess:${reply.data}', + upload: false + ); final int status = reply.data[2]; - switch(status){ case 0x00: //成功 @@ -154,13 +166,27 @@ class AddFingerprintLogic extends BaseGetXController { Future _replyAddFingerprintConfirmation(Reply reply) async { final int status = reply.data[2]; + final String getMobile = (await Storage.getMobile())!; switch(status){ case 0x00: //成功 // var fingerprintNum = listChangInt(reply.data.sublist(9, 11)).toString(); - final List fingerprintList = reply.data.sublist(reply.data.length - 2); - final String fingerprintNum = listChangInt(fingerprintList).toString(); - state.regIndex.value++; + UmengCommonSdk.onEvent('add_fingerprint', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_fingerprint_result':'成功', + }); + + BuglyTool.uploadException( + message: '添加指纹确认结果,解析数据', + detail: '添加指纹确认结果,解析数据 _replyAddFingerprintConfirmation:${reply.data}', + upload: false + ); + + final List fingerprintList = reply.data.sublist(reply.data.length - 2); + final String fingerprintNum = listChangInt(fingerprintList).toString(); + state.regIndex.value++; if(state.fingerprintNumber.value == fingerprintNum){ return; }else{ @@ -177,6 +203,19 @@ class AddFingerprintLogic extends BaseGetXController { break; default: //失败 + UmengCommonSdk.onEvent('add_fingerprint', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_fingerprint_result':'失败-${reply.data}', + }); + + BuglyTool.uploadException( + message: '添加指纹确认结果,解析数据', + detail: '添加指纹确认结果蓝牙返回失败结果,解析数据 _replyAddFingerprintConfirmation:${reply.data}', + eventStr: '添加指纹事件蓝牙返回失败结果', + upload: true + ); state.ifAddState.value = false; break; } @@ -184,7 +223,50 @@ class AddFingerprintLogic extends BaseGetXController { // 添加指纹开始 Future senderAddFingerprint() async { - showBlueConnetctToastTimer(action: (){ + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List signKeyDataList = changeStringListToIntList(signKey!); + + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); + + final String command = SenderAddFingerprintWithTimeCycleCoercionCommand( + keyID:'1', + userID:await Storage.getUid(), + fingerNo:0, + useCountLimit:0xffff, + isForce:state.isCoerced.value == '1' ? 1 : 0, // 是否是胁迫 + isAdmin: state.isAdministrator.value == '2' ? 1 : 0, + operate: 0, + isRound:state.selectType.value == '2' ? 1: 0, // 是否是循环 + weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 + startDate: int.parse(state.startDate.value)~/1000, + endDate: int.parse(state.endDate.value)~/1000, + startTime:DateTool().dateToHNString(state.effectiveDateTime.value), + endTime:DateTool().dateToHNString(state.failureDateTime.value), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList, + ).toString(); + + showBlueConnetctToastTimer(action: () async { + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('add_fingerprint', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_fingerprint_result':'超时', + }); + + BuglyTool.uploadException( + message: '添加指纹超时处理-添加指纹失败', + detail: '添加指纹超时处理,断开连接,添加指纹失败--SenderAddFingerprintWithTimeCycleCoercionCommand:$command', + eventStr: '添加指纹事件超时', + upload: true + ); Get.close(1); }); BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { @@ -219,6 +301,21 @@ class AddFingerprintLogic extends BaseGetXController { isBeforeAddUser: false ); }else if (deviceConnectionState == BluetoothConnectionState.disconnected){ + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('add_fingerprint', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_fingerprint_result':'断开', + }); + + BuglyTool.uploadException( + message: '添加指纹断开连接-添加指纹失败', + detail: '添加指纹断开连接-添加指纹失败--SenderAddFingerprintWithTimeCycleCoercionCommand:$command', + eventStr: '添加指纹事件断开连接', + upload: true + ); + if(state.ifCurrentScreen.value == true){ showBlueConnetctToast(); } @@ -277,6 +374,20 @@ class AddFingerprintLogic extends BaseGetXController { ); if(entity.errorCode!.codeIsSuccessful){ updateFingerprintUserNoLoadData(entity.data!.fingerprintId.toString()); + BuglyTool.uploadException( + message: '添加指纹调用接口成功', + detail: '添加指纹调用接口成功', + eventStr: '添加指纹事件用接口成功', + upload: true + ); + }else{ + updateFingerprintUserNoLoadData(entity.data!.fingerprintId.toString()); + BuglyTool.uploadException( + message: '添加指纹调用接口失败', + detail: '添加指纹调用接口添加指纹调用接口失败 - ${entity.errorMsg}', + eventStr: '添加指纹事件接口失败', + upload: true + ); } } diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 48af4620..56ba98ed 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -14,6 +14,7 @@ import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import 'package:star_lock/tools/bugly/bugly_tool.dart'; import 'package:star_lock/tools/throttler.dart'; import 'package:star_lock/widget/permission/permission_dialog.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../../app_settings/app_settings.dart'; import '../../../blue/blue_manage.dart'; @@ -26,6 +27,7 @@ import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/commonDataManage.dart'; +import '../../../tools/dateTool.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; import '../lockOperatingRecord/keyOperationRecord_entity.dart'; @@ -67,6 +69,16 @@ class LockDetailLogic extends BaseGetXController { detail: '开锁结果,解析数据 _replyOpenLock:${reply.data}', upload: true); + if(status != 6){ + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('open_lock', { + 'lock_name':state.keyInfos.value.lockName!, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'open_lock_result':'${reply.data}', + }); + } + switch (status) { case 0x00: //成功 @@ -363,7 +375,15 @@ class LockDetailLogic extends BaseGetXController { showBlueConnetctToastTimer( outTimer: 20, - action: () { + action: () async { + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('open_lock', { + 'lock_name':state.keyInfos.value.lockName!, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'open_lock_result':'超时', + }); + resetOpenDoorState(); blueManageDisconnect(); BuglyTool.uploadException( @@ -399,6 +419,16 @@ class LockDetailLogic extends BaseGetXController { message: '蓝牙连接失败-开锁失败', detail: '蓝牙连接失败,断开连接, 开锁失败--OpenLockCommand:$command', upload: true); + upload: true + ); + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('open_lock', { + 'lock_name':state.keyInfos.value.lockName!, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'open_lock_result':'断开连接', + }); + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index 6375d6cd..892636ca 100755 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -22,129 +22,129 @@ class LockOperatingRecordLogic extends BaseGetXController { LockOperatingRecordState state = LockOperatingRecordState(); // 获取解析后的数据 - late StreamSubscription _replySubscription; + // late StreamSubscription _replySubscription; - void _initReplySubscription() { - _replySubscription = - EventBusManager().eventBus!.on().listen((Reply reply) { - if (reply is SenderReferEventRecordTimeReply) { - _replyReferEventRecordTime(reply); - } - }); - } + // void _initReplySubscription() { + // _replySubscription = + // EventBusManager().eventBus!.on().listen((Reply reply) { + // if (reply is SenderReferEventRecordTimeReply) { + // _replyReferEventRecordTime(reply); + // } + // }); + // } // 根据时间查解析数据 - Future _replyReferEventRecordTime(Reply reply) async { - cancelBlueConnetctToastTimer(); - final int status = reply.data[2]; - switch (status) { - case 0x00: - //成功 - final int dataLength = (reply.data[5] << 8) + reply.data[6]; - AppLog.log('dataLength:$dataLength'); - // var dataLength = reply.data[5]; - if (dataLength > 0) { - reply.data.removeRange(0, 7); - // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 - if (reply.data.length < 17) { - return; - } - final List> getList = splitList(reply.data, 17); - // AppLog.log("getList:$getList"); - final List uploadList = []; - for (int i = 0; i < getList.length; i++) { - final List indexList = getList[i]; - // AppLog.log("indexList:$indexList"); - final Map indexMap = {}; - - indexMap['type'] = indexList[0].toString(); - - final int userNo = (indexList[1] * 256) + indexList[2]; - indexMap['user'] = userNo.toString(); - // AppLog.log('userNouserNouserNouserNo:$userNo'); - - final List passwordData = indexList.sublist(7, 17); - final String password = utf8String(passwordData); - indexMap['password'] = password.toString(); - // AppLog.log('passwordpasswordpassword:$password'); - - indexMap['success'] = '1'; - - final int time = (0xff & indexList[3]) << 24 | - (0xff & indexList[4]) << 16 | - (0xff & indexList[5]) << 8 | - (0xFF & indexList[6]); - final operateDate = time * 1000; - final serverTime = state.currentDate; - if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter( - DateTime.fromMillisecondsSinceEpoch(serverTime * 1000))) { - continue; - } - indexMap['date'] = '$operateDate'; - uploadList.add(indexMap); - } - if (dataLength == state.logCountPage) { - state.ifHaveNext = true; - } else { - state.ifHaveNext = false; - } - lockRecordUploadData(uploadList); - } - break; - case 0x06: - //无权限 需要鉴权 - - break; - default: - //失败 - break; - } - } + // Future _replyReferEventRecordTime(Reply reply) async { + // cancelBlueConnetctToastTimer(); + // final int status = reply.data[2]; + // switch (status) { + // case 0x00: + // //成功 + // final int dataLength = (reply.data[5] << 8) + reply.data[6]; + // AppLog.log('dataLength:$dataLength'); + // // var dataLength = reply.data[5]; + // if (dataLength > 0) { + // reply.data.removeRange(0, 7); + // // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 + // if (reply.data.length < 17) { + // return; + // } + // final List> getList = splitList(reply.data, 17); + // // AppLog.log("getList:$getList"); + // final List uploadList = []; + // for (int i = 0; i < getList.length; i++) { + // final List indexList = getList[i]; + // // AppLog.log("indexList:$indexList"); + // final Map indexMap = {}; + // + // indexMap['type'] = indexList[0].toString(); + // + // final int userNo = (indexList[1] * 256) + indexList[2]; + // indexMap['user'] = userNo.toString(); + // AppLog.log('userNouserNouserNouserNo:$userNo'); + // + // final List passwordData = indexList.sublist(7, 17); + // final String password = utf8String(passwordData); + // indexMap['password'] = password.toString(); + // AppLog.log('passwordpasswordpassword:$password'); + // + // indexMap['success'] = '1'; + // + // final int time = (0xff & indexList[3]) << 24 | + // (0xff & indexList[4]) << 16 | + // (0xff & indexList[5]) << 8 | + // (0xFF & indexList[6]); + // final operateDate = time * 1000; + // final serverTime = state.currentDate; + // if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter( + // DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) { + // continue; + // } + // indexMap['date'] = '$operateDate'; + // uploadList.add(indexMap); + // } + // if (dataLength == state.logCountPage) { + // state.ifHaveNext = true; + // } else { + // state.ifHaveNext = false; + // } + // lockRecordUploadData(uploadList); + // } + // break; + // case 0x06: + // //无权限 需要鉴权 + // + // break; + // default: + // //失败 + // break; + // } + // } // 查询事件记录(时间查询) - Future senderReferEventRecordTime() async { - showEasyLoading(); - showBlueConnetctToastTimer(action: () { - dismissEasyLoading(); - }); - BlueManage().blueSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState connectionStateState) async { - if (connectionStateState == BluetoothConnectionState.connected) { - final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = - changeStringListToIntList(privateKey!); - - final List? token = await Storage.getStringList(saveBlueToken); - final List getTokenList = changeStringListToIntList(token!); - - final List? publicKey = - await Storage.getStringList(saveBluePublicKey); - final List getPublicKeyList = - changeStringListToIntList(publicKey!); - - IoSenderManage.senderReferEventRecordTimeCommand( - keyID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - logsCount: state.logCountPage, - // time:DateTime.now().millisecondsSinceEpoch~/1000, - time: state.operateDate, - currentDate: state.currentDate, - token: getTokenList, - needAuthor: 1, - publicKey: getPublicKeyList, - privateKey: getPrivateKeyList, - ); - } else if (connectionStateState == - BluetoothConnectionState.disconnected) { - dismissEasyLoading(); - cancelBlueConnetctToastTimer(); - if (state.ifCurrentScreen.value == true) { - showBlueConnetctToast(); - } - } - }); - } + // Future senderReferEventRecordTime() async { + // showEasyLoading(); + // showBlueConnetctToastTimer(action: () { + // dismissEasyLoading(); + // }); + // BlueManage().blueSendData(BlueManage().connectDeviceName, + // (BluetoothConnectionState connectionStateState) async { + // if (connectionStateState == BluetoothConnectionState.connected) { + // final List? privateKey = + // await Storage.getStringList(saveBluePrivateKey); + // final List getPrivateKeyList = + // changeStringListToIntList(privateKey!); + // + // final List? token = await Storage.getStringList(saveBlueToken); + // final List getTokenList = changeStringListToIntList(token!); + // + // final List? publicKey = + // await Storage.getStringList(saveBluePublicKey); + // final List getPublicKeyList = + // changeStringListToIntList(publicKey!); + // + // IoSenderManage.senderReferEventRecordTimeCommand( + // keyID: BlueManage().connectDeviceName, + // userID: await Storage.getUid(), + // logsCount: state.logCountPage, + // // time:DateTime.now().millisecondsSinceEpoch~/1000, + // time: state.operateDate, + // currentDate: state.currentDate, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList, + // ); + // } else if (connectionStateState == + // BluetoothConnectionState.disconnected) { + // dismissEasyLoading(); + // cancelBlueConnetctToastTimer(); + // if (state.ifCurrentScreen.value == true) { + // showBlueConnetctToast(); + // } + // } + // }); + // } //请求操作记录列表 Future mockNetworkDataRequest() async { @@ -181,48 +181,48 @@ class LockOperatingRecordLogic extends BaseGetXController { } // 查询锁记录最后时间 - Future getLockRecordLastUploadDataTime() async { - final LockOperatingRecordGetLastRecordTimeEntity entity = - await ApiRepository.to.getLockRecordLastUploadDataTime( - lockId: CommonDataManage().currentKeyInfo.lockId.toString()); - if (entity.errorCode!.codeIsSuccessful) { - state.operateDate = entity.data!.operateDate! ~/ 1000; - state.currentDate = entity.data!.currentDate! ~/ 1000; - senderReferEventRecordTime(); - } - } + // Future getLockRecordLastUploadDataTime() async { + // final LockOperatingRecordGetLastRecordTimeEntity entity = + // await ApiRepository.to.getLockRecordLastUploadDataTime( + // lockId: CommonDataManage().currentKeyInfo.lockId.toString()); + // if (entity.errorCode!.codeIsSuccessful) { + // state.operateDate = entity.data!.operateDate! ~/ 1000; + // state.currentDate = entity.data!.currentDate! ~/ 1000; + // senderReferEventRecordTime(); + // } + // } // 操作记录上传 - Future lockRecordUploadData(List list) async { - if (list.isEmpty) { - return; - } - final KeyOperationRecordEntity entity = await ApiRepository.to - .lockRecordUploadData( - lockId: CommonDataManage().currentKeyInfo.lockId.toString(), - records: list); - if (entity.errorCode!.codeIsSuccessful) { - if (state.ifHaveNext == true) { - getLockRecordLastUploadDataTime(); - } else { - pageNo = 1; - mockNetworkDataRequest(); - } - } - } + // Future lockRecordUploadData(List list) async { + // if(list.isEmpty){ + // return; + // } + // final KeyOperationRecordEntity entity = await ApiRepository.to + // .lockRecordUploadData( + // lockId: CommonDataManage().currentKeyInfo.lockId.toString(), + // records: list); + // if (entity.errorCode!.codeIsSuccessful) { + // if (state.ifHaveNext == true) { + // getLockRecordLastUploadDataTime(); + // } else { + // pageNo = 1; + // mockNetworkDataRequest(); + // } + // } + // } //清空操作记录 - Future clearOperationRecordRequest() async { - final KeyOperationRecordEntity entity = await ApiRepository.to - .clearOperationRecord( - CommonDataManage().currentKeyInfo.lockId.toString()); - if (entity.errorCode!.codeIsSuccessful) { - showToast('清除数据成功'.tr, something: () { - pageNo = 1; - mockNetworkDataRequest(); - }); - } - } + // Future clearOperationRecordRequest() async { + // final KeyOperationRecordEntity entity = await ApiRepository.to + // .clearOperationRecord( + // CommonDataManage().currentKeyInfo.lockId.toString()); + // if (entity.errorCode!.codeIsSuccessful) { + // showToast('清除数据成功', something: () { + // pageNo = 1; + // mockNetworkDataRequest(); + // }); + // } + // } @override Future onReady() async { @@ -245,10 +245,10 @@ class LockOperatingRecordLogic extends BaseGetXController { // 获取是否是演示模式 演示模式不获取接口 final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - getLockRecordLastUploadDataTime(); + // getLockRecordLastUploadDataTime(); // senderReferEventRecordTime(); // senderReferEventRecordNumber(); - _initReplySubscription(); + // _initReplySubscription(); } } @@ -259,7 +259,7 @@ class LockOperatingRecordLogic extends BaseGetXController { //获取是否是演示模式 演示模式不获取接口 final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - _replySubscription.cancel(); + // _replySubscription.cancel(); // _getDoorLockLogListRefreshUIEvent?.cancel(); } } diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart index d653af5f..cd346e51 100755 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart @@ -84,6 +84,29 @@ class _LockOperatingRecordPageState extends State with }, child: Column( children: [ + // (CommonDataManage().currentKeyInfo.isLockOwner == 1 || + // CommonDataManage().currentKeyInfo.keyRight == 1) + // ? Column( + // children: [ + // Container( + // padding: EdgeInsets.only(left:20.h, right: 20.h, top: 20.h), + // child: Text( + // TranslationLoader.lanKeys!.lockOperatingRecordTip!.tr, + // textAlign: TextAlign.start, + // style: TextStyle(fontSize: 20.sp), + // ), + // ), + // KeySearchWidget( + // editingController: state.searchController, + // onSubmittedAction: () { + // logic.pageNo = 1; + // getHttpData(); + // }, + // ), + // ], + // ) + // : Container(), + // SizedBox(height: 10.h), Expanded(child: _buildMainUI()), ], ), @@ -275,7 +298,6 @@ class _LockOperatingRecordPageState extends State with @override void didChangeDependencies() { super.didChangeDependencies(); - /// 路由订阅 AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); } @@ -299,7 +321,9 @@ class _LockOperatingRecordPageState extends State with void didPop() { super.didPop(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } @@ -315,7 +339,9 @@ class _LockOperatingRecordPageState extends State with void didPushNext() { super.didPushNext(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } diff --git a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart index ec901d63..2d5e576a 100755 --- a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart +++ b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart @@ -6,6 +6,7 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_factoryDataReset.dart'; @@ -19,6 +20,7 @@ import '../../../../blue/sender_manage.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; import '../../../../tools/commonDataManage.dart'; +import '../../../../tools/dateTool.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; import 'checkingInInfoData_entity.dart'; @@ -287,7 +289,16 @@ class LockSetLogic extends BaseGetXController { showEasyLoading(); showBlueConnetctToastTimer( isShowBlueConnetctToast: false, - action: () { + action: () async { + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('delet_lock', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'delet_type':'lock', + 'delet_lock_result':'删除锁超时', + }); + dismissEasyLoading(); showDeletAlertTipDialog(); }); @@ -316,6 +327,15 @@ class LockSetLogic extends BaseGetXController { privateKey: getPrivateKeyList, token: getTokenList); } else if (connectionState == BluetoothConnectionState.disconnected) { + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('delet_lock', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'delet_type':'lock', + 'delet_lock_result':'删除锁断开', + }); + dismissEasyLoading(); cancelBlueConnetctToastTimer(); if (state.ifCurrentScreen.value == true) { @@ -568,7 +588,16 @@ class LockSetLogic extends BaseGetXController { final LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData( lockId: state.lockSetInfoData.value.lockId!, ); + final String getMobile = (await Storage.getMobile())!; if (entity.errorCode!.codeIsSuccessful) { + UmengCommonSdk.onEvent('delet_lock', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'delet_type':'lock', + 'delet_lock_result':'成功', + }); + BlueManage().connectDeviceMacAddress = ''; final bool isOnlyOneData = state.isOnlyOneData.value == true; await Future.delayed(const Duration(milliseconds: 200)) @@ -578,6 +607,14 @@ class LockSetLogic extends BaseGetXController { SchedulerBinding.instance.addPostFrameCallback((_) { eventBus.fire(RefreshLockListInfoDataEvent()); }); + }else{ + UmengCommonSdk.onEvent('delet_lock', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'delet_type':'lock', + 'delet_lock_result':'${entity.errorCode}--${entity.errorMsg}', + }); } } @@ -588,7 +625,16 @@ class LockSetLogic extends BaseGetXController { keyId: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0); + final String getMobile = (await Storage.getMobile())!; if (entity.errorCode!.codeIsSuccessful) { + UmengCommonSdk.onEvent('delet_lock', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'delet_type':'key', + 'delet_lock_result':'成功', + }); + BlueManage().connectDeviceMacAddress = ''; final bool isOnlyOneData = state.isOnlyOneData.value == true; await Future.delayed(const Duration(milliseconds: 200)) @@ -598,6 +644,14 @@ class LockSetLogic extends BaseGetXController { SchedulerBinding.instance.addPostFrameCallback((_) { eventBus.fire(RefreshLockListInfoDataEvent()); }); + }else{ + UmengCommonSdk.onEvent('delet_lock', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'delet_type':'key', + 'delet_lock_result':'${entity.errorCode}--${entity.errorMsg}', + }); } } diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index 610912a4..3c9e006e 100755 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -6,6 +6,7 @@ import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/pass import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_modelVendor.dart'; @@ -15,6 +16,7 @@ import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; import '../../../../tools/baseGetXController.dart'; +import '../../../../tools/bugly/bugly_tool.dart'; import '../../../../tools/commonDataManage.dart'; import '../../../../tools/dateTool.dart'; import '../../../../tools/storage.dart'; @@ -178,7 +180,15 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { endDate: getFailureDateTime, addType: '1', pwdRight: state.isAdministrator.value == true ? 1 : 0); + final String getMobile = (await Storage.getMobile())!; if (entity.errorCode!.codeIsSuccessful) { + UmengCommonSdk.onEvent('add_password', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_password_result':'成功', + }); + state.isSendSuccess.value = true; state.sendSucceedType.value = state.widgetType.value; state.pwdNameStr = state.nameController.text; @@ -189,6 +199,12 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { updatePWDNumberRequest(entity.data!.keyboardPwdId.toString()); } } else { + UmengCommonSdk.onEvent('add_password', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_password_result':'${entity.errorMsg}', + }); showToast('${entity.errorMsg}'); } } @@ -228,11 +244,16 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = - EventBusManager().eventBus!.on().listen((Reply reply) async { + _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) async { // 设置自定义密码 - if ((reply is SenderCustomPasswordsReply) && - (state.ifCurrentScreen.value == true)) { + if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) { + BuglyTool.uploadException( + message: '添加密码结果,解析数据', + detail: '添加密码结果,解析数据:${reply.data}', + eventStr: '添加密码事件结果', + upload: true + ); + final int status = reply.data[2]; switch (status) { case 0x00: @@ -369,22 +390,60 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { } state.sureBtnState.value = 1; + final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List signKeyDataList = changeStringListToIntList(signKey!); + + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); + + final String command = SenderCustomPasswordsCommand( + keyID: '1', + userID: await Storage.getUid(), + pwdNo: 0, + pwd: state.pwdController.text, + operate: 0, + isAdmin: state.isAdministrator.value == true ? 1 : 0, + useCountLimit: 0xffff, + startTime: startDate ~/ 1000, + endTime: endDate ~/ 1000, + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList + ).toString(); + + showEasyLoading(); - showBlueConnetctToastTimer(action: () { + showBlueConnetctToastTimer(action: () async { + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('add_password', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_password_result':'添加自定义密码超时', + }); + + BuglyTool.uploadException( + message: '添加密码超时处理-添加密码失败', + detail: '添加密码超时,添加密码失败--senderCustomPasswordsCommand:$command', + eventStr: '添加密码事件超时', + upload: true + ); + dismissEasyLoading(); state.sureBtnState.value = 0; }); BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - final List? signKey = - await Storage.getStringList(saveBlueSignKey); + final List? signKey = await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); - final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = - changeStringListToIntList(privateKey!); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); @@ -404,8 +463,22 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { signKey: signKeyDataList, privateKey: getPrivateKeyList, token: getTokenList); - } else if (deviceConnectionState == - BluetoothConnectionState.disconnected) { + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('add_password', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'add_password_result':'添加自定义密码断开', + }); + + BuglyTool.uploadException( + message: '添加密码断开-添加密码失败', + detail: '添加密码断开,添加密码失败--senderCustomPasswordsCommand:$command', + eventStr: '添加密码事件断开连接', + upload: true + ); + dismissEasyLoading(); cancelBlueConnetctToastTimer(); state.sureBtnState.value = 0; diff --git a/lib/mine/addLock/saveLock/saveLock_logic.dart b/lib/mine/addLock/saveLock/saveLock_logic.dart index 68232ed1..2074d793 100755 --- a/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -6,6 +6,7 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart'; import 'package:star_lock/mine/addLock/saveLock/entity/SaveLockEntity.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../../app_settings/app_settings.dart'; import '../../../blue/blue_manage.dart'; @@ -17,6 +18,7 @@ import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/commonDataManage.dart'; +import '../../../tools/dateTool.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; import 'saveLock_state.dart'; @@ -404,8 +406,14 @@ class SaveLockLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { state.lockId = entity.data!.lockId!; + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('save_lock_result', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'save_lock_result':'成功', + }); backAction(); - // await senderCustomPasswords(); // BlueManage().disconnect(BlueManage().connectDeviceMacAddress); @@ -413,6 +421,14 @@ class SaveLockLogic extends BaseGetXController { // Get.close(state.isFromMap == 1 ? 5 : 6); } else { state.sureBtnState.value = 0; + + final String getMobile = (await Storage.getMobile())!; + UmengCommonSdk.onEvent('save_lock_result', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'save_lock_result':'${entity.errorCode}--${entity.errorMsg}', + }); } } diff --git a/lib/mine/mineSet/mineSet/mineSet_logic.dart b/lib/mine/mineSet/mineSet/mineSet_logic.dart index 616e0ccd..78839b76 100755 --- a/lib/mine/mineSet/mineSet/mineSet_logic.dart +++ b/lib/mine/mineSet/mineSet/mineSet_logic.dart @@ -13,12 +13,14 @@ import 'package:star_lock/tools/push/xs_jPhush.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/versionUndate/versionUndate_entity.dart'; +import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; import '../../../app_settings/app_settings.dart'; import '../../../blue/blue_manage.dart'; import '../../../talk/udp/udp_help.dart'; +import '../../../tools/dateTool.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/store_service.dart'; import '../../../translations/app_dept.dart'; @@ -130,7 +132,15 @@ class MineSetLogic extends BaseGetXController { }); final LoginEntity entity = await ApiRepository.to.userLogout(deviceld: getPushDeviceID); + final String getMobile = (await Storage.getMobile())!; if (entity.errorCode!.codeIsSuccessful) { + UmengCommonSdk.onEvent('logout', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'logout_result':'成功', + }); + UdpHelp().closeUDP(); logOut(); @@ -140,6 +150,13 @@ class MineSetLogic extends BaseGetXController { BlueManage().disconnect(); XSJPushProvider().initLocalNotification(isCancelLocalPush: true); Get.offNamedUntil(Routers.starLockLoginPage, (Route route) => false); + }else{ + UmengCommonSdk.onEvent('logout', { + 'lock_name':BlueManage().connectDeviceName, + 'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date':DateTool().getNowDateWithType(1), + 'logout_result':'${entity.errorCode}--${entity.errorMsg}', + }); } } diff --git a/lib/tools/advancedCalendar/src/widget.dart b/lib/tools/advancedCalendar/src/widget.dart index 702b32e6..57d42a23 100755 --- a/lib/tools/advancedCalendar/src/widget.dart +++ b/lib/tools/advancedCalendar/src/widget.dart @@ -232,9 +232,8 @@ class _AdvancedCalendarState extends State height: height, child: ValueListenableBuilder( valueListenable: _controller, - builder: (_, DateTime selectedDate, __) { - AppLog.log('****selectedDate: $selectedDate'); - eventBus.fire(DoorLockLogListRefreshUI(selectedDate)); + builder: (_, selectedDate, __) { + // AppLog.log('****selectedDate: $selectedDate'); return Stack( alignment: Alignment.center, children: [ @@ -253,6 +252,7 @@ class _AdvancedCalendarState extends State ); } _monthViewCurrentPage.value = pageIndex; + AppLog.log('调用onPageChanged'); }, controller: _monthPageController, physics: _animationController.value == 1.0 @@ -390,6 +390,8 @@ class _AdvancedCalendarState extends State void _handleDateChanged(DateTime date) { _controller.value = date; + AppLog.log('点击日期了'); + eventBus.fire(DoorLockLogListRefreshUI(date)); } void _handleFinishDrag() async { diff --git a/lib/tools/bugly/bugly_tool.dart b/lib/tools/bugly/bugly_tool.dart index bbefa239..35869076 100644 --- a/lib/tools/bugly/bugly_tool.dart +++ b/lib/tools/bugly/bugly_tool.dart @@ -65,6 +65,7 @@ class BuglyTool { required String message, required String detail, required bool upload, + String eventStr = '开门事件', bool begin = false, Map? data, }) async { @@ -80,7 +81,7 @@ class BuglyTool { // AppLog.log('message:${(await Storage.getMobile())!.isNotEmpty ? (await Storage.getMobile()) : (await Storage.getEmail())}+$time --- 开门事件 detail:$uploadStr'); // FlutterBugly.uploadException(message: '${(await Storage.getMobile())!.isNotEmpty ? (await Storage.getMobile()) : (await Storage.getEmail())}+$time --- 开门事件', detail: uploadStr, data: data); - BuglyTool.uploadExceptionWithEvent(eventStr:'开门事件', detail: uploadStr); + BuglyTool.uploadExceptionWithEvent(eventStr:eventStr, detail: uploadStr); } } diff --git a/pubspec.yaml b/pubspec.yaml index 0a06bdb2..4bb9af7b 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -100,6 +100,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.79+2024083001:测试所有国家国际化功能 # 1.0.79+2024083001:测试开完锁数据上传功能 # 1.0.81+2024092901:添加开锁数据收集功能 +# 1.0.82+2024093001:优化开锁数据收集功能 # 1.0.85+2024120301:完善网关功能 # 1.0.85+2024120401:修复网关问题,打包给谢敬调试 @@ -238,7 +239,7 @@ dependencies: # audio_service: ^0.18.12 app_settings: ^5.1.1 flutter_local_notifications: ^17.0.0 - fluwx: ^4.5.5 + fluwx: 4.5.5 system_settings: ^2.0.0 expandable: ^5.0.1 colorfilter_generator: ^0.0.8 @@ -248,6 +249,7 @@ dependencies: flutter_bugly: ^1.0.2 open_filex: ^4.4.0 + umeng_common_sdk: 1.2.7 dependency_overrides: #强制设置google_maps_flutter_ios 为 2.5.2