@ -97,7 +97,7 @@ class OtaCoreService {
return true ;
return true ;
} catch ( e ) {
} catch ( e ) {
_showBleCheckFailedSnackbar ( ' 检查BLE连接状态时发生错误: $ e ' ) ;
_showBleCheckFailedSnackbar ( ' otaBleCheckErrorWithError ' . trParams ( { ' error ' : e . toString ( ) } ) ) ;
return false ;
return false ;
}
}
}
}
@ -107,14 +107,14 @@ class OtaCoreService {
Get . dialog (
Get . dialog (
AlertDialog (
AlertDialog (
title: Text (
title: Text (
' BLE设备未连接 ' ,
' otaBleNotConnected ' . tr ,
style: TextStyle (
style: TextStyle (
color: Colors . red [ 700 ] ,
color: Colors . red [ 700 ] ,
fontWeight: FontWeight . w600 ,
fontWeight: FontWeight . w600 ,
) ,
) ,
) ,
) ,
content: Text (
content: Text (
' 固件升级需要连接BLE设备 \n 请确保设备已正确连接后再试 ' ,
' otaBleNeedConnection ' . tr ,
style: TextStyle (
style: TextStyle (
color: Colors . red [ 600 ] ,
color: Colors . red [ 600 ] ,
) ,
) ,
@ -125,7 +125,7 @@ class OtaCoreService {
style: TextButton . styleFrom (
style: TextButton . styleFrom (
foregroundColor: Colors . red [ 700 ] ,
foregroundColor: Colors . red [ 700 ] ,
) ,
) ,
child: const Text ( ' 确定 ' ) ,
child: Text ( ' okConfirm ' . tr ) ,
) ,
) ,
] ,
] ,
shape: RoundedRectangleBorder (
shape: RoundedRectangleBorder (
@ -145,14 +145,14 @@ class OtaCoreService {
Get . dialog (
Get . dialog (
AlertDialog (
AlertDialog (
title: Text (
title: Text (
' 设备信息不可用 ' ,
' otaDeviceInfoUnavailableTitle ' . tr ,
style: TextStyle (
style: TextStyle (
color: Colors . orange [ 700 ] ,
color: Colors . orange [ 700 ] ,
fontWeight: FontWeight . w600 ,
fontWeight: FontWeight . w600 ,
) ,
) ,
) ,
) ,
content: Text (
content: Text (
' 无法获取设备信息 \n 请重新连接设备或稍后再试 ' ,
' otaCannotGetDeviceInfo ' . tr ,
style: TextStyle (
style: TextStyle (
color: Colors . orange [ 600 ] ,
color: Colors . orange [ 600 ] ,
) ,
) ,
@ -163,7 +163,7 @@ class OtaCoreService {
style: TextButton . styleFrom (
style: TextButton . styleFrom (
foregroundColor: Colors . orange [ 700 ] ,
foregroundColor: Colors . orange [ 700 ] ,
) ,
) ,
child: const Text ( ' 确定 ' ) ,
child: Text ( ' okConfirm ' . tr ) ,
) ,
) ,
] ,
] ,
shape: RoundedRectangleBorder (
shape: RoundedRectangleBorder (
@ -182,7 +182,7 @@ class OtaCoreService {
/ / / [ message ] 错 误 信 息
/ / / [ message ] 错 误 信 息
void _showBleCheckFailedSnackbar ( String message ) {
void _showBleCheckFailedSnackbar ( String message ) {
Get . snackbar (
Get . snackbar (
' BLE连接检查失败 ' ,
' otaBleCheckFailed ' . tr ,
message ,
message ,
snackPosition: SnackPosition . BOTTOM ,
snackPosition: SnackPosition . BOTTOM ,
backgroundColor: Colors . red [ 600 ] ,
backgroundColor: Colors . red [ 600 ] ,
@ -202,7 +202,7 @@ class OtaCoreService {
final deviceInfo = _bleManager . deviceInfo . value ;
final deviceInfo = _bleManager . deviceInfo . value ;
if ( deviceInfo = = null ) {
if ( deviceInfo = = null ) {
_showBatteryCheckFailedSnackbar ( ' 无法获取设备信息,请检查设备连接 ' ) ;
_showBatteryCheckFailedSnackbar ( ' otaCannotGetDeviceInfoCheckConnection ' . tr ) ;
return false ;
return false ;
}
}
@ -213,7 +213,7 @@ class OtaCoreService {
/ / 如 果 根 据 设 备 名 称 找 不 到 产 品 , 尝 试 使 用 默 认 产 品 名 称
/ / 如 果 根 据 设 备 名 称 找 不 到 产 品 , 尝 试 使 用 默 认 产 品 名 称
product = AppConfig . getproduct ( " DeapSound " ) ;
product = AppConfig . getproduct ( " DeapSound " ) ;
if ( product = = null ) {
if ( product = = null ) {
_showBatteryCheckFailedSnackbar ( ' 无法获取产品信息,设备名称: $ deviceName ' ) ;
_showBatteryCheckFailedSnackbar ( ' otaCannotGetProductInfoWithName ' . trParams ( { ' deviceName ' : deviceName } ) ) ;
return false ;
return false ;
}
}
}
}
@ -236,7 +236,7 @@ class OtaCoreService {
return _checkDoubleHeadsetBattery ( leftBattery , rightBattery ) ;
return _checkDoubleHeadsetBattery ( leftBattery , rightBattery ) ;
}
}
} catch ( e ) {
} catch ( e ) {
_showBatteryCheckFailedSnackbar ( ' 检查设备电量时发生错误: $ e ' ) ;
_showBatteryCheckFailedSnackbar ( ' otaBleCheckErrorWithError ' . trParams ( { ' error ' : e . toString ( ) } ) ) ;
return false ;
return false ;
}
}
}
}
@ -253,14 +253,14 @@ class OtaCoreService {
if ( leftBattery > 0 & & leftBattery ! = 127 ) {
if ( leftBattery > 0 & & leftBattery ! = 127 ) {
/ / 左 耳 有 效 , 使 用 左 耳 电 量
/ / 左 耳 有 效 , 使 用 左 耳 电 量
activeBattery = leftBattery ;
activeBattery = leftBattery ;
activeEar = ' 左耳 ' ;
activeEar = ' leftEar ' . tr ;
} else if ( rightBattery > 0 & & rightBattery ! = 127 ) {
} else if ( rightBattery > 0 & & rightBattery ! = 127 ) {
/ / 左 耳 无 效 , 使 用 右 耳 电 量
/ / 左 耳 无 效 , 使 用 右 耳 电 量
activeBattery = rightBattery ;
activeBattery = rightBattery ;
activeEar = ' 右耳 ' ;
activeEar = ' rightEar ' . tr ;
} else {
} else {
/ / 两 边 都 无 效
/ / 两 边 都 无 效
_showBatteryCheckFailedSnackbar ( ' 无法获取有效的电量信息 ' ) ;
_showBatteryCheckFailedSnackbar ( ' otaCannotGetBatteryInfo ' . tr ) ;
return false ;
return false ;
}
}
@ -285,7 +285,7 @@ class OtaCoreService {
bool rightValid = rightBattery > 0 & & rightBattery ! = 127 ;
bool rightValid = rightBattery > 0 & & rightBattery ! = 127 ;
if ( ! leftValid | | ! rightValid ) {
if ( ! leftValid | | ! rightValid ) {
_showBatteryCheckFailedSnackbar ( ' 无法获取有效的电量信息 ' ) ;
_showBatteryCheckFailedSnackbar ( ' otaCannotGetBatteryInfo ' . tr ) ;
return false ;
return false ;
}
}
@ -314,15 +314,15 @@ class OtaCoreService {
/ / / [ earSide ] 耳 机 端 ( 左 耳 / 右 耳 )
/ / / [ earSide ] 耳 机 端 ( 左 耳 / 右 耳 )
/ / / [ batteryLevel ] 电 量 百 分 比
/ / / [ batteryLevel ] 电 量 百 分 比
void _showSingleHeadsetLowBatteryDialog ( String earSide , int batteryLevel ) {
void _showSingleHeadsetLowBatteryDialog ( String earSide , int batteryLevel ) {
String message = ' 设备电量不足,无法进行固件升级 \n ' ;
String message = ' otaSingleBatteryLow ' . trParams ( {
message + = ' 升级要求:设备电量需大于20% \n ' ;
' ear ' : earSide ,
message + = ' 当前电量: $ earSide ${ batteryLevel } % \n ' ;
' battery ' : batteryLevel . toString ( ) ,
message + = ' 请充电后再试 ' ;
} ) ;
Get . dialog (
Get . dialog (
AlertDialog (
AlertDialog (
title: Text (
title: Text (
' 电量不足 ' ,
' otaLowBattery ' . tr ,
style: TextStyle (
style: TextStyle (
color: Colors . orange [ 700 ] ,
color: Colors . orange [ 700 ] ,
fontWeight: FontWeight . w600 ,
fontWeight: FontWeight . w600 ,
@ -340,7 +340,7 @@ class OtaCoreService {
style: TextButton . styleFrom (
style: TextButton . styleFrom (
foregroundColor: Colors . orange [ 700 ] ,
foregroundColor: Colors . orange [ 700 ] ,
) ,
) ,
child: const Text ( ' 确定 ' ) ,
child: Text ( ' okConfirm ' . tr ) ,
) ,
) ,
] ,
] ,
shape: RoundedRectangleBorder (
shape: RoundedRectangleBorder (
@ -359,15 +359,15 @@ class OtaCoreService {
/ / / [ leftBattery ] 左 耳 电 量
/ / / [ leftBattery ] 左 耳 电 量
/ / / [ rightBattery ] 右 耳 电 量
/ / / [ rightBattery ] 右 耳 电 量
void _showLowBatteryDialog ( int leftBattery , int rightBattery ) {
void _showLowBatteryDialog ( int leftBattery , int rightBattery ) {
String message = ' 设备电量不足,无法进行固件升级 \n ' ;
String message = ' otaDoubleBatteryLow ' . trParams ( {
message + = ' 升级要求:左右耳电量均需大于20% \n ' ;
' left ' : leftBattery . toString ( ) ,
message + = ' 当前电量:左耳 ${ leftBattery } %,右耳 ${ rightBattery } % \n ' ;
' right ' : rightBattery . toString ( ) ,
message + = ' 请充电后再试 ' ;
} ) ;
Get . dialog (
Get . dialog (
AlertDialog (
AlertDialog (
title: Text (
title: Text (
' 电量不足 ' ,
' otaLowBattery ' . tr ,
style: TextStyle (
style: TextStyle (
color: Colors . orange [ 700 ] ,
color: Colors . orange [ 700 ] ,
fontWeight: FontWeight . w600 ,
fontWeight: FontWeight . w600 ,
@ -385,7 +385,7 @@ class OtaCoreService {
style: TextButton . styleFrom (
style: TextButton . styleFrom (
foregroundColor: Colors . orange [ 700 ] ,
foregroundColor: Colors . orange [ 700 ] ,
) ,
) ,
child: const Text ( ' 确定 ' ) ,
child: Text ( ' okConfirm ' . tr ) ,
) ,
) ,
] ,
] ,
shape: RoundedRectangleBorder (
shape: RoundedRectangleBorder (
@ -404,7 +404,7 @@ class OtaCoreService {
/ / / [ message ] 错 误 信 息
/ / / [ message ] 错 误 信 息
void _showBatteryCheckFailedSnackbar ( String message ) {
void _showBatteryCheckFailedSnackbar ( String message ) {
Get . snackbar (
Get . snackbar (
' 电量检查失败 ' ,
' otaBatteryCheckFailed ' . tr ,
message ,
message ,
snackPosition: SnackPosition . BOTTOM ,
snackPosition: SnackPosition . BOTTOM ,
backgroundColor: Colors . orange [ 600 ] ,
backgroundColor: Colors . orange [ 600 ] ,