Unverified Commit a2ed3ecb authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Revert "Make the 'time to update' message depend up on the channel. (#24173)" (#24320)

This reverts commit 97e03104.

Landing on red to hopefully make less red on the board.

TBR=@goderbauer
parent f2370c4f
...@@ -207,34 +207,20 @@ class FlutterVersion { ...@@ -207,34 +207,20 @@ class FlutterVersion {
/// The amount of time we wait before pinging the server to check for the /// The amount of time we wait before pinging the server to check for the
/// availability of a newer version of Flutter. /// availability of a newer version of Flutter.
@visibleForTesting @visibleForTesting
static const Duration checkAgeConsideredUpToDate = Duration(days: 3); static const Duration kCheckAgeConsideredUpToDate = Duration(days: 3);
/// We warn the user if the age of their Flutter installation is greater than /// We warn the user if the age of their Flutter installation is greater than
/// this duration. The durations are slightly longer than the expected release /// this duration.
/// cadence for each channel, to give the user a grace period before they get
/// notified.
/// ///
/// For example, for the beta channel, this is set to five weeks because /// This is set to 5 weeks because releases are currently around every 4 weeks.
/// beta releases happen approximately every month.
@visibleForTesting @visibleForTesting
static Duration versionAgeConsideredUpToDate(String channel) { static const Duration kVersionAgeConsideredUpToDate = Duration(days: 35);
switch (channel) {
case 'stable':
return const Duration(days: 365 ~/ 2); // Six months
case 'beta':
return const Duration(days: 7 * 8); // Eight weeks
case 'dev':
return const Duration(days: 7 * 4); // Four weeks
default:
return const Duration(days: 7 * 3); // Three weeks
}
}
/// The amount of time we wait between issuing a warning. /// The amount of time we wait between issuing a warning.
/// ///
/// This is to avoid annoying users who are unable to upgrade right away. /// This is to avoid annoying users who are unable to upgrade right away.
@visibleForTesting @visibleForTesting
static const Duration maxTimeSinceLastWarning = Duration(days: 1); static const Duration kMaxTimeSinceLastWarning = Duration(days: 1);
/// The amount of time we pause for to let the user read the message about /// The amount of time we pause for to let the user read the message about
/// outdated Flutter installation. /// outdated Flutter installation.
...@@ -252,7 +238,7 @@ class FlutterVersion { ...@@ -252,7 +238,7 @@ class FlutterVersion {
static Future<void> resetFlutterVersionFreshnessCheck() async { static Future<void> resetFlutterVersionFreshnessCheck() async {
try { try {
await Cache.instance.getStampFileFor( await Cache.instance.getStampFileFor(
VersionCheckStamp.flutterVersionCheckStampFile, VersionCheckStamp.kFlutterVersionCheckStampFile,
).delete(); ).delete();
} on FileSystemException { } on FileSystemException {
// Ignore, since we don't mind if the file didn't exist in the first place. // Ignore, since we don't mind if the file didn't exist in the first place.
...@@ -272,7 +258,7 @@ class FlutterVersion { ...@@ -272,7 +258,7 @@ class FlutterVersion {
final DateTime localFrameworkCommitDate = DateTime.parse(frameworkCommitDate); final DateTime localFrameworkCommitDate = DateTime.parse(frameworkCommitDate);
final Duration frameworkAge = _clock.now().difference(localFrameworkCommitDate); final Duration frameworkAge = _clock.now().difference(localFrameworkCommitDate);
final bool installationSeemsOutdated = frameworkAge > versionAgeConsideredUpToDate(channel); final bool installationSeemsOutdated = frameworkAge > kVersionAgeConsideredUpToDate;
// Get whether there's a newer version on the remote. This only goes // Get whether there's a newer version on the remote. This only goes
// to the server if we haven't checked recently so won't happen on every // to the server if we haven't checked recently so won't happen on every
...@@ -287,8 +273,8 @@ class FlutterVersion { ...@@ -287,8 +273,8 @@ class FlutterVersion {
// Do not load the stamp before the above server check as it may modify the stamp file. // Do not load the stamp before the above server check as it may modify the stamp file.
final VersionCheckStamp stamp = await VersionCheckStamp.load(); final VersionCheckStamp stamp = await VersionCheckStamp.load();
final DateTime lastTimeWarningWasPrinted = stamp.lastTimeWarningWasPrinted ?? _clock.ago(maxTimeSinceLastWarning * 2); final DateTime lastTimeWarningWasPrinted = stamp.lastTimeWarningWasPrinted ?? _clock.ago(kMaxTimeSinceLastWarning * 2);
final bool beenAWhileSinceWarningWasPrinted = _clock.now().difference(lastTimeWarningWasPrinted) > maxTimeSinceLastWarning; final bool beenAWhileSinceWarningWasPrinted = _clock.now().difference(lastTimeWarningWasPrinted) > kMaxTimeSinceLastWarning;
// We show a warning if either we know there is a new remote version, or we couldn't tell but the local // We show a warning if either we know there is a new remote version, or we couldn't tell but the local
// version is outdated. // version is outdated.
...@@ -341,7 +327,7 @@ class FlutterVersion { ...@@ -341,7 +327,7 @@ class FlutterVersion {
/// Gets the release date of the latest available Flutter version. /// Gets the release date of the latest available Flutter version.
/// ///
/// This method sends a server request if it's been more than /// This method sends a server request if it's been more than
/// [checkAgeConsideredUpToDate] since the last version check. /// [kCheckAgeConsideredUpToDate] since the last version check.
/// ///
/// Returns null if the cached version is out-of-date or missing, and we are /// Returns null if the cached version is out-of-date or missing, and we are
/// unable to reach the server to get the latest version. /// unable to reach the server to get the latest version.
...@@ -353,7 +339,7 @@ class FlutterVersion { ...@@ -353,7 +339,7 @@ class FlutterVersion {
final Duration timeSinceLastCheck = _clock.now().difference(versionCheckStamp.lastTimeVersionWasChecked); final Duration timeSinceLastCheck = _clock.now().difference(versionCheckStamp.lastTimeVersionWasChecked);
// Don't ping the server too often. Return cached value if it's fresh. // Don't ping the server too often. Return cached value if it's fresh.
if (timeSinceLastCheck < checkAgeConsideredUpToDate) if (timeSinceLastCheck < kCheckAgeConsideredUpToDate)
return versionCheckStamp.lastKnownRemoteVersion; return versionCheckStamp.lastKnownRemoteVersion;
} }
...@@ -395,10 +381,10 @@ class VersionCheckStamp { ...@@ -395,10 +381,10 @@ class VersionCheckStamp {
/// The prefix of the stamp file where we cache Flutter version check data. /// The prefix of the stamp file where we cache Flutter version check data.
@visibleForTesting @visibleForTesting
static const String flutterVersionCheckStampFile = 'flutter_version_check'; static const String kFlutterVersionCheckStampFile = 'flutter_version_check';
static Future<VersionCheckStamp> load() async { static Future<VersionCheckStamp> load() async {
final String versionCheckStamp = Cache.instance.getStampFor(flutterVersionCheckStampFile); final String versionCheckStamp = Cache.instance.getStampFor(kFlutterVersionCheckStampFile);
if (versionCheckStamp != null) { if (versionCheckStamp != null) {
// Attempt to parse stamp JSON. // Attempt to parse stamp JSON.
...@@ -449,8 +435,8 @@ class VersionCheckStamp { ...@@ -449,8 +435,8 @@ class VersionCheckStamp {
if (newTimeWarningWasPrinted != null) if (newTimeWarningWasPrinted != null)
jsonData['lastTimeWarningWasPrinted'] = '$newTimeWarningWasPrinted'; jsonData['lastTimeWarningWasPrinted'] = '$newTimeWarningWasPrinted';
const JsonEncoder prettyJsonEncoder = JsonEncoder.withIndent(' '); const JsonEncoder kPrettyJsonEncoder = JsonEncoder.withIndent(' ');
Cache.instance.setStampFor(flutterVersionCheckStampFile, prettyJsonEncoder.convert(jsonData)); Cache.instance.setStampFor(kFlutterVersionCheckStampFile, kPrettyJsonEncoder.convert(jsonData));
} }
Map<String, String> toJson({ Map<String, String> toJson({
......
...@@ -188,7 +188,7 @@ void main() { ...@@ -188,7 +188,7 @@ void main() {
)).thenAnswer((_) => Future<Process>.value(createMockProcess())); )).thenAnswer((_) => Future<Process>.value(createMockProcess()));
final File versionCheckFile = Cache.instance.getStampFileFor( final File versionCheckFile = Cache.instance.getStampFileFor(
VersionCheckStamp.flutterVersionCheckStampFile, VersionCheckStamp.kFlutterVersionCheckStampFile,
); );
/// Create a bogus "leftover" version check file to make sure it gets /// Create a bogus "leftover" version check file to make sure it gets
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment