1、优化bugly数据上报到一条数据上
2、添加蓝牙权限、定位权限数据上报
This commit is contained in:
parent
9336e83434
commit
ebc9b677ab
BIN
ios/.DS_Store
vendored
BIN
ios/.DS_Store
vendored
Binary file not shown.
@ -149,8 +149,10 @@ class BlueManage {
|
|||||||
if (_adapterState == BluetoothAdapterState.on) {
|
if (_adapterState == BluetoothAdapterState.on) {
|
||||||
try {
|
try {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'startScanSingle:$deviceName',
|
message: '开始指定设备名称的扫描蓝牙设备',
|
||||||
detail: 'startScanSingle$deviceName 开始指定设备名称的扫描蓝牙设备');
|
detail: '调用方法是:startScanSingle 指定设备名称是:$deviceName',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
//android 扫描比较慢,取样只要 3 分之一
|
//android 扫描比较慢,取样只要 3 分之一
|
||||||
final int divisor = Platform.isAndroid ? 3 : 1;
|
final int divisor = Platform.isAndroid ? 3 : 1;
|
||||||
FlutterBluePlus.startScan(
|
FlutterBluePlus.startScan(
|
||||||
@ -169,8 +171,10 @@ class BlueManage {
|
|||||||
AppLog.log(
|
AppLog.log(
|
||||||
'扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒');
|
'扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒');
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'startScanSingle:$deviceName',
|
message: '指定设备名称的扫描蓝牙设备 监听扫描结果',
|
||||||
detail: 'startScanSingle$deviceName 监听扫描结果 扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒');
|
detail: 'startScanSingle$deviceName 监听扫描结果 是否查找到 $isExit 以查找$milliseconds毫秒 扫描到的设备数:${results.length} results:$results',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
if (isExit) {
|
if (isExit) {
|
||||||
for (final ScanResult scanResult in results) {
|
for (final ScanResult scanResult in results) {
|
||||||
if (((scanResult.advertisementData.serviceUuids.isNotEmpty
|
if (((scanResult.advertisementData.serviceUuids.isNotEmpty
|
||||||
@ -193,8 +197,10 @@ class BlueManage {
|
|||||||
scanDevices.add(scanResult);
|
scanDevices.add(scanResult);
|
||||||
}
|
}
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'startScanSingle:$deviceName',
|
message: '遍历扫描到的结果跟缓存的结果对比,如果有最新的就更新缓存',
|
||||||
detail: 'startScanSingle$deviceName 查询到的结果scanResult:$scanResult');
|
detail: 'startScanSingle deviceName:$deviceName 查询到的结果scanResult:$scanResult',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,9 +208,11 @@ class BlueManage {
|
|||||||
}
|
}
|
||||||
}, onError: (e) {
|
}, onError: (e) {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'startScanSingle:$deviceName',
|
message: '指定设备名称的扫描蓝牙设备 监听扫描结果失败',
|
||||||
detail: 'startScanSingle$deviceName 监听扫描结果失败 e:${e.toString()}');
|
detail: '打印失败问题 e:${e.toString()}',
|
||||||
AppLog.log('扫描失败:$e',);
|
upload: false
|
||||||
|
);
|
||||||
|
AppLog.log('扫描失败:$e',);
|
||||||
});
|
});
|
||||||
FlutterBluePlus.cancelWhenScanComplete(subscription);
|
FlutterBluePlus.cancelWhenScanComplete(subscription);
|
||||||
await completer.future;
|
await completer.future;
|
||||||
@ -212,8 +220,10 @@ class BlueManage {
|
|||||||
subscription.cancel();
|
subscription.cancel();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'startScanSingle:$deviceName',
|
message: '指定设备名称的扫描蓝牙设备 内部逻辑整形失败',
|
||||||
detail: 'startScanSingle$deviceName startScanSingle内部逻辑整形失败 e:${e.toString()}');
|
detail: 'tartScanSingle内部逻辑整形失败 e:${e.toString()}',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
AppLog.log('扫描失败');
|
AppLog.log('扫描失败');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -300,36 +310,46 @@ class BlueManage {
|
|||||||
// 蓝牙已开启,可以进行蓝牙操作
|
// 蓝牙已开启,可以进行蓝牙操作
|
||||||
if (bluetoothConnectionState != BluetoothConnectionState.connected) {
|
if (bluetoothConnectionState != BluetoothConnectionState.connected) {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'blueSendData 蓝牙未连接',
|
message: '点击按钮 蓝牙未连接 下一步扫描连接蓝牙',
|
||||||
detail: 'blueSendData 蓝牙未连接}');
|
detail: 'blueSendData 蓝牙连接状态 bluetoothConnectionState:$bluetoothConnectionState deviceName:$deviceName',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
_connect(deviceName, (BluetoothConnectionState state) {
|
_connect(deviceName, (BluetoothConnectionState state) {
|
||||||
stateCallBack(bluetoothConnectionState!);
|
stateCallBack(bluetoothConnectionState!);
|
||||||
}, isAddEquipment: isAddEquipment);
|
}, isAddEquipment: isAddEquipment);
|
||||||
} else {
|
} else {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'blueSendData 蓝牙是连接状态',
|
message: '点击按钮 蓝牙已经连接 下一步扫描连接蓝牙',
|
||||||
detail: 'blueSendData 蓝牙是连接状态,直接回调}');
|
detail: 'blueSendData 直接回调状态 蓝牙连接状态bluetoothConnectionState:$bluetoothConnectionState deviceName:$deviceName',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
stateCallBack(bluetoothConnectionState!);
|
stateCallBack(bluetoothConnectionState!);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'blueSendData 蓝牙未打开',
|
message: '点击按钮 蓝牙未打开',
|
||||||
detail: 'blueSendData 蓝牙未打开--_adapterState:${BluetoothAdapterState.on}');
|
detail: 'blueSendData 蓝牙未打开--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
stateCallBack(BluetoothConnectionState.disconnected);
|
stateCallBack(BluetoothConnectionState.disconnected);
|
||||||
openBlue();
|
openBlue();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
AppLog.log('蓝牙打开失败');
|
AppLog.log('蓝牙打开失败');
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'blueSendData 蓝牙打开失败',
|
message: '点击按钮 蓝牙未打开 然后蓝牙打开失败',
|
||||||
detail: 'blueSendData 蓝牙打开失败--_adapterState:${BluetoothAdapterState.on}');
|
detail: 'blueSendData 蓝牙打开失败--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'blueSendData isAvailable状态',
|
message: '点击按钮 蓝牙状态不可用',
|
||||||
detail: 'blueSendData isAvailable不可用--isAvailable:$isAvailable');
|
detail: 'blueSendData 蓝牙状态不可用--isAvailable:$isAvailable',
|
||||||
// FlutterBuglyPlugin.reportException(exceptionName: 'blueSendData isAvailable状态', reason: 'blueSendData isAvailable不可用');
|
upload: false
|
||||||
|
);
|
||||||
|
stateCallBack(BluetoothConnectionState.disconnected);
|
||||||
AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作');
|
AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -353,8 +373,10 @@ class BlueManage {
|
|||||||
if (GetPlatform.isAndroid && !isExistDevice && isCurrentDevice && mac != null) {
|
if (GetPlatform.isAndroid && !isExistDevice && isCurrentDevice && mac != null) {
|
||||||
// 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空
|
// 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: '_connect:$deviceName',
|
message: '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是:_connect',
|
||||||
detail: '_connect:$deviceName GetPlatform.isAndroid:${GetPlatform.isAndroid} isExistDevice:$isExistDevice mac:$mac');
|
detail: '调用方法_connect deviceName:$deviceName GetPlatform.isAndroid:${GetPlatform.isAndroid} isExistDevice:$isExistDevice mac:$mac',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
scanSingleTimer?.cancel();
|
scanSingleTimer?.cancel();
|
||||||
// 兼容android 的低配手机
|
// 兼容android 的低配手机
|
||||||
await doNotSearchBLE(mac, connectStateCallBack, isAddEquipment: isAddEquipment);
|
await doNotSearchBLE(mac, connectStateCallBack, isAddEquipment: isAddEquipment);
|
||||||
@ -362,15 +384,19 @@ class BlueManage {
|
|||||||
scanSingleTimer = Timer(3.seconds, () {
|
scanSingleTimer = Timer(3.seconds, () {
|
||||||
scanSingleTimer?.cancel();
|
scanSingleTimer?.cancel();
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: '_connect:$deviceName',
|
message: '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 3秒以后调用startScanSingle 上传记录当前方法是:_connect',
|
||||||
detail: '_connect$deviceName scanSingleTimer 调用 startScanSingle');
|
detail: '_connect deviceName:$deviceName scanSingleTimer调用startScanSingle',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) => null);
|
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) => null);
|
||||||
});
|
});
|
||||||
} else if (isAddEquipment == false && isExistDevice == false) {
|
} else if (isAddEquipment == false && isExistDevice == false) {
|
||||||
//取消缓存直接使用,存在配对场景设备信息会更变
|
// 取消缓存直接使用,存在配对场景设备信息会更变
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: '_connect:$deviceName',
|
message: '取消缓存直接使用,存在配对场景设备信息会更变 然后开始指定设备名称的扫描蓝牙设备 上传记录当前方法是:_connect',
|
||||||
detail: '_connect$deviceName isAddEquipment:$isAddEquipment isExistDevice:$isExistDevice 下一步调用startScanSingle');
|
detail: '符合条件(isAddEquipment == false && isExistDevice == false) 下一步调用startScanSingle',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
|
|
||||||
// AppLog.log('无存在设备需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment');
|
// AppLog.log('无存在设备需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment');
|
||||||
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
|
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
|
||||||
@ -379,8 +405,10 @@ class BlueManage {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: '_connect:$deviceName',
|
message: '没有扫描直接调用连接设备 上传记录当前方法是:_connect',
|
||||||
detail: '_connect$deviceName 直接调用_connectDevice');
|
detail: '走这个方法是有缓存或者添加设备的时候以及不符合(GetPlatform.isAndroid && !isExistDevice && isCurrentDevice && mac != null) deviceName:$deviceName 直接调用_connectDevice',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
// AppLog.log('安卓或者iOS 存在设备不需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment');
|
// AppLog.log('安卓或者iOS 存在设备不需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment');
|
||||||
_connectDevice(devicesList, deviceName, connectStateCallBack,
|
_connectDevice(devicesList, deviceName, connectStateCallBack,
|
||||||
isAddEquipment: isAddEquipment);
|
isAddEquipment: isAddEquipment);
|
||||||
@ -425,25 +453,25 @@ class BlueManage {
|
|||||||
}
|
}
|
||||||
if (scanResult == null || connectDeviceMacAddress.isEmpty) {
|
if (scanResult == null || connectDeviceMacAddress.isEmpty) {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: '_connectDevice:$deviceName',
|
message: '扫描结果scanResult == null || connectDeviceMacAddress.isEmpty不往下执行 return 上传记录当前方法是:_connectDevice',
|
||||||
detail: '_connectDevice$deviceName scanResult:$scanResult connectDeviceMacAddress:$connectDeviceMacAddress scanResult == null || connectDeviceMacAddress.isEmpty不往下执行');
|
detail: 'scanResult:$scanResult connectDeviceMacAddress:$connectDeviceMacAddress',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AppLog.log('调用了停止扫描的方法');
|
AppLog.log('调用了停止扫描的方法');
|
||||||
await stopScan();
|
await stopScan();
|
||||||
BuglyTool.uploadException(
|
|
||||||
message: '_connectDevice:$deviceName',
|
|
||||||
detail: '_connectDevice$deviceName devicesList:$devicesList isReconnect:$isReconnect knownDeviceIndex:$knownDeviceIndex 调用了停止扫描方法');
|
|
||||||
|
|
||||||
if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') &&
|
if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') && isAddEquipment == false) {
|
||||||
isAddEquipment == false) {
|
|
||||||
// 添加这个判断是因为有些苹果设备或者安卓等性能比较好的设备时,添加完锁之后,锁板未改变为已添加状态之前,就进行了蓝牙连接,导致添加完锁就失败,这里进行了判断,如果第一次连接失败,就清除缓存重新扫描连接
|
// 添加这个判断是因为有些苹果设备或者安卓等性能比较好的设备时,添加完锁之后,锁板未改变为已添加状态之前,就进行了蓝牙连接,导致添加完锁就失败,这里进行了判断,如果第一次连接失败,就清除缓存重新扫描连接
|
||||||
if (isReconnect == true) {
|
if (isReconnect == true) {
|
||||||
AppLog.log('该锁已被重置, 重新发送扫描命令');
|
AppLog.log('该锁已被重置, 重新发送扫描命令');
|
||||||
|
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: '_connectDevice:$deviceName',
|
message: '该锁已被重置, 重新发送扫描命令startScanSingle 上传记录当前方法是:_connectDevice',
|
||||||
detail: '_connectDevice$deviceName 该锁已被重置, 重新发送扫描命令 serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}');
|
detail: '添加这个判断是因为有些苹果设备或者安卓等性能比较好的设备时,添加完锁之后,锁板未改变为已添加状态之前,就进行了蓝牙连接,导致添加完锁就失败,这里进行了判断,如果第一次连接失败,就清除缓存重新扫描连接 该锁已被重置, 重新发送扫描命令 serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
|
|
||||||
scanDevices.clear();
|
scanDevices.clear();
|
||||||
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
|
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
|
||||||
@ -454,10 +482,23 @@ class BlueManage {
|
|||||||
connectStateCallBack(BluetoothConnectionState.disconnected);
|
connectStateCallBack(BluetoothConnectionState.disconnected);
|
||||||
EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
|
EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
|
||||||
scanDevices.clear();
|
scanDevices.clear();
|
||||||
|
|
||||||
|
BuglyTool.uploadException(
|
||||||
|
message: '提示该锁已被重置, 回调断开连接, 清除缓存,上传记录当前方法是:_connectDevice',
|
||||||
|
detail: 'isReconnect:$isReconnect serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//尝试连接设备
|
|
||||||
|
BuglyTool.uploadException(
|
||||||
|
message: '从devicesList里面查到了设备 下一步连接设备 上传记录当前方法是:_connectDevice',
|
||||||
|
detail: 'devicesList:$devicesList scanResult:${scanResult.toString()} bluetoothConnectDevice:${bluetoothConnectDevice.toString()} connectDeviceMacAddress:$connectDeviceMacAddress',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
|
|
||||||
|
//连接设备
|
||||||
await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack);
|
await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,19 +506,24 @@ class BlueManage {
|
|||||||
Future<void> doNotSearchBLE(
|
Future<void> doNotSearchBLE(
|
||||||
String masAdds, ConnectStateCallBack connectStateCallBack,
|
String masAdds, ConnectStateCallBack connectStateCallBack,
|
||||||
{bool isAddEquipment = false}) async {
|
{bool isAddEquipment = false}) async {
|
||||||
BuglyTool.uploadException(
|
|
||||||
message: 'doNotSearchBLE:$masAdds',
|
|
||||||
detail: 'doNotSearchBLE$masAdds 调用doNotSearchBLE');
|
|
||||||
await FlutterBluePlus.stopScan();
|
await FlutterBluePlus.stopScan();
|
||||||
|
|
||||||
if (bluetoothConnectDevice == null ||
|
if (bluetoothConnectDevice == null ||
|
||||||
bluetoothConnectDevice?.remoteId.str != masAdds) {
|
bluetoothConnectDevice?.remoteId.str != masAdds) {
|
||||||
bluetoothConnectDevice = BluetoothDevice.fromId(masAdds);
|
bluetoothConnectDevice = BluetoothDevice.fromId(masAdds);
|
||||||
_initGetMtuSubscription();
|
_initGetMtuSubscription();
|
||||||
_initListenConnectionState();
|
_initListenConnectionState();
|
||||||
|
BuglyTool.uploadException(
|
||||||
|
message: '直接给蓝牙设备写入 上传记录当前方法是:doNotSearchBLE',
|
||||||
|
detail: '直接给蓝牙设备写入 通过fromId方法创建一个BluetoothDevice masAdds:$masAdds',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
}else{
|
}else{
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'doNotSearchBLE:$masAdds',
|
message: '直接给蓝牙设备写入 上传记录当前方法是:doNotSearchBLE',
|
||||||
detail: 'doNotSearchBLE$masAdds 未调用_initGetMtuSubscription()、_initListenConnectionState()');
|
detail: '直接给蓝牙设备写入 用传入的bluetoothConnectDevice:${bluetoothConnectDevice.toString()}连接 masAdds:$masAdds',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
//尝试连接设备
|
//尝试连接设备
|
||||||
await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack,
|
await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack,
|
||||||
@ -507,8 +553,10 @@ class BlueManage {
|
|||||||
if (attempt >= maxAttempts) {
|
if (attempt >= maxAttempts) {
|
||||||
AppLog.log('$maxAttempts次后尝试连接失败');
|
AppLog.log('$maxAttempts次后尝试连接失败');
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
|
message: '连接三次超时断开连接 回调断开连接 上传记录当前方法是:bluetoothDeviceConnect',
|
||||||
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} $maxAttempts次后尝试连接失败');
|
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} $maxAttempts次后尝试连接失败',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
connectStateCallBack(BluetoothConnectionState.disconnected);
|
connectStateCallBack(BluetoothConnectionState.disconnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,18 +572,24 @@ class BlueManage {
|
|||||||
bluetoothConnectionState = BluetoothConnectionState.connected;
|
bluetoothConnectionState = BluetoothConnectionState.connected;
|
||||||
connectStateCallBack(bluetoothConnectionState!);
|
connectStateCallBack(bluetoothConnectionState!);
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
|
message: '订阅成功 上传记录当前方法是:bluetoothDeviceConnect',
|
||||||
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} 发现服务,连接成功,订阅数据');
|
detail: '发现服务,连接成功,订阅数据 bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} ',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
} else{
|
} else{
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
|
message: '订阅失败 上传记录当前方法是:bluetoothDeviceConnect',
|
||||||
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} characteristic.characteristicUuid != _characteristicIdSubscription 失败');
|
detail: '失败原因: characteristic.characteristicUuid:${characteristic.characteristicUuid} != _characteristicIdSubscription:$_characteristicIdSubscription bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
|
message: '订阅失败 上传记录当前方法是:bluetoothDeviceConnect',
|
||||||
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} service.uuid != _serviceIdConnec 失败');
|
detail: '失败原因: service.uuid:${service.uuid} != _serviceIdConnect:$_serviceIdConnect bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
@ -544,8 +598,10 @@ class BlueManage {
|
|||||||
AppLog.log(
|
AppLog.log(
|
||||||
'发现设备时失败 e:$e bluetoothConnectionState:$bluetoothConnectionState');
|
'发现设备时失败 e:$e bluetoothConnectionState:$bluetoothConnectionState');
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
|
message: '发现服务时失败',
|
||||||
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} 发现服务时报错 e:$e');
|
detail: '发现服务时报错原因e:$e bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,11 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
Future<void> _replyOpenLock(Reply reply) async {
|
Future<void> _replyOpenLock(Reply reply) async {
|
||||||
final int status = reply.data[6];
|
final int status = reply.data[6];
|
||||||
|
|
||||||
BuglyTool.uploadException(message: '_replyOpenLock', detail: '_replyOpenLock:${reply.data}');
|
BuglyTool.uploadException(
|
||||||
|
message: '开锁结果,解析数据',
|
||||||
|
detail: '开锁结果,解析数据 _replyOpenLock:${reply.data}',
|
||||||
|
upload: true
|
||||||
|
);
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
@ -357,15 +361,22 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
showBlueConnetctToastTimer(
|
showBlueConnetctToastTimer(
|
||||||
outTimer: 20,
|
outTimer: 20,
|
||||||
action: () {
|
action: () {
|
||||||
// FlutterBuglyPlugin.reportException(exceptionName: '开门超时处理', reason: '开门超时,断开连接');
|
|
||||||
BuglyTool.uploadException(message: '开门超时处理', detail: '开门超时,断开连接--$command');
|
|
||||||
resetOpenDoorState();
|
resetOpenDoorState();
|
||||||
blueManageDisconnect();
|
blueManageDisconnect();
|
||||||
|
BuglyTool.uploadException(
|
||||||
|
message: '开门超时处理-开锁失败',
|
||||||
|
detail: '开门超时,断开连接,开锁失败--OpenLockCommand:$command',
|
||||||
|
upload: true
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
BlueManage().blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
|
BlueManage().blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||||
BuglyTool.uploadException(message: '蓝牙连接成功', detail: '蓝牙连接成功,发送开锁指令--$command');
|
BuglyTool.uploadException(
|
||||||
|
message: '蓝牙连接成功',
|
||||||
|
detail: '蓝牙连接成功,发送开锁指令--OpenLockCommand:$command',
|
||||||
|
upload: false
|
||||||
|
);
|
||||||
// FlutterBuglyPlugin.reportException(exceptionName: '蓝牙连接成功', reason: '蓝牙连接成功,发送开锁指令');
|
// FlutterBuglyPlugin.reportException(exceptionName: '蓝牙连接成功', reason: '蓝牙连接成功,发送开锁指令');
|
||||||
IoSenderManage.senderOpenLock(
|
IoSenderManage.senderOpenLock(
|
||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
@ -380,7 +391,11 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
);
|
);
|
||||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
BuglyTool.uploadException(message: '蓝牙连接失败', detail: '蓝牙连接失败,断开连接--$command');
|
BuglyTool.uploadException(
|
||||||
|
message: '蓝牙连接失败-开锁失败',
|
||||||
|
detail: '蓝牙连接失败,断开连接, 开锁失败--OpenLockCommand:$command',
|
||||||
|
upload: true
|
||||||
|
);
|
||||||
if (state.ifCurrentScreen.value == true) {
|
if (state.ifCurrentScreen.value == true) {
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
@ -467,8 +482,10 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
openDoorAction();
|
openDoorAction();
|
||||||
} else {
|
} else {
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: '点击了需要联网开锁 2',
|
message: '点击了需要联网开锁',
|
||||||
detail: '点击了需要联网开锁 获取连网token失败');
|
detail: '点击了需要联网开锁 获取连网token失败',
|
||||||
|
upload: true
|
||||||
|
);
|
||||||
showToast('网络访问失败,请检查网络是否正常'.tr, something: () {
|
showToast('网络访问失败,请检查网络是否正常'.tr, something: () {
|
||||||
resetOpenDoorState();
|
resetOpenDoorState();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
|
|||||||
@ -1440,7 +1440,10 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
// FlutterBuglyPlugin.reportException(exceptionName: '点击了不需要联网开锁');
|
// FlutterBuglyPlugin.reportException(exceptionName: '点击了不需要联网开锁');
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: '点击了不需要联网开锁',
|
message: '点击了不需要联网开锁',
|
||||||
detail: '点击了不需要联网开锁 openDoorModel:${state.openDoorModel}');
|
detail: '点击了不需要联网开锁 openDoorModel:${state.openDoorModel}',
|
||||||
|
upload: false,
|
||||||
|
begin:true
|
||||||
|
);
|
||||||
AppLog.log('点击开锁 state.openDoorModel = 0 不需要联网');
|
AppLog.log('点击开锁 state.openDoorModel = 0 不需要联网');
|
||||||
logic.openDoorAction();
|
logic.openDoorAction();
|
||||||
} else {
|
} else {
|
||||||
@ -1449,7 +1452,10 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
// FlutterBuglyPlugin.reportException(exceptionName: '点击了需要联网开锁');
|
// FlutterBuglyPlugin.reportException(exceptionName: '点击了需要联网开锁');
|
||||||
BuglyTool.uploadException(
|
BuglyTool.uploadException(
|
||||||
message: '点击了需要联网开锁',
|
message: '点击了需要联网开锁',
|
||||||
detail: '点击了需要联网开锁 openDoorModel:${state.openDoorModel}');
|
detail: '点击了需要联网开锁 openDoorModel:${state.openDoorModel}',
|
||||||
|
upload: false,
|
||||||
|
begin:true
|
||||||
|
);
|
||||||
AppLog.log('点击开锁 state.openDoorModel = 2 需要联网');
|
AppLog.log('点击开锁 state.openDoorModel = 2 需要联网');
|
||||||
logic.getLockNetToken();
|
logic.getLockNetToken();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,11 +60,35 @@ class BuglyTool {
|
|||||||
FlutterBugly.setUserId(userId?.toString() ?? '');
|
FlutterBugly.setUserId(userId?.toString() ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String uploadStr = '';
|
||||||
static Future<void> uploadException({
|
static Future<void> uploadException({
|
||||||
required String message,
|
required String message,
|
||||||
required String detail,
|
required String detail,
|
||||||
|
required bool upload,
|
||||||
|
bool begin = false,
|
||||||
Map? data,
|
Map? data,
|
||||||
}) async {
|
}) async {
|
||||||
FlutterBugly.uploadException(message: '${(await Storage.getMobile())!.isNotEmpty ? (await Storage.getMobile()) : (await Storage.getEmail())}+$time ---' + message, detail: detail, data: data);
|
String getMessage = '${(await Storage.getMobile())!.isNotEmpty ? (await Storage.getMobile()) : (await Storage.getEmail())}+$time --- message:$message detail:$detail';
|
||||||
|
if(begin == true){
|
||||||
|
// 开始
|
||||||
|
uploadStr = '';
|
||||||
|
}else{
|
||||||
|
uploadStr = '$uploadStr \n<----------->\n $getMessage';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(upload){
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static Future<void> uploadExceptionWithEvent({
|
||||||
|
required String eventStr,
|
||||||
|
required String detail,
|
||||||
|
}) async {
|
||||||
|
FlutterBugly.uploadException(message: '${(await Storage.getMobile())!.isNotEmpty ? (await Storage.getMobile()) : (await Storage.getEmail())}+${time == 0 ? DateTime.now().millisecondsSinceEpoch : 0}--- $eventStr', detail: detail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import 'package:permission_handler/permission_handler.dart';
|
|||||||
import 'package:star_lock/app_settings/app_settings.dart';
|
import 'package:star_lock/app_settings/app_settings.dart';
|
||||||
import 'package:star_lock/tools/storage.dart';
|
import 'package:star_lock/tools/storage.dart';
|
||||||
|
|
||||||
|
import '../../tools/bugly/bugly_tool.dart';
|
||||||
|
|
||||||
class PermissionDialog {
|
class PermissionDialog {
|
||||||
static Map<Permission, String> titles = <Permission, String>{
|
static Map<Permission, String> titles = <Permission, String>{
|
||||||
Permission.camera: '相机'.tr,
|
Permission.camera: '相机'.tr,
|
||||||
@ -66,12 +68,14 @@ class PermissionDialog {
|
|||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child: Text('不允许'.tr),
|
child: Text('不允许'.tr),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
BuglyTool.uploadExceptionWithEvent(eventStr: '${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}', detail: "不允许'${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr} titles:$titles'");
|
||||||
Get.back(result: false);
|
Get.back(result: false);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child: Text('允许'.tr),
|
child: Text('允许'.tr),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
BuglyTool.uploadExceptionWithEvent(eventStr: '${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}', detail: "不允许'${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr} titles:$titles'");
|
||||||
Get.back(result: true);
|
Get.back(result: true);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -302,12 +306,14 @@ class PermissionDialog {
|
|||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child: Text('不允许'.tr),
|
child: Text('不允许'.tr),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
BuglyTool.uploadExceptionWithEvent(eventStr: '${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}', detail: "不允许'${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr} titles:$titles'");
|
||||||
Get.back(result: false);
|
Get.back(result: false);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child: Text('允许'.tr),
|
child: Text('允许'.tr),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
BuglyTool.uploadExceptionWithEvent(eventStr: '${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}', detail: "允许'${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr} titles:$titles'");
|
||||||
Get.back(result: true);
|
Get.back(result: true);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user