1.网络访问失败的时长增加到6s

2.推送的debugPrint删除
3.判断2.4G的wifi删除
4.鸿蒙6.0视频对讲动画转太快
This commit is contained in:
sky.min 2026-01-06 10:16:00 +08:00
parent 9a76dcd232
commit be0577bb55
9 changed files with 137 additions and 231 deletions

View File

@ -14,7 +14,6 @@ class AppLog {
} }
static void log(String msg, {StackTrace? stackTrace, bool? error}) { static void log(String msg, {StackTrace? stackTrace, bool? error}) {
debugPrint(msg);
msg = '${DateTime.now().toIso8601String()} : $msg'; msg = '${DateTime.now().toIso8601String()} : $msg';
DebugConsole.info(msg, stackTrace: stackTrace, isErr: error ?? false); DebugConsole.info(msg, stackTrace: stackTrace, isErr: error ?? false);
if (!kDebugMode) { if (!kDebugMode) {

View File

@ -65,23 +65,33 @@ class SenderBeforeDataManage {
// //
Future<void> _replyAddUserKey(Reply reply) async { Future<void> _replyAddUserKey(Reply reply) async {
//
if (reply.data.length < 47) {
return; //
}
final int status = reply.data[46]; final int status = reply.data[46];
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
// sublist安全
if (reply.data.length >= 49) {
final List<int> userNoData = reply.data.sublist(47, 49); final List<int> userNoData = reply.data.sublist(47, 49);
CommonDataManage().currentLockUserNo = listChangInt(userNoData); CommonDataManage().currentLockUserNo = listChangInt(userNoData);
CommonDataManage().currentKeyInfo.lockUserNo = CommonDataManage().currentLockUserNo; CommonDataManage().currentKeyInfo.lockUserNo = CommonDataManage().currentLockUserNo;
_updateLockUserNo(userNoData); _updateLockUserNo(userNoData);
}
break; break;
case 0x06: case 0x06:
// //
if (reply.data.length >= 46) {
final List<int> token = reply.data.sublist(42, 46); final List<int> token = reply.data.sublist(42, 46);
final List<String> strTokenList = changeIntListToStringList(token); final List<String> strTokenList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, strTokenList); Storage.setStringList(saveBlueToken, strTokenList);
final List<int> addUserData = await getAddUserKeyData(tokenList: token); final List<int> addUserData = await getAddUserKeyData(tokenList: token);
eventBus.fire(LockAddUserSucceedEvent(addUserData, 1)); eventBus.fire(LockAddUserSucceedEvent(addUserData, 1));
}
break; break;
case 0x0c: case 0x0c:
// 32 // 32

View File

@ -65,13 +65,6 @@ class _ConfiguringWifiPageState extends State<ConfiguringWifiPage>
logic.showToast('请输入WiFi密码'.tr); logic.showToast('请输入WiFi密码'.tr);
return; return;
} }
// WiFi名称是否包含5G关键字
if (state.wifiNameController.text
.toLowerCase()
.contains('5g')) {
logic.showToast('请确保使用2.4GHz WiFi网络'.tr);
return;
}
logic.senderConfiguringWifiAction(); logic.senderConfiguringWifiAction();
}, },
), ),

View File

@ -108,7 +108,7 @@ class BaseProvider extends GetConnect with Api {
} }
if (res.body == null) { if (res.body == null) {
if (res.statusCode == null && isShowErrMsg!) { if (res.statusCode == null && isShowErrMsg!) {
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, duration: 2000.milliseconds); EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, duration: 6000.milliseconds);
} }
var rs = {'errorMsg': 'Network Error!', 'errorCode': -1, 'data': null, 'description': '表示成功或是。'}; var rs = {'errorMsg': 'Network Error!', 'errorCode': -1, 'data': null, 'description': '表示成功或是。'};
return Response( return Response(

View File

@ -37,8 +37,6 @@ class UdpTalkHangUpHandler extends ScpMessageBaseHandle
startChartManage.stopSendingRbcuInfoMessages(); startChartManage.stopSendingRbcuInfoMessages();
startChartManage.stopSendingRbcuProBeMessages(); startChartManage.stopSendingRbcuProBeMessages();
startChartManage.stopTalkHangupMessageTimer(); startChartManage.stopTalkHangupMessageTimer();
//
talkStatus.setEnd();
Get.back(); Get.back();
} }
} }
@ -57,8 +55,6 @@ class UdpTalkHangUpHandler extends ScpMessageBaseHandle
startChartManage.stopSendingRbcuInfoMessages(); startChartManage.stopSendingRbcuInfoMessages();
startChartManage.stopSendingRbcuProBeMessages(); startChartManage.stopSendingRbcuProBeMessages();
startChartManage.stopTalkHangupMessageTimer(); startChartManage.stopTalkHangupMessageTimer();
//
talkStatus.setEnd();
} }
@override @override

