v0.9.4: added an opt-in for betas in the update checker

This commit is contained in:
Evan Debenham
2021-07-14 16:16:29 -04:00
parent fd0286b9a1
commit 3c3e22d486
7 changed files with 57 additions and 7 deletions

View File

@@ -34,7 +34,10 @@ public abstract class UpdateService {
//whether the app is updateable via an ingame prompt (e.g. not a demo or an android instant app)
public abstract boolean isUpdateable();
public abstract void checkForUpdate( boolean useMetered, UpdateResultCallback callback );
//whether the service supports an opt-in channel for betas
public abstract boolean supportsBetaChannel();
public abstract void checkForUpdate( boolean useMetered, boolean includeBetas, UpdateResultCallback callback );
public abstract void initializeUpdate( AvailableUpdateData update );

View File

@@ -35,7 +35,12 @@ public class DebugUpdates extends UpdateService {
}
@Override
public void checkForUpdate(boolean useMetered, UpdateResultCallback callback) {
public boolean supportsBetaChannel() {
return true;
}
@Override
public void checkForUpdate(boolean useMetered, boolean includeBetas, UpdateResultCallback callback) {
if (!useMetered && !Game.platform.connectedToUnmeteredNetwork()){
callback.onConnectionFailed();

View File

@@ -44,7 +44,12 @@ public class GitHubUpdates extends UpdateService {
}
@Override
public void checkForUpdate(boolean useMetered, UpdateResultCallback callback) {
public boolean supportsBetaChannel() {
return true;
}
@Override
public void checkForUpdate(boolean useMetered, boolean includeBetas, UpdateResultCallback callback) {
if (!useMetered && !Game.platform.connectedToUnmeteredNetwork()){
callback.onConnectionFailed();
@@ -62,15 +67,13 @@ public class GitHubUpdates extends UpdateService {
Bundle latestRelease = null;
int latestVersionCode = Game.versionCode;
boolean includePrereleases = Game.version.contains("-BETA-") || Game.version.contains("-RC-");
for (Bundle b : Bundle.read( httpResponse.getResultAsStream() ).getBundleArray()){
Matcher m = versionCodePattern.matcher(b.getString("body"));
if (m.find()){
int releaseVersion = Integer.parseInt(m.group(1));
if (releaseVersion > latestVersionCode
&& (includePrereleases || !b.getBoolean("prerelease"))){
&& (includeBetas || !b.getBoolean("prerelease"))){
latestRelease = b;
latestVersionCode = releaseVersion;
}