Commit 9fca42e2 authored by Hans-Christoph Steiner's avatar Hans-Christoph Steiner

Merge branch 'suggestedVersionName-sync-up' into 'master'

suggestedVersionName sync up

Closes #1063

See merge request !862
parents 92327cbc 3f64fd49
Pipeline #108492123 passed with stages
in 32 minutes and 51 seconds
......@@ -481,7 +481,7 @@ public class IndexUpdater {
}
int versionCode;
if (repoPushRequest.versionCode == null) {
versionCode = app.suggestedVersionCode;
versionCode = app.autoInstallVersionCode;
} else {
versionCode = repoPushRequest.versionCode;
}
......
......@@ -92,7 +92,7 @@ public class ApkProvider extends FDroidProvider {
@Nullable
public static Apk findSuggestedApk(Context context, App app) {
String mostAppropriateSignature = app.getMostAppropriateSignature();
Apk apk = findApkFromAnyRepo(context, app.packageName, app.suggestedVersionCode,
Apk apk = findApkFromAnyRepo(context, app.packageName, app.autoInstallVersionCode,
mostAppropriateSignature);
if (apk == null && (mostAppropriateSignature == null || !app.isInstalled(context))) {
List<Apk> apks = findByPackageName(context, app.packageName);
......
......@@ -162,27 +162,36 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
public String liberapayID;
public String upstreamVersionName;
/**
* This matches {@code CurrentVersion} in build metadata files.
*
* @see <a href="https://f-droid.org/docs/Build_Metadata_Reference/#CurrentVersion">CurrentVersion</a>
*/
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. Java
* inits {@code int}s to 0. Since it is valid to have a negative Version
* Code, this is inited to {@link Integer#MIN_VALUE};
*
* @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 = Integer.MIN_VALUE;
/**
* Unlike other public fields, this is only accessible via a getter, to
* emphasise that setting it wont do anything. In order to change this,
* you need to change suggestedVersionCode to an apk which is in the
* apk table.
* you need to change {@link #autoInstallVersionCode} to an APK which is
* in the {@link Schema.ApkTable} table.
*/
private String suggestedVersionName;
private String autoInstallVersionName;
public int suggestedVersionCode;
/**
* The version that will be automatically installed if the user does not
* choose a specific version.
* TODO this should probably be converted to init to {@link Integer#MIN_VALUE} like {@link #suggestedVersionCode}
*/
public int autoInstallVersionCode;
public Date added;
public Date lastUpdated;
......@@ -299,20 +308,20 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
case Cols.LIBERAPAY_ID:
liberapayID = cursor.getString(i);
break;
case Cols.SuggestedApk.VERSION_NAME:
suggestedVersionName = cursor.getString(i);
case Cols.AutoInstallApk.VERSION_NAME:
autoInstallVersionName = cursor.getString(i);
break;
case Cols.PREFERRED_SIGNER:
preferredSigner = cursor.getString(i);
break;
case Cols.AUTO_INSTALL_VERSION_CODE:
autoInstallVersionCode = cursor.getInt(i);
break;
case Cols.SUGGESTED_VERSION_CODE:
suggestedVersionCode = cursor.getInt(i);
break;
case Cols.UPSTREAM_VERSION_CODE:
upstreamVersionCode = cursor.getInt(i);
break;
case Cols.UPSTREAM_VERSION_NAME:
upstreamVersionName = cursor.getString(i);
case Cols.SUGGESTED_VERSION_NAME:
suggestedVersionName = cursor.getString(i);
break;
case Cols.ADDED:
added = Utils.parseDate(cursor.getString(i), null);
......@@ -955,9 +964,9 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
values.put(Cols.ADDED, Utils.formatDate(added, ""));
values.put(Cols.LAST_UPDATED, Utils.formatDate(lastUpdated, ""));
values.put(Cols.PREFERRED_SIGNER, preferredSigner);
values.put(Cols.AUTO_INSTALL_VERSION_CODE, autoInstallVersionCode);
values.put(Cols.SUGGESTED_VERSION_NAME, suggestedVersionName);
values.put(Cols.SUGGESTED_VERSION_CODE, suggestedVersionCode);
values.put(Cols.UPSTREAM_VERSION_NAME, upstreamVersionName);
values.put(Cols.UPSTREAM_VERSION_CODE, upstreamVersionCode);
values.put(Cols.ForWriting.Categories.CATEGORIES, Utils.serializeCommaSeparatedString(categories));
values.put(Cols.ANTI_FEATURES, Utils.serializeCommaSeparatedString(antiFeatures));
values.put(Cols.REQUIREMENTS, Utils.serializeCommaSeparatedString(requirements));
......@@ -1021,8 +1030,8 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
*/
public boolean hasUpdates() {
boolean updates = false;
if (suggestedVersionCode > 0) {
updates = installedVersionCode > 0 && installedVersionCode < suggestedVersionCode;
if (autoInstallVersionCode > 0) {
updates = installedVersionCode > 0 && installedVersionCode < autoInstallVersionCode;
}
return updates;
}
......@@ -1041,7 +1050,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
public boolean canAndWantToUpdate(Context context) {
boolean canUpdate = hasUpdates();
AppPrefs prefs = getPrefs(context);
boolean wantsUpdate = !prefs.ignoreAllUpdates && prefs.ignoreThisUpdate < suggestedVersionCode;
boolean wantsUpdate = !prefs.ignoreAllUpdates && prefs.ignoreThisUpdate < autoInstallVersionCode;
return canUpdate && wantsUpdate && !isDisabledByAntiFeatures();
}
......@@ -1077,11 +1086,11 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
/**
* @see App#suggestedVersionName for why this uses a getter while other member variables are
* @see App#autoInstallVersionName for why this uses a getter while other member variables are
* publicly accessible.
*/
public String getSuggestedVersionName() {
return suggestedVersionName;
public String getAutoInstallVersionName() {
return autoInstallVersionName;
}
/**
......@@ -1182,10 +1191,10 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
dest.writeString(this.flattrID);
dest.writeString(this.liberapayID);
dest.writeString(this.preferredSigner);
dest.writeString(this.upstreamVersionName);
dest.writeInt(this.upstreamVersionCode);
dest.writeString(this.suggestedVersionName);
dest.writeInt(this.suggestedVersionCode);
dest.writeString(this.autoInstallVersionName);
dest.writeInt(this.autoInstallVersionCode);
dest.writeLong(this.added != null ? this.added.getTime() : -1);
dest.writeLong(this.lastUpdated != null ? this.lastUpdated.getTime() : -1);
dest.writeStringArray(this.categories);
......@@ -1233,10 +1242,10 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
this.flattrID = in.readString();
this.liberapayID = in.readString();
this.preferredSigner = in.readString();
this.upstreamVersionName = in.readString();
this.upstreamVersionCode = in.readInt();
this.suggestedVersionName = in.readString();
this.suggestedVersionCode = in.readInt();
this.autoInstallVersionName = in.readString();
this.autoInstallVersionCode = in.readInt();
long tmpAdded = in.readLong();
this.added = tmpAdded == -1 ? null : new Date(tmpAdded);
long tmpLastUpdated = in.readLong();
......
......@@ -32,17 +32,17 @@ import java.util.Set;
/**
* Each app has a bunch of metadata that it associates with a package name (such as org.fdroid.fdroid).
* Multiple repositories can host the same package, and provide different metadata for that app.
*
* <p>
* As such, it is usually the case that you are interested in an {@link App} which has its metadata
* provided by "the repo with the best priority", rather than "specific repo X". This is important
* when asking for an apk, whereby the preferable way is likely using:
*
* * {@link AppProvider.Helper#findHighestPriorityMetadata(ContentResolver, String)}
*
* <p>
* * {@link AppProvider.Helper#findHighestPriorityMetadata(ContentResolver, String)}
* <p>
* rather than:
*
* * {@link AppProvider.Helper#findSpecificApp(ContentResolver, String, long, String[])}
*
* <p>
* * {@link AppProvider.Helper#findSpecificApp(ContentResolver, String, long, String[])}
* <p>
* The same can be said of retrieving a list of {@link App} objects, where the metadata for each app
* in the result set should be populated from the repository with the best priority.
*/
......@@ -53,7 +53,8 @@ public class AppProvider extends FDroidProvider {
public static final class Helper {
private Helper() { }
private Helper() {
}
public static List<App> all(ContentResolver resolver) {
return all(resolver, Cols.ALL);
......@@ -192,6 +193,7 @@ public class AppProvider extends FDroidProvider {
* Tells the query selection that it will need to join onto the installed apps table
* when used. This should be called when your query makes use of fields from that table
* (for example, list all installed, or list those which can be updated).
*
* @return A reference to this object, to allow method chaining, for example
* <code>return new AppQuerySelection(selection).requiresInstalledTable())</code>
*/
......@@ -361,8 +363,8 @@ public class AppProvider extends FDroidProvider {
case Cols.Package.PACKAGE_NAME:
appendField(PackageTable.Cols.PACKAGE_NAME, PackageTable.NAME, Cols.Package.PACKAGE_NAME);
break;
case Cols.SuggestedApk.VERSION_NAME:
addSuggestedApkVersionField();
case Cols.AutoInstallApk.VERSION_NAME:
addAutoInstallApkVersionField();
break;
case Cols.InstalledApp.VERSION_NAME:
addInstalledAppVersionName();
......@@ -387,19 +389,22 @@ public class AppProvider extends FDroidProvider {
appendField("COUNT( DISTINCT " + getTableName() + "." + Cols.ROW_ID + " ) AS " + Cols._COUNT);
}
private void addSuggestedApkVersionField() {
addSuggestedApkField(
private void addAutoInstallApkVersionField() {
addAutoInstallApkField(
ApkTable.Cols.VERSION_NAME,
Cols.SuggestedApk.VERSION_NAME);
Cols.AutoInstallApk.VERSION_NAME);
}
private void addSuggestedApkField(String fieldName, String alias) {
/**
* @see <a href="https://gitlab.com/fdroid/fdroidclient/issues/1063">suggestedApk name mismatch #1063</a>
*/
private void addAutoInstallApkField(String fieldName, String alias) {
if (!isSuggestedApkTableAdded) {
isSuggestedApkTableAdded = true;
leftJoin(
getApkTableName(),
"suggestedApk",
getTableName() + "." + Cols.SUGGESTED_VERSION_CODE + " = suggestedApk." + ApkTable.Cols.VERSION_CODE + " AND " + getTableName() + "." + Cols.ROW_ID + " = suggestedApk." + ApkTable.Cols.APP_ID);
getTableName() + "." + Cols.AUTO_INSTALL_VERSION_CODE + " = suggestedApk." + ApkTable.Cols.VERSION_CODE + " AND " + getTableName() + "." + Cols.ROW_ID + " = suggestedApk." + ApkTable.Cols.APP_ID);
}
appendField(fieldName, "suggestedApk", alias);
}
......@@ -615,11 +620,11 @@ public class AppProvider extends FDroidProvider {
// Need to use COALESCE because the prefs join may not resolve any rows, which means the
// ignore* fields will be NULL. In that case, we want to instead use a default value of 0.
final String ignoreCurrent = " COALESCE(prefs." + AppPrefsTable.Cols.IGNORE_THIS_UPDATE + ", 0) != " + app + "." + Cols.SUGGESTED_VERSION_CODE;
final String ignoreCurrent = " COALESCE(prefs." + AppPrefsTable.Cols.IGNORE_THIS_UPDATE + ", 0) != " + app + "." + Cols.AUTO_INSTALL_VERSION_CODE;
final String ignoreAll = "COALESCE(prefs." + AppPrefsTable.Cols.IGNORE_ALL_UPDATES + ", 0) != 1";
final String ignore = " (" + ignoreCurrent + " AND " + ignoreAll + ") ";
final String where = ignore + " AND " + app + "." + Cols.SUGGESTED_VERSION_CODE + " > installed." + InstalledAppTable.Cols.VERSION_CODE;
final String where = ignore + " AND " + app + "." + Cols.AUTO_INSTALL_VERSION_CODE + " > installed." + InstalledAppTable.Cols.VERSION_CODE;
return new AppQuerySelection(where).requireNaturalInstalledTable().requireLeftJoinPrefs();
}
......@@ -1093,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;
......@@ -1118,7 +1123,7 @@ public class AppProvider extends FDroidProvider {
// installed table (this is impossible), but rather because the subselect above returned
// zero rows.
String updateSql =
"UPDATE " + app + " SET " + Cols.SUGGESTED_VERSION_CODE + " = ( " +
"UPDATE " + app + " SET " + Cols.AUTO_INSTALL_VERSION_CODE + " = ( " +
" SELECT MAX( " + apk + "." + ApkTable.Cols.VERSION_CODE + " ) " +
" FROM " + apk +
" JOIN " + app + " AS appForThisApk ON (appForThisApk." + Cols.ROW_ID + " = " + apk + "." + ApkTable.Cols.APP_ID + ") " +
......@@ -1128,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);
}
......@@ -1154,17 +1159,17 @@ public class AppProvider extends FDroidProvider {
final String[] args;
if (packageName == null) {
restrictToApps = " COALESCE(" + Cols.UPSTREAM_VERSION_CODE + ", 0) = 0 OR " + Cols.SUGGESTED_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};
}
String updateSql =
"UPDATE " + app + " SET " + Cols.SUGGESTED_VERSION_CODE + " = ( " +
"UPDATE " + app + " SET " + Cols.AUTO_INSTALL_VERSION_CODE + " = ( " +
" SELECT MAX( " + apk + "." + ApkTable.Cols.VERSION_CODE + " ) " +
" FROM " + apk +
" JOIN " + app + " AS appForThisApk ON (appForThisApk." + Cols.ROW_ID + " = " + apk + "." + ApkTable.Cols.APP_ID + ") " +
......
......@@ -147,9 +147,9 @@ public class DBHelper extends SQLiteOpenHelper {
+ AppMetadataTable.Cols.VIDEO + " string, "
+ AppMetadataTable.Cols.CHANGELOG + " text, "
+ AppMetadataTable.Cols.PREFERRED_SIGNER + " text,"
+ AppMetadataTable.Cols.SUGGESTED_VERSION_CODE + " text,"
+ AppMetadataTable.Cols.UPSTREAM_VERSION_NAME + " text,"
+ AppMetadataTable.Cols.UPSTREAM_VERSION_CODE + " integer,"
+ AppMetadataTable.Cols.AUTO_INSTALL_VERSION_CODE + " text,"
+ AppMetadataTable.Cols.SUGGESTED_VERSION_NAME + " text,"
+ AppMetadataTable.Cols.SUGGESTED_VERSION_CODE + " integer,"
+ AppMetadataTable.Cols.ANTI_FEATURES + " string,"
+ AppMetadataTable.Cols.DONATE + " string,"
+ AppMetadataTable.Cols.BITCOIN + " string,"
......
......@@ -274,8 +274,8 @@ 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_NAME, null, AppMetadataTable.Cols.UPSTREAM_VERSION_NAME);
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);
break;
......
......@@ -269,10 +269,10 @@ public class RepoXMLHandler extends DefaultHandler {
curapp.lastUpdated = Utils.parseDate(str, null);
break;
case "marketversion":
curapp.upstreamVersionName = str;
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);
......
......@@ -191,9 +191,9 @@ public interface Schema {
String FLATTR_ID = "flattrID";
String LIBERAPAY_ID = "liberapayID";
String PREFERRED_SIGNER = "preferredSigner";
String SUGGESTED_VERSION_CODE = "suggestedVercode";
String UPSTREAM_VERSION_NAME = "upstreamVersion";
String UPSTREAM_VERSION_CODE = "upstreamVercode";
String AUTO_INSTALL_VERSION_CODE = "suggestedVercode"; // name mismatch from issue #1063
String SUGGESTED_VERSION_NAME = "upstreamVersion"; // name mismatch from issue #1063
String SUGGESTED_VERSION_CODE = "upstreamVercode"; // name mismatch from issue #1063
String ADDED = "added";
String LAST_UPDATED = "lastUpdated";
String ANTI_FEATURES = "antiFeatures";
......@@ -210,7 +210,7 @@ public interface Schema {
String IS_APK = "isApk";
String IS_LOCALIZED = "isLocalized";
interface SuggestedApk {
interface AutoInstallApk {
String VERSION_NAME = "suggestedApkVersion";
}
......@@ -238,17 +238,17 @@ public interface Schema {
/**
* Each of the physical columns in the sqlite table. Differs from {@link Cols#ALL} in
* that it doesn't include fields which are aliases of other fields (e.g. {@link Cols#_ID}
* or which are from other related tables (e.g. {@link Cols.SuggestedApk#VERSION_NAME}).
* or which are from other related tables (e.g. {@link AutoInstallApk#VERSION_NAME}).
*/
String[] ALL_COLS = {
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,
UPSTREAM_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,
PREFERRED_SIGNER, SUGGESTED_VERSION_CODE, IS_APK, IS_LOCALIZED,
PREFERRED_SIGNER, AUTO_INSTALL_VERSION_CODE, IS_APK, IS_LOCALIZED,
};
/**
......@@ -261,11 +261,11 @@ 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,
UPSTREAM_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,
PREFERRED_SIGNER, SUGGESTED_VERSION_CODE, IS_APK, IS_LOCALIZED, SuggestedApk.VERSION_NAME,
PREFERRED_SIGNER, AUTO_INSTALL_VERSION_CODE, IS_APK, IS_LOCALIZED, AutoInstallApk.VERSION_NAME,
InstalledApp.VERSION_CODE, InstalledApp.VERSION_NAME,
InstalledApp.SIGNATURE, Package.PACKAGE_NAME,
};
......
......@@ -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 + ");");
}
......
......@@ -250,7 +250,7 @@ public class AppDetailsActivity extends AppCompatActivity
MenuItem itemIgnoreThis = menu.findItem(R.id.action_ignore_this);
if (itemIgnoreThis != null) {
itemIgnoreThis.setVisible(app.hasUpdates());
itemIgnoreThis.setChecked(app.getPrefs(this).ignoreThisUpdate >= app.suggestedVersionCode);
itemIgnoreThis.setChecked(app.getPrefs(this).ignoreThisUpdate >= app.autoInstallVersionCode);
}
return true;
}
......@@ -274,10 +274,10 @@ public class AppDetailsActivity extends AppCompatActivity
AppPrefsProvider.Helper.update(this, app, app.getPrefs(this));
return true;
} else if (item.getItemId() == R.id.action_ignore_this) {
if (app.getPrefs(this).ignoreThisUpdate >= app.suggestedVersionCode) {
if (app.getPrefs(this).ignoreThisUpdate >= app.autoInstallVersionCode) {
app.getPrefs(this).ignoreThisUpdate = 0;
} else {
app.getPrefs(this).ignoreThisUpdate = app.suggestedVersionCode;
app.getPrefs(this).ignoreThisUpdate = app.autoInstallVersionCode;
}
item.setChecked(app.getPrefs(this).ignoreThisUpdate > 0);
AppPrefsProvider.Helper.update(this, app, app.getPrefs(this));
......
......@@ -239,7 +239,7 @@ public class AppDetailsRecyclerViewAdapter
String appropriateSig = app.getMostAppropriateSignature();
for (int i = 0; i < versions.size(); i++) {
final Apk apk = versions.get(i);
if (apk.versionCode == app.suggestedVersionCode && TextUtils.equals(apk.sig, appropriateSig)) {
if (apk.versionCode == app.autoInstallVersionCode && TextUtils.equals(apk.sig, appropriateSig)) {
curApk = apk;
break;
}
......@@ -1104,7 +1104,7 @@ public class AppDetailsRecyclerViewAdapter
boolean isAppInstalled = app.isInstalled(context);
boolean isApkInstalled = apk.versionCode == app.installedVersionCode &&
TextUtils.equals(apk.sig, app.installedSig);
boolean isApkSuggested = apk.versionCode == app.suggestedVersionCode &&
boolean isApkSuggested = apk.versionCode == app.autoInstallVersionCode &&
TextUtils.equals(apk.sig, app.getMostAppropriateSignature());
boolean isApkDownloading = callbacks.isAppDownloading() && downloadedApk != null &&
downloadedApk.compareTo(apk) == 0 && TextUtils.equals(apk.apkName, downloadedApk.apkName);
......
......@@ -40,7 +40,7 @@ public class StandardAppListItemController extends AppListItemController {
return activity.getString(R.string.antifeatures);
} else if (app.isInstalled(activity.getApplicationContext())) {
if (app.canAndWantToUpdate(activity)) {
return activity.getString(R.string.app_version_x_available, app.getSuggestedVersionName());
return activity.getString(R.string.app_version_x_available, app.getAutoInstallVersionName());
} else {
return activity.getString(R.string.app_version_x_installed, app.installedVersionName);
}
......
......@@ -35,7 +35,7 @@ public class InstalledAppListItemController extends AppListItemController {
* Either "Version X" or "Version Y (Recommended)", depending on the installed version.
*/
private CharSequence getInstalledVersion(@NonNull App app) {
int statusStringRes = (app.suggestedVersionCode == app.installedVersionCode)
int statusStringRes = (app.autoInstallVersionCode == app.installedVersionCode)
? R.string.app_recommended_version_installed
: R.string.app_version_x_installed;
......@@ -51,10 +51,10 @@ public class InstalledAppListItemController extends AppListItemController {
AppPrefs prefs = app.getPrefs(activity);
if (prefs.ignoreAllUpdates) {
return activity.getString(R.string.installed_app__updates_ignored);
} else if (prefs.ignoreThisUpdate > 0 && prefs.ignoreThisUpdate == app.suggestedVersionCode) {
} else if (prefs.ignoreThisUpdate > 0 && prefs.ignoreThisUpdate == app.autoInstallVersionCode) {
return activity.getString(
R.string.installed_app__updates_ignored_for_suggested_version,
app.getSuggestedVersionName());
app.getAutoInstallVersionName());
}
return null;
......
......@@ -42,7 +42,7 @@ public class UpdateableAppListItemController extends AppListItemController {
@Override
protected void onDismissApp(@NonNull final App app, UpdatesAdapter adapter) {
final AppPrefs prefs = app.getPrefs(activity);
prefs.ignoreThisUpdate = app.suggestedVersionCode;
prefs.ignoreThisUpdate = app.autoInstallVersionCode;
Snackbar.make(
itemView,
......
......@@ -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);
}
......
......@@ -94,14 +94,14 @@ public class InstalledAppProviderTest extends FDroidProviderTest {
apps = InstalledAppProvider.Helper.all(context);
assertEquals(3, apps.length);
assertEquals(packageName0, apps[0].packageName);
assertEquals("v0", apps[0].upstreamVersionName);
assertEquals(0, apps[0].upstreamVersionCode);
assertEquals("v0", apps[0].suggestedVersionName);
assertEquals(0, apps[0].suggestedVersionCode);
assertEquals(packageName1, apps[1].packageName);
assertEquals("v1", apps[1].upstreamVersionName);
assertEquals(1, apps[1].upstreamVersionCode);
assertEquals("v1", apps[1].suggestedVersionName);
assertEquals(1, apps[1].suggestedVersionCode);
assertEquals(packageName2, apps[2].packageName);
assertEquals("v2", apps[2].upstreamVersionName);
assertEquals(2, apps[2].upstreamVersionCode);
assertEquals("v2", apps[2].suggestedVersionName);
assertEquals(2, apps[2].suggestedVersionCode);
assertNotEquals(packageName0, apps[2].packageName);
}
......
......@@ -273,7 +273,7 @@ public class PreferredSignatureTest extends FDroidProviderTest {
private void assertSuggested(Context context, int suggestedVersion, String suggestedSig) {
App suggestedApp = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), PACKAGE_NAME);
assertEquals("Suggested version on App", suggestedVersion, suggestedApp.suggestedVersionCode);
assertEquals("Suggested version on App", suggestedVersion, suggestedApp.autoInstallVersionCode);
Apk suggestedApk = ApkProvider.Helper.findSuggestedApk(context, suggestedApp);
assertEquals("Version on suggested Apk", suggestedVersion, suggestedApk.versionCode);
......
......@@ -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);
......@@ -195,7 +195,7 @@ public class SuggestedVersionTest extends FDroidProviderTest {
*/
public void assertSuggested(String packageName, int suggestedVersion, String installedSig, int installedVersion) {
App suggestedApp = AppProvider.Helper.findHighestPriorityMetadata(context.getContentResolver(), packageName);
assertEquals("Suggested version on App", suggestedVersion, suggestedApp.suggestedVersionCode);
assertEquals("Suggested version on App", suggestedVersion, suggestedApp.autoInstallVersionCode);
assertEquals("Installed signature on App", installedSig, suggestedApp.installedSig);
Apk suggestedApk = ApkProvider.Helper.findSuggestedApk(context, suggestedApp);
......@@ -212,7 +212,7 @@ public class SuggestedVersionTest extends FDroidProviderTest {
App canUpdateApp = appsToUpdate.get(0);
assertEquals("Package name of updatable app", packageName, canUpdateApp.packageName);
assertEquals("Installed version of updatable app", installedVersion, canUpdateApp.installedVersionCode);
assertEquals("Suggested version to update to", suggestedVersion, canUpdateApp.suggestedVersionCode);
assertEquals("Suggested version to update to", suggestedVersion, canUpdateApp.autoInstallVersionCode);
assertEquals("Installed signature of updatable app", installedSig, canUpdateApp.installedSig);
}
}
......
......@@ -303,6 +303,8 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
"antiFeatures",
"authorEmail",
"authorName",
"autoInstallVersionCode",
"autoInstallVersionName",
"bitcoin",
"categories",
"changelog",
......@@ -332,12 +334,10 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
"translation",
"tvBanner",
"tvScreenshots",
"upstreamVersionCode",
"upstreamVersionName",
"video",
"whatsNew",
"wearScreenshots",
"webSite",
"whatsNew",