🐛 Fix android build no check

This commit is contained in:
2025-11-23 02:00:13 +08:00
parent 864cbe73b7
commit f1d72a5215

View File

@@ -82,12 +82,32 @@ class _ParsedVersion implements Comparable<_ParsedVersion> {
return _ParsedVersion(major, minor, patch, build); return _ParsedVersion(major, minor, patch, build);
} }
/// Normalize Android build numbers by removing architecture-based offsets
/// Android adds 1000 for x86, 2000 for ARMv7, 4000 for ARMv8
int get normalizedBuild {
// Check if build number has an architecture offset
// We detect this by checking if the build % 1000 is the base build
if (build >= 4000) {
// Likely ARMv8 (arm64-v8a) with +4000 offset
return build % 4000;
} else if (build >= 2000) {
// Likely ARMv7 (armeabi-v7a) with +2000 offset
return build % 2000;
} else if (build >= 1000) {
// Likely x86/x86_64 with +1000 offset
return build % 1000;
}
// No offset, return as-is
return build;
}
@override @override
int compareTo(_ParsedVersion other) { int compareTo(_ParsedVersion other) {
if (major != other.major) return major.compareTo(other.major); if (major != other.major) return major.compareTo(other.major);
if (minor != other.minor) return minor.compareTo(other.minor); if (minor != other.minor) return minor.compareTo(other.minor);
if (patch != other.patch) return patch.compareTo(other.patch); if (patch != other.patch) return patch.compareTo(other.patch);
return build.compareTo(other.build); // Use normalized build numbers for comparison to handle Android arch offsets
return normalizedBuild.compareTo(other.normalizedBuild);
} }
@override @override
@@ -244,13 +264,14 @@ class UpdateService {
showDialog( showDialog(
context: context, context: context,
barrierDismissible: false, barrierDismissible: false,
builder: (context) => _WindowsUpdateDialog( builder:
updateUrl: url, (context) => _WindowsUpdateDialog(
onComplete: () { updateUrl: url,
// Close the update sheet onComplete: () {
Navigator.of(context).pop(); // Close the update sheet
}, Navigator.of(context).pop();
), },
),
); );
} }
@@ -321,7 +342,9 @@ class _WindowsUpdateDialog extends StatefulWidget {
class _WindowsUpdateDialogState extends State<_WindowsUpdateDialog> { class _WindowsUpdateDialogState extends State<_WindowsUpdateDialog> {
final ValueNotifier<double?> progressNotifier = ValueNotifier<double?>(null); final ValueNotifier<double?> progressNotifier = ValueNotifier<double?>(null);
final ValueNotifier<String> messageNotifier = ValueNotifier<String>('Downloading installer...'); final ValueNotifier<String> messageNotifier = ValueNotifier<String>(
'Downloading installer...',
);
@override @override
void initState() { void initState() {
@@ -392,16 +415,17 @@ class _WindowsUpdateDialogState extends State<_WindowsUpdateDialog> {
Navigator.of(context).pop(); Navigator.of(context).pop();
showDialog( showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder:
title: const Text('Update Failed'), (context) => AlertDialog(
content: Text(message), title: const Text('Update Failed'),
actions: [ content: Text(message),
TextButton( actions: [
onPressed: () => Navigator.of(context).pop(), TextButton(
child: const Text('OK'), onPressed: () => Navigator.of(context).pop(),
child: const Text('OK'),
),
],
), ),
],
),
); );
} }
@@ -458,7 +482,9 @@ class _WindowsUpdateDialogState extends State<_WindowsUpdateDialog> {
); );
if (response.statusCode == 200) { if (response.statusCode == 200) {
talker.info('[Update] Windows installer downloaded successfully to: $filePath'); talker.info(
'[Update] Windows installer downloaded successfully to: $filePath',
);
return filePath; return filePath;
} else { } else {
talker.error( talker.error(
@@ -500,7 +526,9 @@ class _WindowsUpdateDialogState extends State<_WindowsUpdateDialog> {
} }
} }
talker.info('[Update] Windows installer extracted successfully to: $extractDir'); talker.info(
'[Update] Windows installer extracted successfully to: $extractDir',
);
return extractDir; return extractDir;
} catch (e) { } catch (e) {
talker.error('[Update] Error extracting Windows installer: $e'); talker.error('[Update] Error extracting Windows installer: $e');
@@ -514,10 +542,11 @@ class _WindowsUpdateDialogState extends State<_WindowsUpdateDialog> {
talker.info('[Update] Running Windows installer from: $extractDir'); talker.info('[Update] Running Windows installer from: $extractDir');
final dir = Directory(extractDir); final dir = Directory(extractDir);
final exeFiles = dir final exeFiles =
.listSync() dir
.where((f) => f is File && f.path.endsWith('.exe')) .listSync()
.toList(); .where((f) => f is File && f.path.endsWith('.exe'))
.toList();
if (exeFiles.isEmpty) { if (exeFiles.isEmpty) {
talker.info('[Update] No .exe file found in extracted directory'); talker.info('[Update] No .exe file found in extracted directory');