Table of Contents

Class AndroidWebAppUpdaterProvider

Namespace
VpnHood.AppLib.Stores.AndroidWeb
Assembly
VpnHood.AppLib.Stores.AndroidWeb.dll

The update of an APK handed out outside the stores. Android's DownloadManager downloads the package in its own process, so a minimized or killed app and a disconnect do not stop it, and a PackageInstaller session installs it once the person confirms. Nothing starts unpressed: the notice offers it, as the person may be on mobile data. The package lives in the app's external cache folder, which no backup takes, named by its version, so what to remove needs no record of its own: DownloadManager lists only this app's downloads. No option keeps a package after its install: it is of no use then. Not in the VPN service: it runs only while connected, Android lets it open no screen from the background, and the install ends its process. DownloadManager takes the network of the app that asked, and this app is always in the tunnel: a download goes direct before a connect, and on through the tunnel after it, from where it was. The implementation rule that an updater runs apart from what it updates cannot hold here, as Android lets no app run one: Android's process downloads and its installer installs, only the press is the app's, and an app that no longer starts is updated from the website.

public class AndroidWebAppUpdaterProvider : IAppUpdaterProvider
Inheritance
AndroidWebAppUpdaterProvider
Implements
Inherited Members

Properties

FeedDistribution

The feed this install reads, as AppConfigs.GetUpdateInfoUrl names it: in an arm64 process the arm64 APK's, a third the size, else the universal APK's. The process decides, not the build: the universal APK on an arm64 phone runs as arm64 too, so it moves to the arm64 APK at its next update. Every release publishes both feeds (pub/lib/Publish-GithubRelease.ps1); never name another.

public static string FeedDistribution { get; }

Property Value

string

HasOwnScreen

Gets a value indicating whether a store's own screen shows the update, where the person decides: the check opens it by itself after a delay, the store's offer keeps the feed's notice away, and its "none" before a connect waits for the connect; otherwise, the app's notice offers the update, which starts at the person's press, or by itself where the channel's automatic update is on (IsAutomaticUpdateSupported).

public bool HasOwnScreen { get; }

Property Value

bool

Remarks

It is false: the app's notice offers the update.

IsAutomaticUpdateSupported

Gets a value indicating whether the app turns the channel's automatic update on and off, as a desktop's own updater does; a store's is the store's own setting.

public bool IsAutomaticUpdateSupported { get; }

Property Value

bool

Remarks

It is false: the website's APK updates only from the notice.

IsInstalling

Gets a value indicating whether an install the app runs itself, and waits on, is under way, which stops the app once it puts the new version in; the app refuses connects meanwhile.

public bool IsInstalling { get; }

Property Value

bool

Remarks

It is a desktop's: a store's install and Android's package installer are the system's, which stops the app itself.

Methods

Check(AppRelease?, IUiContext?, CancellationToken)

Asks the channel for an update now, which may take the network.

public Task<AppUpdateState> Check(AppRelease? feedRelease, IUiContext? uiContext, CancellationToken cancellationToken)

Parameters

feedRelease AppRelease

The feed's newer release, or null.

uiContext IUiContext

The app's window, or null where none is open.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<AppUpdateState>

A task whose result is the update as it stands.

Remarks

It takes no network: it asks Android whether this install may update itself, then reads DownloadManager's list. An install a store keeps updated has no update here. It does not watch the cancellation token.

Exceptions

UiContextNotAvailableException

uiContext is null, and the channel needs a window, as a store's.

TimeoutException

The store did not answer its query in time, as Google Play's.

NotSupportedException

The store needs a desktop window, which the UI context is not, as the Microsoft Store's.

OperationCanceledException

cancellationToken was canceled.

InvalidOperationException

The device has no DownloadManager, the app has no package manager, or its external cache folder is not available.

CompleteUpdate(AppRelease?, IUiContext?, CancellationToken)

Installs the downloaded update: the person's Install, where the channel stops after the download.

public Task CompleteUpdate(AppRelease? feedRelease, IUiContext? uiContext, CancellationToken cancellationToken)

Parameters

feedRelease AppRelease

The feed's newer release, or null.

uiContext IUiContext

The app's window, or null where none is open.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once the install has started, or, where the system must first let the app install apps (IsInstallPermissionNeeded), once the system's page for it is open.

Remarks

Where Android must first let the app install apps ("Install unknown apps"), it opens that page and returns, and the person's next Install installs; otherwise it hands the package to Android's installer, whose own screen asks the person, and returns once the package is handed over. It watches the cancellation token only while it copies the package.

Exceptions

NotSupportedException

The channel has no such step.

InvalidOperationException

