mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-02-05 12:42:34 -05:00
[app] Fix release channel logic in App#findSuggestedApk()
Stable updates are always allowed, even if we also allow beta updates.
This commit is contained in:
@@ -552,8 +552,13 @@ public class App implements Comparable<App>, Parcelable {
|
||||
if (!a.compatible) continue;
|
||||
// if we have a signature, but it doesn't match, don't use this APK
|
||||
if (mostAppropriateSignature != null && !a.sig.equals(mostAppropriateSignature)) continue;
|
||||
// stable release channel is always allowed, otherwise must include given channel
|
||||
final String stable = Apk.RELEASE_CHANNEL_STABLE;
|
||||
boolean isReleaseChannelAllowed = stable.equals(releaseChannel) ?
|
||||
a.releaseChannels.contains(stable) :
|
||||
a.releaseChannels.contains(stable) || a.releaseChannels.contains(releaseChannel);
|
||||
// if the signature matches and we want the highest version code, take this as list is sorted.
|
||||
if (a.releaseChannels.contains(releaseChannel)) {
|
||||
if (isReleaseChannelAllowed) {
|
||||
apk = a;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -102,6 +102,22 @@ public class SuggestedVersionTest {
|
||||
assertSuggested(app, apks, suggestedVersion, releaseChannel, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncompatibleWithBeta() {
|
||||
App singleApp = TestUtils.getApp();
|
||||
singleApp.installedVersionCode = 1;
|
||||
singleApp.installedSig = TestUtils.FDROID_SIG;
|
||||
Apk apk1 = TestUtils.getApk(1, TestUtils.FDROID_SIG, Apk.RELEASE_CHANNEL_STABLE);
|
||||
Apk apk2 = TestUtils.getApk(2, TestUtils.FDROID_SIG, Apk.RELEASE_CHANNEL_STABLE);
|
||||
Apk apk3 = TestUtils.getApk(3, TestUtils.FDROID_SIG, Apk.RELEASE_CHANNEL_STABLE);
|
||||
apk3.compatible = false;
|
||||
List<Apk> apks = new ArrayList<>();
|
||||
apks.add(apk3);
|
||||
apks.add(apk2);
|
||||
apks.add(apk1);
|
||||
assertSuggested(singleApp, apks, 2, Apk.RELEASE_CHANNEL_BETA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the app exists, that its suggested version code is correct, and that the apk which is "suggested"
|
||||
* has the correct signature.
|
||||
|
||||
Reference in New Issue
Block a user