Public Access
The Android head had no updater and no release path, and the two are one problem: Android refuses an update signed by a different key, and CI generates a fresh debug key in every container. An APK released from a workflow could be installed once and never updated again — each new one an uninstall, which on this product means losing the cache, the outbox and the device key. So there are two channels, and they are two applications because the platform gives no third option. dev.dodotech.dodossh is cut from a v* tag by a person running scripts/release-android.ps1 with the key ADR 0011 rule 1 keeps off runners. dev.dodotech.dodossh.nightly is cut from main by CI and signed with a keystore committed here in the open — a key everybody has cannot be stolen and grants nothing by being held, which is why putting it in CI does not touch the rule. Neither can update the other, by construction. See ADR 0014. The android job assumed an image with a JDK and an Android SDK on it, which is what a GitHub runner is and what this project's is not. It now installs a JDK, fetches Google's command-line tools, accepts the licences and installs API 36 — each a no-op where it is already satisfied, and each cached by the persistent runner's own disk rather than by an action that would move a quarter of a gigabyte to rebuild a directory that never left. The client reads a small JSON manifest beside the APK, the counterpart of releases.win.json, and compares Android's versionCode rather than a version name: that integer is what the platform itself uses to accept or refuse an install, so comparing anything else would offer updates the phone then rejects. It fetches, and then asks Android to ask — the system draws its own confirmation, and from API 26 will not draw even that until unknown sources is on for this application. IUpdateChannel gained ApplyingEndsTheProcess. On Windows applying replaces the files and restarts, so the shell disposes the vault first and that is what zeroes the keys. On the phone the install is a request and the answer may be no, so disposing first would answer "not now" with a locked keychain and every shell closed — a punishment for declining an update. Two measured bugs found on the way, both older than this work and both invisible to a -getProperty check. ApplicationDisplayVersion is read by the Android targets in a top-level PropertyGroup, so the target setting it from MinVer ran after the only thing that reads it: every APK ever built here said versionName 1.0.0. And nothing found so far varies the launcher name per channel — four mechanisms tried, all of them recorded in platform-flags, none of them reaching the label the launcher shows. The two channels share an icon name for now and are told apart by package name, version, and what the preferences screen says.
102 lines
3.5 KiB
C#
102 lines
3.5 KiB
C#
using DodoSSH.Client.Session;
|
|
|
|
namespace DodoSSH.Client.App.Tests;
|
|
|
|
/// <summary>
|
|
/// A release channel that answers whatever the test tells it to.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// <b><see cref="ApplyAndRestart"/> records the call instead of making it, and that is the whole reason
|
|
/// <c>IUpdateChannel</c> exists as an interface.</b> The real one replaces the running process and never
|
|
/// returns, so a test could not observe it at all — and the single most important thing to be able to
|
|
/// assert about this feature is a negative: that a downloaded update is <em>never</em> applied unless
|
|
/// somebody pressed the button. A counter is what makes that assertion writable.
|
|
/// </para>
|
|
/// <para>
|
|
/// <see cref="HoldDownload"/> exists for the same reason in the other direction: without a way to stop a
|
|
/// download halfway, the Downloading state would be a state no test could ever catch the view model in.
|
|
/// </para>
|
|
/// </remarks>
|
|
internal sealed class FakeUpdateChannel : IUpdateChannel
|
|
{
|
|
/// <summary>What the next check finds. Null means this build is current.</summary>
|
|
internal AvailableUpdate? Available { get; set; }
|
|
|
|
/// <summary>When set, checking throws it.</summary>
|
|
internal Exception? CheckFailure { get; set; }
|
|
|
|
/// <summary>When set, downloading throws it.</summary>
|
|
internal Exception? DownloadFailure { get; set; }
|
|
|
|
/// <summary>When set, a download waits on it before completing.</summary>
|
|
internal TaskCompletionSource? HoldDownload { get; set; }
|
|
|
|
/// <summary>The percentages a download reports on its way through.</summary>
|
|
internal IReadOnlyList<int> ProgressSteps { get; set; } = [25, 50, 100];
|
|
|
|
internal int Checks { get; private set; }
|
|
|
|
internal int Downloads { get; private set; }
|
|
|
|
internal int Restarts { get; private set; }
|
|
|
|
internal AvailableUpdate? RestartedWith { get; private set; }
|
|
|
|
/// <inheritdoc />
|
|
public bool IsSupported { get; set; } = true;
|
|
|
|
/// <summary>Settable, because the two heads answer it differently and both paths need driving.</summary>
|
|
/// <remarks>
|
|
/// True is the desktop's: the shell disposes itself before applying. False is the phone's, where the
|
|
/// install can be declined — and the test that matters is that declining leaves a working session
|
|
/// rather than a torn-down one.
|
|
/// </remarks>
|
|
public bool ApplyingEndsTheProcess { get; set; } = true;
|
|
|
|
/// <inheritdoc />
|
|
public string CurrentVersion { get; set; } = "1.0.0";
|
|
|
|
/// <inheritdoc />
|
|
public Task<AvailableUpdate?> CheckAsync(CancellationToken cancellationToken)
|
|
{
|
|
Checks++;
|
|
|
|
return CheckFailure is { } failure
|
|
? Task.FromException<AvailableUpdate?>(failure)
|
|
: Task.FromResult(Available);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task DownloadAsync(
|
|
AvailableUpdate update,
|
|
IProgress<int> progress,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
Downloads++;
|
|
|
|
if (DownloadFailure is { } failure)
|
|
{
|
|
throw failure;
|
|
}
|
|
|
|
if (HoldDownload is { } gate)
|
|
{
|
|
await gate.Task.WaitAsync(cancellationToken).ConfigureAwait(false);
|
|
}
|
|
|
|
foreach (var percent in ProgressSteps)
|
|
{
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
progress.Report(percent);
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void ApplyAndRestart(AvailableUpdate update)
|
|
{
|
|
Restarts++;
|
|
RestartedWith = update;
|
|
}
|
|
}
|