rename App.upstreamVersionCode to suggestedVersionCode #1063

parent 10808e2f
......@@ -170,14 +170,11 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
public String suggestedVersionName;
/**
* The index-v1 metadata uses the term `suggestedVersionCode` but we need that
* value to end up in the `upstreamVersionCode` property here. These variables
* need to be renamed across the whole F-Droid ecosystem to make sense.
* This matches {@code CurrentVersionCode} in build metadata files.
*
* @see <a href="https://gitlab.com/fdroid/fdroidclient/issues/1063">issue #1063</a>
* @see <a href="https://f-droid.org/docs/Build_Metadata_Reference/#CurrentVersionCode">CurrentVersionCode</a>
*/
@JsonProperty("suggestedVersionCode")
public int upstreamVersionCode;
public int suggestedVersionCode;
/**
* Unlike other public fields, this is only accessible via a getter, to
......@@ -317,8 +314,8 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
case Cols.AUTO_INSTALL_VERSION_CODE:
autoInstallVersionCode = cursor.getInt(i);
break;
case Cols.UPSTREAM_VERSION_CODE:
upstreamVersionCode = cursor.getInt(i);
case Cols.SUGGESTED_VERSION_CODE:
suggestedVersionCode = cursor.getInt(i);
break;
case Cols.SUGGESTED_VERSION_NAME:
suggestedVersionName = cursor.getString(i);
......@@ -966,7 +963,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
values.put(Cols.PREFERRED_SIGNER, preferredSigner);
values.put(Cols.AUTO_INSTALL_VERSION_CODE, autoInstallVersionCode);
values.put(Cols.SUGGESTED_VERSION_NAME, suggestedVersionName);
values.put(Cols.UPSTREAM_VERSION_CODE, upstreamVersionCode);
values.put(Cols.SUGGESTED_VERSION_CODE, suggestedVersionCode);
values.put(Cols.ForWriting.Categories.CATEGORIES, Utils.serializeCommaSeparatedString(categories));
values.put(Cols.ANTI_FEATURES, Utils.serializeCommaSeparatedString(antiFeatures));
values.put(Cols.REQUIREMENTS, Utils.serializeCommaSeparatedString(requirements));
......@@ -1192,7 +1189,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
dest.writeString(this.liberapayID);
dest.writeString(this.preferredSigner);
dest.writeString(this.suggestedVersionName);
dest.writeInt(this.upstreamVersionCode);
dest.writeInt(this.suggestedVersionCode);
dest.writeString(this.autoInstallVersionName);
dest.writeInt(this.autoInstallVersionCode);
dest.writeLong(this.added != null ? this.added.getTime() : -1);
......@@ -1243,7 +1240,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
this.liberapayID = in.readString();
this.preferredSigner = in.readString();
this.suggestedVersionName = in.readString();
this.upstreamVersionCode = in.readInt();
this.suggestedVersionCode = in.readInt();
this.autoInstallVersionName = in.readString();
this.autoInstallVersionCode = in.readInt();
long tmpAdded = in.readLong();
......
......@@ -1098,7 +1098,7 @@ public class AppProvider extends FDroidProvider {
final String installed = InstalledAppTable.NAME;
final boolean unstableUpdates = Preferences.get().getUnstableUpdates();
String restrictToStable = unstableUpdates ? "" : (apk + "." + ApkTable.Cols.VERSION_CODE + " <= " + app + "." + Cols.UPSTREAM_VERSION_CODE + " AND ");
String restrictToStable = unstableUpdates ? "" : (apk + "." + ApkTable.Cols.VERSION_CODE + " <= " + app + "." + Cols.SUGGESTED_VERSION_CODE + " AND ");
String restrictToApp = "";
String[] args = null;
......@@ -1133,7 +1133,7 @@ public class AppProvider extends FDroidProvider {
apk + "." + ApkTable.Cols.SIGNATURE + " IS COALESCE(" + installed + "." + InstalledAppTable.Cols.SIGNATURE + ", " + apk + "." + ApkTable.Cols.SIGNATURE + ") AND " +
restrictToStable +
" ( " + app + "." + Cols.IS_COMPATIBLE + " = 0 OR " + apk + "." + Cols.IS_COMPATIBLE + " = 1 ) ) " +
" WHERE " + Cols.UPSTREAM_VERSION_CODE + " > 0 " + restrictToApp;
" WHERE " + Cols.SUGGESTED_VERSION_CODE + " > 0 " + restrictToApp;
LoggingQuery.execSQL(db(), updateSql, args);
}
......@@ -1159,12 +1159,12 @@ public class AppProvider extends FDroidProvider {
final String[] args;
if (packageName == null) {
restrictToApps = " COALESCE(" + Cols.UPSTREAM_VERSION_CODE + ", 0) = 0 OR " + Cols.AUTO_INSTALL_VERSION_CODE + " IS NULL ";
restrictToApps = " COALESCE(" + Cols.SUGGESTED_VERSION_CODE + ", 0) = 0 OR " + Cols.AUTO_INSTALL_VERSION_CODE + " IS NULL ";
args = null;
} else {
// Don't update an app with an upstream version code, because that would have been updated
// by updateSuggestedFromUpdate(packageName).
restrictToApps = " COALESCE(" + Cols.UPSTREAM_VERSION_CODE + ", 0) = 0 AND " + app + "." + Cols.PACKAGE_ID + " = (" + getPackageIdFromPackageNameQuery() + ") ";
restrictToApps = " COALESCE(" + Cols.SUGGESTED_VERSION_CODE + ", 0) = 0 AND " + app + "." + Cols.PACKAGE_ID + " = (" + getPackageIdFromPackageNameQuery() + ") ";
args = new String[]{packageName};
}
......
......@@ -149,7 +149,7 @@ public class DBHelper extends SQLiteOpenHelper {
+ AppMetadataTable.Cols.PREFERRED_SIGNER + " text,"
+ AppMetadataTable.Cols.AUTO_INSTALL_VERSION_CODE + " text,"
+ AppMetadataTable.Cols.SUGGESTED_VERSION_NAME + " text,"
+ AppMetadataTable.Cols.UPSTREAM_VERSION_CODE + " integer,"
+ AppMetadataTable.Cols.SUGGESTED_VERSION_CODE + " integer,"
+ AppMetadataTable.Cols.ANTI_FEATURES + " string,"
+ AppMetadataTable.Cols.DONATE + " string,"
+ AppMetadataTable.Cols.BITCOIN + " string,"
......
......@@ -274,7 +274,7 @@ public class InstalledAppProvider extends FDroidProvider {
query = new QueryBuilder();
query.addField(Cols._ID);
query.appendField(Cols.APPLICATION_LABEL, null, Schema.AppMetadataTable.Cols.NAME);
query.appendField(Cols.VERSION_CODE, null, AppMetadataTable.Cols.UPSTREAM_VERSION_CODE);
query.appendField(Cols.VERSION_CODE, null, AppMetadataTable.Cols.SUGGESTED_VERSION_CODE);
query.appendField(Cols.VERSION_NAME, null, AppMetadataTable.Cols.SUGGESTED_VERSION_NAME);
query.appendField(PackageTable.Cols.PACKAGE_NAME, PackageTable.NAME,
AppMetadataTable.Cols.Package.PACKAGE_NAME);
......
......@@ -272,7 +272,7 @@ public class RepoXMLHandler extends DefaultHandler {
curapp.suggestedVersionName = str;
break;
case "marketvercode":
curapp.upstreamVersionCode = Utils.parseInt(str, -1);
curapp.suggestedVersionCode = Utils.parseInt(str, -1);
break;
case "categories":
curapp.categories = Utils.parseCommaSeparatedString(str);
......
......@@ -193,7 +193,7 @@ public interface Schema {
String PREFERRED_SIGNER = "preferredSigner";
String AUTO_INSTALL_VERSION_CODE = "suggestedVercode"; // name mismatch from issue #1063
String SUGGESTED_VERSION_NAME = "upstreamVersion"; // name mismatch from issue #1063
String UPSTREAM_VERSION_CODE = "upstreamVercode";
String SUGGESTED_VERSION_CODE = "upstreamVercode"; // name mismatch from issue #1063
String ADDED = "added";
String LAST_UPDATED = "lastUpdated";
String ANTI_FEATURES = "antiFeatures";
......@@ -244,7 +244,7 @@ public interface Schema {
ROW_ID, PACKAGE_ID, REPO_ID, IS_COMPATIBLE, NAME, SUMMARY, ICON, DESCRIPTION,
WHATSNEW, LICENSE, AUTHOR_NAME, AUTHOR_EMAIL, WEBSITE, ISSUE_TRACKER, SOURCE_CODE,
TRANSLATION, VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID, LIBERAPAY_ID,
SUGGESTED_VERSION_NAME, UPSTREAM_VERSION_CODE, ADDED, LAST_UPDATED,
SUGGESTED_VERSION_NAME, SUGGESTED_VERSION_CODE, ADDED, LAST_UPDATED,
ANTI_FEATURES, REQUIREMENTS, ICON_URL,
FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS,
SEVEN_INCH_SCREENSHOTS, TEN_INCH_SCREENSHOTS, TV_SCREENSHOTS, WEAR_SCREENSHOTS,
......@@ -261,7 +261,7 @@ public interface Schema {
_ID, ROW_ID, REPO_ID, IS_COMPATIBLE, NAME, SUMMARY, ICON, DESCRIPTION,
WHATSNEW, LICENSE, AUTHOR_NAME, AUTHOR_EMAIL, WEBSITE, ISSUE_TRACKER, SOURCE_CODE,
TRANSLATION, VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID, LIBERAPAY_ID,
SUGGESTED_VERSION_NAME, UPSTREAM_VERSION_CODE, ADDED, LAST_UPDATED,
SUGGESTED_VERSION_NAME, SUGGESTED_VERSION_CODE, ADDED, LAST_UPDATED,
ANTI_FEATURES, REQUIREMENTS, ICON_URL,
FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS,
SEVEN_INCH_SCREENSHOTS, TEN_INCH_SCREENSHOTS, TV_SCREENSHOTS, WEAR_SCREENSHOTS,
......
......@@ -199,7 +199,7 @@ public class TempAppProvider extends AppProvider {
db.execSQL(copyData(CatJoinTable.Cols.ALL_COLS, mainCat, tempCat, null));
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_id ON " + getTableName() + " (" + Cols.PACKAGE_ID + ");");
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_upstreamVercode ON " + getTableName() + " (" + Cols.UPSTREAM_VERSION_CODE + ");");
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_upstreamVercode ON " + getTableName() + " (" + Cols.SUGGESTED_VERSION_CODE + ");");
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_compatible ON " + getTableName() + " (" + Cols.IS_COMPATIBLE + ");");
}
......
......@@ -94,17 +94,17 @@ public class TestUtils {
return ApkProvider.Helper.findByUri(context, uri, Schema.ApkTable.Cols.ALL);
}
public static App insertApp(Context context, String packageName, String appName, int upstreamVersionCode,
public static App insertApp(Context context, String packageName, String appName, int suggestedVersionCode,
String repoUrl, String preferredSigner) {
Repo repo = ensureRepo(context, repoUrl);
return insertApp(context, packageName, appName, upstreamVersionCode, repo, preferredSigner);
return insertApp(context, packageName, appName, suggestedVersionCode, repo, preferredSigner);
}
public static App insertApp(Context context, String packageName, String appName, int upstreamVersionCode,
public static App insertApp(Context context, String packageName, String appName, int suggestedVersionCode,
Repo repo, String preferredSigner) {
ContentValues values = new ContentValues();
values.put(Schema.AppMetadataTable.Cols.REPO_ID, repo.getId());
values.put(Schema.AppMetadataTable.Cols.UPSTREAM_VERSION_CODE, upstreamVersionCode);
values.put(Schema.AppMetadataTable.Cols.SUGGESTED_VERSION_CODE, suggestedVersionCode);
values.put(Schema.AppMetadataTable.Cols.PREFERRED_SIGNER, preferredSigner);
return Assert.insertApp(context, packageName, appName, values);
}
......
......@@ -95,13 +95,13 @@ public class InstalledAppProviderTest extends FDroidProviderTest {
assertEquals(3, apps.length);
assertEquals(packageName0, apps[0].packageName);
assertEquals("v0", apps[0].suggestedVersionName);
assertEquals(0, apps[0].upstreamVersionCode);
assertEquals(0, apps[0].suggestedVersionCode);
assertEquals(packageName1, apps[1].packageName);
assertEquals("v1", apps[1].suggestedVersionName);
assertEquals(1, apps[1].upstreamVersionCode);
assertEquals(1, apps[1].suggestedVersionCode);
assertEquals(packageName2, apps[2].packageName);
assertEquals("v2", apps[2].suggestedVersionName);
assertEquals(2, apps[2].upstreamVersionCode);
assertEquals(2, apps[2].suggestedVersionCode);
assertNotEquals(packageName0, apps[2].packageName);
}
......
......@@ -44,7 +44,7 @@ public class SuggestedVersionTest extends FDroidProviderTest {
TestUtils.updateDbAfterInserting(context);
assertSuggested("single.app", 2);
// By enabling unstable updates, the "upstreamVersionCode" should get ignored, and we should
// By enabling unstable updates, the "suggestedVersionCode" should get ignored, and we should
// suggest the latest version (3).
Preferences.get().setUnstableUpdates(true);
assertSuggested("single.app", 3);
......@@ -66,7 +66,7 @@ public class SuggestedVersionTest extends FDroidProviderTest {
TestUtils.updateDbAfterInserting(context);
// Given we aren't installed yet, we don't care which signature.
// Just get as close to upstreamVersionCode as possible.
// Just get as close to suggestedVersionCode as possible.
assertSuggested("single.app", 4);
// Now install v1 with the f-droid signature. In response, we should only suggest
......@@ -74,13 +74,13 @@ public class SuggestedVersionTest extends FDroidProviderTest {
InstalledAppTestUtils.install(context, "single.app", 1, "v1", TestUtils.FDROID_CERT);
assertSuggested("single.app", 3, TestUtils.FDROID_SIG, 1);
// This adds the "upstreamVersionCode" version of the app, but signed by f-droid.
// This adds the "suggestedVersionCode" version of the app, but signed by f-droid.
TestUtils.insertApk(context, singleApp, 4, TestUtils.FDROID_SIG);
TestUtils.insertApk(context, singleApp, 5, TestUtils.FDROID_SIG);
TestUtils.updateDbAfterInserting(context);
assertSuggested("single.app", 4, TestUtils.FDROID_SIG, 1);
// Version 5 from F-Droid is not the "upstreamVersionCode", but with beta updates it should
// Version 5 from F-Droid is not the "suggestedVersionCode", but with beta updates it should
// still become the suggested version now.
Preferences.get().setUnstableUpdates(true);
assertSuggested("single.app", 5, TestUtils.FDROID_SIG, 1);
......@@ -111,7 +111,7 @@ public class SuggestedVersionTest extends FDroidProviderTest {
TestUtils.updateDbAfterInserting(context);
// Given we aren't installed yet, we don't care which signature or even which repo.
// Just get as close to upstreamVersionCode as possible.
// Just get as close to suggestedVersionCode as possible.
assertSuggested("single.app", 4);
// Now install v1 with the f-droid signature. In response, we should only suggest
......@@ -119,7 +119,7 @@ public class SuggestedVersionTest extends FDroidProviderTest {
InstalledAppTestUtils.install(context, "single.app", 1, "v1", TestUtils.FDROID_CERT);
assertSuggested("single.app", 3, TestUtils.FDROID_SIG, 1);
// This adds the "upstreamVersionCode" version of the app, but signed by f-droid.
// This adds the "suggestedVersionCode" version of the app, but signed by f-droid.
TestUtils.insertApk(context, mainApp, 4, TestUtils.FDROID_SIG);
TestUtils.insertApk(context, mainApp, 5, TestUtils.FDROID_SIG);
TestUtils.updateDbAfterInserting(context);
......@@ -131,7 +131,7 @@ public class SuggestedVersionTest extends FDroidProviderTest {
InstalledAppTestUtils.install(context, "single.app", 3, "v3", TestUtils.THIRD_PARTY_CERT);
assertSuggested("single.app", 4, TestUtils.THIRD_PARTY_SIG, 3);
// Version 6 from the 3rd party repo is not the "upstreamVersionCode", but with beta updates
// Version 6 from the 3rd party repo is not the "suggestedVersionCode", but with beta updates
// it should still become the suggested version now.
Preferences.get().setUnstableUpdates(true);
assertSuggested("single.app", 6, TestUtils.THIRD_PARTY_SIG, 3);
......@@ -144,7 +144,7 @@ public class SuggestedVersionTest extends FDroidProviderTest {
*/
@Test
public void dontSuggestUpstreamVersions() {
// By setting the "upstreamVersionCode" to 0, we are letting F-Droid choose the highest compatible version.
// By setting the "suggestedVersionCode" to 0, we are letting F-Droid choose the highest compatible version.
App mainApp = TestUtils.insertApp(context, "single.app", "Single App (Main repo)", 0, "https://main.repo",
TestUtils.UPSTREAM_SIG);
......
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