mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Adds a step to the updater to verify that the new .flx package is signed and untampered. Each .flx contains a signed manifest file. The manifest contains a SHA-256 hash of the .flx contents. See bundle.dart for a description of the new .flx format.
33 lines
1.1 KiB
Dart
33 lines
1.1 KiB
Dart
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:math';
|
|
|
|
// This class represents a dot-separated version string. Used for comparing
|
|
// versions.
|
|
// Usage: assert(new Version('1.1.0') < new Version('1.2.1'));
|
|
class Version {
|
|
Version(String versionStr) :
|
|
_parts = versionStr.split('.').map((String val) => int.parse(val)).toList();
|
|
|
|
List<int> _parts;
|
|
|
|
bool operator<(Version other) => _compare(other) < 0;
|
|
bool operator==(dynamic other) => other is Version && _compare(other) == 0;
|
|
bool operator>(Version other) => _compare(other) > 0;
|
|
|
|
int _compare(Version other) {
|
|
int length = min(_parts.length, other._parts.length);
|
|
for (int i = 0; i < length; ++i) {
|
|
if (_parts[i] < other._parts[i])
|
|
return -1;
|
|
if (_parts[i] > other._parts[i])
|
|
return 1;
|
|
}
|
|
return _parts.length - other._parts.length; // results in 1.0 < 1.0.0
|
|
}
|
|
|
|
int get hashCode => _parts.fold(373, (int acc, int part) => 37*acc + part);
|
|
}
|