Clarify comments in response to CR.

This commit is contained in:
Peter Serwylo 2017-06-09 09:03:56 +10:00
parent 82eb50c2fe
commit d0444dafca

View File

@ -953,6 +953,8 @@ public class AppProvider extends FDroidProvider {
* with the closest version code to that, without going over. * with the closest version code to that, without going over.
* If the app is not compatible at all (i.e. no versions were compatible) * If the app is not compatible at all (i.e. no versions were compatible)
* then we take the highest, otherwise we take the highest compatible version. * then we take the highest, otherwise we take the highest compatible version.
* If the app is installed, then all apks signed by a different certificate are
* ignored for the purpose of this calculation.
* *
* @see #updateSuggestedFromLatest() * @see #updateSuggestedFromLatest()
*/ */
@ -1030,12 +1032,14 @@ public class AppProvider extends FDroidProvider {
" installed." + InstalledAppTable.Cols.PACKAGE_NAME + " = pkg." + PackageTable.Cols.PACKAGE_NAME + ") " + " installed." + InstalledAppTable.Cols.PACKAGE_NAME + " = pkg." + PackageTable.Cols.PACKAGE_NAME + ") " +
")"; ")";
// If the installed sig is not null, then the apk signature will need to match that. // Ideally, the check below would actually be written as:
// If the installed sig IS null, then it will check whether the apk sig matches the apk sig // `installedSig IS NULL OR installedSig = apk.sig`
// (i.e. it will always return the app).
// This would be better writen as: `installedSig IS NULL OR installedSig = apk.sig`,
// however that would require a separate sub query for each `installedSig` which is more // however that would require a separate sub query for each `installedSig` which is more
// expensive. This is a less expressive way to write the same thing. // expensive. Using a COALESCE is a less expressive way to write the same thing with only
// a single subquery.
// Also note that the `installedSig IS NULL` is not because there is a `NULL` entry in the
// installed table (this is impossible), but rather because the subselect above returned
// zero rows.
return apkTable + "." + ApkTable.Cols.SIGNATURE + " = " + return apkTable + "." + ApkTable.Cols.SIGNATURE + " = " +
"COALESCE(" + installedSig + ", " + apkTable + "." + ApkTable.Cols.SIGNATURE + ")"; "COALESCE(" + installedSig + ", " + apkTable + "." + ApkTable.Cols.SIGNATURE + ")";
} }