mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-04-20 14:57:15 -04:00
InstalledAppProvider: Fix Trichrome Library install
* The way Trichrome library (which is a static shared library)
is implemented means that the PackageManager ends up with two
entries for it, one for the system-installed version, and another
for the upgrade installed on /data.
* The previous implementation which only relied on packageName would
sometimes pick the older version, which meant that even after installing
an update it'd still keep trying to re-install the same version over
and over again since in F-Droid's internal database it still thought that
an older version was installed.
* Always using the newer version / higher version code should hopefully fix this.
Fixes: b52c7ca39a
"Remove duplicate entries from installed packages list"
Issue: https://gitlab.com/fdroid/fdroidclient/-/issues/2184
Issue: calyxos#406
This commit is contained in:
committed by
Hans-Christoph Steiner
parent
9dc40bf391
commit
e1d37ce02f
@@ -23,6 +23,7 @@ import org.fdroid.fdroid.privileged.IPrivilegedService;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
@@ -220,12 +221,28 @@ public class InstalledAppProviderService extends JobIntentService {
|
||||
}
|
||||
}
|
||||
|
||||
private static class PackageInfoComparator implements Comparator<PackageInfo> {
|
||||
@Override
|
||||
public int compare(PackageInfo o1, PackageInfo o2) {
|
||||
// There are two trichrome library entries in the list,
|
||||
// one for each version. We only want the newest here.
|
||||
String[] duplicateList = new String[]{"org.chromium.trichromelibrary"};
|
||||
for (String dup : duplicateList) {
|
||||
if (o1.packageName.contentEquals(dup)
|
||||
&& o2.packageName.contentEquals(dup)) {
|
||||
return Integer.compare(o1.versionCode, o2.versionCode);
|
||||
}
|
||||
}
|
||||
return o1.packageName.compareTo(o2.packageName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void compareToPackageManager(Context context, List<PackageInfo> packageInfoList) {
|
||||
if (packageInfoList == null || packageInfoList.isEmpty()) {
|
||||
packageInfoList = context.getPackageManager().getInstalledPackages(PackageManager.GET_SIGNATURES);
|
||||
}
|
||||
Map<String, Long> cachedInfo = InstalledAppProvider.Helper.lastUpdateTimes(context);
|
||||
TreeSet<PackageInfo> packageInfoSet = new TreeSet<>((o1, o2) -> o1.packageName.compareTo(o2.packageName));
|
||||
TreeSet<PackageInfo> packageInfoSet = new TreeSet<>(new PackageInfoComparator());
|
||||
packageInfoSet.addAll(packageInfoList);
|
||||
for (PackageInfo packageInfo : packageInfoSet) {
|
||||
if (cachedInfo.containsKey(packageInfo.packageName)) {
|
||||
|
||||
Reference in New Issue
Block a user