View File

@ -1,13 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/talk/other/audio_player_manager.dart'; import 'package:star_lock/talk/other/audio_player_manager.dart';
import 'package:star_lock/talk/starChart/constant/payload_type_constant.dart'; import 'package:star_lock/talk/starChart/constant/payload_type_constant.dart';
@ -98,10 +91,6 @@ class ScpMessageBaseHandle {
// //
void playRingtone() async { void playRingtone() async {
//
if (startChartManage.isMonitoring) {
return;
}
//test:使 //test:使
await audioManager.playRingtone(); await audioManager.playRingtone();
} }

View File

@ -94,7 +94,6 @@ class StartChartManage {
final String echoPeerId = '3phX8Ng2cZHz5NtP8xAf6nYy2z1BYytoejgjoHrWMGhH'; final String echoPeerId = '3phX8Ng2cZHz5NtP8xAf6nYy2z1BYytoejgjoHrWMGhH';
bool isOnlineStarChartServer = false; // 线 bool isOnlineStarChartServer = false; // 线
bool isMonitoring = false; //
Timer? reStartOnlineStartChartServerTimer; // 线 Timer? reStartOnlineStartChartServerTimer; // 线
Timer? talkPingTimer; // Timer? talkPingTimer; //
Timer? talkExpectTimer; // Timer? talkExpectTimer; //
@ -162,18 +161,6 @@ class StartChartManage {
await reportInformation(); await reportInformation();
} }
//
// Future<void> establishConnection({required String ToPeerId}) async {
// //
// await init(); //
//
// //
// await Future.wait([
// startSendingRbcuInfoMessages(ToPeerId: ToPeerId),
// startSendingRbcuProbeTMessages(),
// ] as Iterable<Future>);
// }
/// ///
Future<void> _clientRegister(LoginData? loginData) async { Future<void> _clientRegister(LoginData? loginData) async {
if (loginData?.starchart?.starchartId != null) { if (loginData?.starchart?.starchartId != null) {
@ -434,11 +421,7 @@ class StartChartManage {
} }
/// ///
void startCallRequestMessageTimer({required String ToPeerId, bool isMonitoring = false}) async { void startCallRequestMessageTimer({required String ToPeerId}) async {
// ToPeerId为当前要连接的锁的peerId
this.ToPeerId = ToPeerId;
this.lockPeerId = ToPeerId;
this.isMonitoring = isMonitoring;
// //
// if (talkStatus.status != TalkStatus.proactivelyCallWaitingAnswer) { // if (talkStatus.status != TalkStatus.proactivelyCallWaitingAnswer) {
// // h264则跳转至webview // // h264则跳转至webview
@ -474,28 +457,22 @@ class StartChartManage {
// //
talkRequestTimer ??= Timer.periodic( talkRequestTimer ??= Timer.periodic(
Duration( Duration(
milliseconds: _defaultIntervalTime, seconds: _defaultIntervalTime,
// milliseconds: 500,
), ),
(Timer timer) async { (Timer timer) async {
AppLog.log('发送对讲请求:${ToPeerId}'); AppLog.log('发送对讲请求:${ToPeerId}');
await sendCallRequestMessage(ToPeerId: ToPeerId); await sendCallRequestMessage(ToPeerId: ToPeerId);
}, },
); );
//
if (!isMonitoring) {
talkStatus.setProactivelyCallWaitingAnswer(); talkStatus.setProactivelyCallWaitingAnswer();
// //
talkeRequestOverTimeTimerManager.start(); talkeRequestOverTimeTimerManager.start();
} }
}
/// ///
void stopCallRequestMessageTimer() async { void stopCallRequestMessageTimer() async {
talkRequestTimer?.cancel(); talkRequestTimer?.cancel();
talkRequestTimer = null; talkRequestTimer = null;
//
isMonitoring = false;
} }
// //
@ -554,10 +531,6 @@ class StartChartManage {
_log(text: '心跳已经开始了. 请勿重复发送心跳包消息'); _log(text: '心跳已经开始了. 请勿重复发送心跳包消息');
return; return;
} }
//
// if (_heartBeatTimer != null) {
// _heartBeatTimer?.cancel();
// }
_heartBeatTimer ??= Timer.periodic( _heartBeatTimer ??= Timer.periodic(
Duration( Duration(
seconds: heartbeatIntervalTime, seconds: heartbeatIntervalTime,
@ -740,19 +713,13 @@ class StartChartManage {
// _log(text: '发送通话保持'); // _log(text: '发送通话保持');
} }
Future<void> _sendTalkHangupMessage() async { void _sendTalkHangupMessage() async {
final message = MessageCommand.talkHangupMessage( final message = MessageCommand.talkHangupMessage(
ToPeerId: ToPeerId, ToPeerId: ToPeerId,
FromPeerId: FromPeerId, FromPeerId: FromPeerId,
MessageId: MessageCommand.getNextMessageId(ToPeerId, increment: true), MessageId: MessageCommand.getNextMessageId(ToPeerId, increment: true),
); );
try {
await _sendMessage(message: message); await _sendMessage(message: message);
} catch (e) {
//
AppLog.log('发送挂断消息失败: $e');
//
}
} }
// //
@ -761,7 +728,7 @@ class StartChartManage {
talkHangupTimer ??= Timer.periodic( talkHangupTimer ??= Timer.periodic(
Duration(seconds: _defaultIntervalTime), Duration(seconds: _defaultIntervalTime),
(Timer timer) async { (Timer timer) async {
await _sendTalkHangupMessage(); _sendTalkHangupMessage();
}, },
); );
@ -833,17 +800,10 @@ class StartChartManage {
// //
Future<void> _sendMessage({required List<int> message}) async { Future<void> _sendMessage({required List<int> message}) async {
var result = await _udpSocket?.send(message, InternetAddress(remoteHost), remotePort); var result = await _udpSocket?.send(message, InternetAddress(remoteHost), remotePort);
//
try {
// UDP发送逻辑
} catch (e) {
//
if (result != message.length) { if (result != message.length) {
throw StartChartMessageException('❌Udp send data error----> $result ${message.length}'); throw StartChartMessageException('❌Udp send data error----> $result ${message.length}');
// _udpSocket = null; // _udpSocket = null;
} }
print('对讲消息发送失败: $e');
}
//ToDo: //ToDo:
// UdpTalkDataHandler().updateSendDataRate(message.length); // UdpTalkDataHandler().updateSendDataRate(message.length);
@ -1084,24 +1044,6 @@ class StartChartManage {
void _handleUdpResultData(ScpMessage scpMessage) { void _handleUdpResultData(ScpMessage scpMessage) {
final int payloadType = scpMessage.PayloadType ?? 0; final int payloadType = scpMessage.PayloadType ?? 0;
final int messageType = scpMessage.MessageType ?? 0; final int messageType = scpMessage.MessageType ?? 0;
AppLog.log('payloadType:$payloadType,messageType:$messageType');
//
if (payloadType == PayloadTypeConstant.remoteUnlock) {
AppLog.log('收到蓝牙设备回应消息,${scpMessage.PayloadType}');
//
if (scpMessage.Payload != null && scpMessage.Payload!.isNotEmpty) {
//
final List<int> payload = scpMessage.Payload!;
if (payload.length > 2) {
final int errorCode = payload[2];
if (errorCode == 6) {
// "网关正忙,请稍后再试"
AppLog.log('网关正忙,请稍后再试');
}
}
}
}
try { try {
final ScpMessageHandler handler = ScpMessageHandlerFactory.createHandler(payloadType); final ScpMessageHandler handler = ScpMessageHandlerFactory.createHandler(payloadType);
if (messageType == MessageTypeConstant.Req) { if (messageType == MessageTypeConstant.Req) {
@ -1260,7 +1202,7 @@ class StartChartManage {
final message = MessageCommand.bleMessage( final message = MessageCommand.bleMessage(
FromPeerId: FromPeerId, FromPeerId: FromPeerId,
ToPeerId: lockPeerId, ToPeerId: lockPeerId,
MessageId: MessageCommand.getNextMessageId(lockPeerId, increment: true), MessageId: MessageCommand.getNextMessageId(ToPeerId, increment: true),
bluetoothDeviceName: bluetoothDeviceName, bluetoothDeviceName: bluetoothDeviceName,
bleStructData: bleStructData, bleStructData: bleStructData,
); );
@ -1275,9 +1217,6 @@ class StartChartManage {
status == TalkStatus.proactivelyCallWaitingAnswer || status == TalkStatus.proactivelyCallWaitingAnswer ||
status == TalkStatus.answeredSuccessfully || status == TalkStatus.answeredSuccessfully ||
status == TalkStatus.uninitialized) { status == TalkStatus.uninitialized) {
//
await _sendTalkHangupMessage();
//
startTalkRejectMessageTimer(); startTalkRejectMessageTimer();
startTalkHangupMessageTimer(); startTalkHangupMessageTimer();
await Future.delayed(Duration(seconds: 1)); await Future.delayed(Duration(seconds: 1));

View File

@ -1,31 +1,18 @@
import 'dart:async';
import 'dart:math';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:provider/provider.dart';
import 'package:star_lock/appRouters.dart'; import 'package:star_lock/appRouters.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/talk/call/callTalk.dart'; import 'package:star_lock/talk/call/callTalk.dart';
import 'package:star_lock/talk/starChart/constant/talk_status.dart'; import 'package:star_lock/talk/starChart/constant/talk_status.dart';
import 'package:star_lock/talk/starChart/handle/impl/debug_Info_model.dart';
import 'package:star_lock/talk/starChart/handle/impl/udp_talk_data_handler.dart';
import 'package:star_lock/talk/starChart/star_chart_manage.dart'; import 'package:star_lock/talk/starChart/star_chart_manage.dart';
import 'package:star_lock/talk/starChart/views/native/talk_view_native_decode_logic.dart'; import 'package:star_lock/talk/starChart/views/native/talk_view_native_decode_logic.dart';
import 'package:star_lock/talk/starChart/views/native/talk_view_native_decode_state.dart'; import 'package:star_lock/talk/starChart/views/native/talk_view_native_decode_state.dart';
import 'package:star_lock/talk/starChart/views/talkView/talk_view_logic.dart';
import 'package:star_lock/talk/starChart/views/talkView/talk_view_state.dart';
import 'package:video_decode_plugin/video_decode_plugin.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../app_settings/app_settings.dart';
import '../../../../tools/showTFView.dart';
class TalkViewNativeDecodePage extends StatefulWidget { class TalkViewNativeDecodePage extends StatefulWidget {
const TalkViewNativeDecodePage({Key? key}) : super(key: key); const TalkViewNativeDecodePage({Key? key}) : super(key: key);
@ -102,12 +89,12 @@ class _TalkViewNativeDecodePageState extends State<TalkViewNativeDecodePage> wit
aspectRatio: StartChartManage().videoWidth / StartChartManage().videoHeight, aspectRatio: StartChartManage().videoWidth / StartChartManage().videoHeight,
child: Texture( child: Texture(
textureId: state.textureId.value!, textureId: state.textureId.value!,
filterQuality: FilterQuality.low, filterQuality: FilterQuality.medium,
), ),
) )
: Texture( : Texture(
textureId: state.textureId.value!, textureId: state.textureId.value!,
filterQuality: FilterQuality.low, filterQuality: FilterQuality.medium,
), ),
), ),
), ),
@ -354,10 +341,9 @@ class _TalkViewNativeDecodePageState extends State<TalkViewNativeDecodePage> wit
state.isLongPressing.value = false; state.isLongPressing.value = false;
}, },
onClick: () async { onClick: () async {
//
if (state.talkStatus.value == TalkStatus.passiveCallWaitingAnswer) { if (state.talkStatus.value == TalkStatus.passiveCallWaitingAnswer) {
// //
if (!state.isMonitoringMode()) { if (state.udpStatus.value != 1) {
logic.initiateAnswerCommand(); logic.initiateAnswerCommand();
} }
} }
@ -390,8 +376,8 @@ class _TalkViewNativeDecodePageState extends State<TalkViewNativeDecodePage> wit
} }
String getAnswerBtnImg() { String getAnswerBtnImg() {
// //
if (state.isMonitoringMode.value) { if (state.udpStatus.value == 1) {
return 'images/main/icon_lockDetail_monitoringUnTalkback.png'; return 'images/main/icon_lockDetail_monitoringUnTalkback.png';
} }
switch (state.talkStatus.value) { switch (state.talkStatus.value) {
@ -406,8 +392,8 @@ class _TalkViewNativeDecodePageState extends State<TalkViewNativeDecodePage> wit
} }
String getAnswerBtnName() { String getAnswerBtnName() {
// //
if (state.isMonitoringMode.value) { if (state.udpStatus.value == 1) {
return '长按说话'.tr; return '长按说话'.tr;
} }
switch (state.talkStatus.value) { switch (state.talkStatus.value) {
@ -511,6 +497,7 @@ class _TalkViewNativeDecodePageState extends State<TalkViewNativeDecodePage> wit
@override @override
void dispose() { void dispose() {
state.animationController.dispose();
CallTalk().finishAVData(); CallTalk().finishAVData();
super.dispose(); super.dispose();
} }

View File

@ -41,7 +41,7 @@ class TalkViewNativeDecodeState {
TextEditingController passwordTF = TextEditingController(); TextEditingController passwordTF = TextEditingController();
RxList<int> listAudioData = <int>[].obs; // RxList<int> listAudioData = <int>[].obs; //
final GlobalKey globalKey = GlobalKey(); GlobalKey globalKey = GlobalKey();
Timer? oneMinuteTimeTimer; // 60 Timer? oneMinuteTimeTimer; // 60
RxInt oneMinuteTime = 0.obs; // RxInt oneMinuteTime = 0.obs; //
@ -104,17 +104,13 @@ class TalkViewNativeDecodeState {
int lastPerformanceCheck = 0; int lastPerformanceCheck = 0;
int lastFrameCount = 0; int lastFrameCount = 0;
//
final RxInt networkQualityScore = 1.obs; // 1-55
final RxString networkQualityMessage = ''.obs; //
// Mapkey为textureId_frameSeq // Mapkey为textureId_frameSeq
Map<String, Map<String, dynamic>> frameTracker = {}; Map<String, Map<String, dynamic>> frameTracker = {};
// H264帧缓冲区相关 // H264帧缓冲区相关
final List<Map<String, dynamic>> h264FrameBuffer = <Map<String, dynamic>>[]; // H264帧缓冲区 final List<Map<String, dynamic>> h264FrameBuffer = <Map<String, dynamic>>[]; // H264帧缓冲区
int maxFrameBufferSize = 25; // int maxFrameBufferSize = 25; //
int targetFps = 25; // ,native的缓冲区 final int targetFps = 25; // ,native的缓冲区
Timer? frameProcessTimer; // Timer? frameProcessTimer; //
bool isProcessingFrame = false; // bool isProcessingFrame = false; //
int lastProcessedTimestamp = 0; // int lastProcessedTimestamp = 0; //
@ -129,7 +125,4 @@ class TalkViewNativeDecodeState {
// //
RxBool isFullScreen = false.obs; RxBool isFullScreen = false.obs;
//
final RxBool isMonitoringMode = false.obs;
} }