There is no newer version, or its update is not downloaded.

UiContextNotAvailableException

The channel needs a compatible UI context, as Android's, and uiContext is null or not one.

OperationCanceledException

cancellationToken was canceled.

InvalidOperationException

feedRelease is null, its update is not downloaded, or a step of the install fails, as for an activity without a package manager.

NotSupportedException

This install does not update itself, as a store keeps it updated.

UiContextNotAvailableException

uiContext is not an Android activity's UI context.

Create()

The updater of the website's APK. Where this install may not take the package - a store installed the app and keeps it updated - it offers nothing, and the notice keeps the feed's link. It checks no key: Android itself refuses a package signed with another key than the installed app's.

public static AndroidWebAppUpdaterProvider Create()

Returns

AndroidWebAppUpdaterProvider

The updater.

GetState(AppRelease?)

Gets the update as it stands, which the notice reads whenever it refreshes: it takes no network. With no release, what an earlier one left behind goes.

public AppUpdateState GetState(AppRelease? feedRelease)

Parameters

feedRelease AppRelease

The feed's newer release, or null.

Returns

AppUpdateState

The update's state; none where the channel does not update this copy, whose notice keeps the feed's link.

Remarks

It reads Android's DownloadManager: another version's package is removed, and so is a failed download, whose reason the notice shows; a package gone from the cache folder is downloaded anew at the next Update.

Exceptions

InvalidOperationException

The device has no DownloadManager, the app has no package manager, or its external cache folder is not available.

IsAutomaticUpdateOn(CancellationToken)

Gets whether the automatic update is on, read where the platform keeps it each time, as its installer and its own tools change it too.

public Task<bool> IsAutomaticUpdateOn(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<bool>

A task whose result is true where it is on.

Remarks

It always throws NotSupportedException.

Exceptions

NotSupportedException

The channel has no such switch.

OperationCanceledException

cancellationToken was canceled.

ResumeUpdate(IUiContext, CancellationToken)

Brings back the screen of an update the person started and left before it finished; the app asks it with a window in front, apart from the checks' interval.

public Task<bool> ResumeUpdate(IUiContext uiContext, CancellationToken cancellationToken)

Parameters

uiContext IUiContext

The app's window.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<bool>

A task whose result is false where there is no such update.

Remarks

It gives false: this provider resumes no installer session.

Exceptions

TimeoutException

The store did not answer its query in time, as Google Play's.

OperationCanceledException

cancellationToken was canceled.

SetAutomaticUpdate(bool, CancellationToken)

Turns the automatic update on or off; off stops only the automatic update, as the person's check, Update and Install still work.

public Task SetAutomaticUpdate(bool isOn, CancellationToken cancellationToken)

Parameters

isOn bool

true to turn it on.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once it is set.

Remarks

It always throws NotSupportedException.

Exceptions

NotSupportedException

The channel has no such switch.

InvalidOperationException

The platform's command failed, as Linux's systemctl.

OperationCanceledException

cancellationToken was canceled.

StartUpdate(AppRelease?, IUiContext?, CancellationToken)

Starts the update: the person's Update, or the store's screen the check opens.

public Task StartUpdate(AppRelease? feedRelease, IUiContext? uiContext, CancellationToken cancellationToken)

Parameters

feedRelease AppRelease

The feed's newer release, or null.

uiContext IUiContext

The app's window, or null where none is open.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes at the channel's own stage: once the download has begun, where the app downloads the update; once the store's page is open, as the App Store's; once the store's update flow has ended, installed or dismissed, as Google Play's; or once the store's own download and install have ended, as the Microsoft Store's.

Remarks

Android's DownloadManager downloads the release's package, with its own notification, and the task completes once the download is queued; while one of the release is under way, or its install, it does nothing. It does not watch the cancellation token.

Exceptions

InvalidOperationException

There is no newer version to update to, the store has none to show, the store's update failed, or the release's package is not on https, as the desktop's refuses.

NotSupportedException

This copy cannot take the release, as the website's APK refuses a package that is not on https, or the store needs a desktop window, which the UI context is not, as the Microsoft Store's.

TimeoutException

The store did not answer its query in time, as Google Play's.

UiContextNotAvailableException

uiContext is null, and the channel needs a window, as a store's.

OperationCanceledException

cancellationToken was canceled.

InvalidOperationException

feedRelease is null, the device has no DownloadManager, the app has no package manager, or its external cache folder is not available.

NotSupportedException

This install does not update itself, as a store keeps it updated, or the release's package is not on https; a debuggable build also takes http on the loopback, for a test feed.

ArgumentNullException

The app has no package name or package manager.