diff --git a/app/src/full/AndroidManifest.xml b/app/src/full/AndroidManifest.xml
index b4cfe4e2f..ed877de77 100644
--- a/app/src/full/AndroidManifest.xml
+++ b/app/src/full/AndroidManifest.xml
@@ -77,9 +77,6 @@
android:exported="false"/>
- * This could probably be replaced by {@link org.fdroid.fdroid.data.InstalledAppProvider}
- * if that contained all of the info to generate complete {@link App} and
- * {@link org.fdroid.fdroid.data.Apk} instances.
- */
-public class CacheSwapAppsService extends IntentService {
- private static final String TAG = "CacheSwapAppsService";
-
- private static final String ACTION_PARSE_APP = "org.fdroid.fdroid.localrepo.action.PARSE_APP";
-
- public CacheSwapAppsService() {
- super("CacheSwapAppsService");
- }
-
- /**
- * Parse the locally installed APK for {@code packageName} and save its XML
- * to the APK XML cache.
- */
- private static void parseApp(Context context, String packageName) {
- Intent intent = new Intent();
- intent.setData(Utils.getPackageUri(packageName));
- intent.setClass(context, CacheSwapAppsService.class);
- intent.setAction(ACTION_PARSE_APP);
- context.startService(intent);
- }
-
- /**
- * Parse all of the locally installed APKs into a memory cache, starting
- * with the currently selected apps. APKs that are already parsed in the
- * {@code index.jar} file will be read from that file.
- */
- public static void startCaching(Context context) {
- File indexJarFile = LocalRepoManager.get(context).getIndexJar();
- PackageManager pm = context.getPackageManager();
- for (ApplicationInfo applicationInfo : pm.getInstalledApplications(0)) {
- if (applicationInfo.publicSourceDir.startsWith(FDroidApp.SYSTEM_DIR_NAME)) {
- continue;
- }
- if (!indexJarFile.exists()
- || FileUtils.isFileNewer(new File(applicationInfo.sourceDir), indexJarFile)) {
- parseApp(context, applicationInfo.packageName);
- }
- }
- }
-
- @Override
- protected void onHandleIntent(Intent intent) {
- android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LOWEST);
- if (intent == null || !ACTION_PARSE_APP.equals(intent.getAction())) {
- Utils.debugLog(TAG, "received bad Intent: " + intent);
- return;
- }
-
- try {
- PackageManager pm = getPackageManager();
- String packageName = intent.getData().getSchemeSpecificPart();
- App app = App.getInstance(this, pm, packageName);
- if (app != null) {
- SwapService.putAppInCache(packageName, app);
- }
- } catch (CertificateEncodingException | IOException | PackageManager.NameNotFoundException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/app/src/full/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java b/app/src/full/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java
index 12ee3f23d..7bd4063f1 100644
--- a/app/src/full/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java
+++ b/app/src/full/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java
@@ -276,12 +276,10 @@ public final class LocalRepoManager {
}
public void addApp(Context context, String packageName) {
- App app;
+ App app = null;
try {
- app = SwapService.getAppFromCache(packageName);
- if (app == null) {
- app = App.getInstance(context.getApplicationContext(), pm, packageName);
- }
+ InstalledApp installedApp = InstalledAppProvider.Helper.findByPackageName(context, packageName);
+ app = App.getInstance(context, pm, installedApp, packageName);
if (app == null || !app.isValid()) {
return;
}
diff --git a/app/src/full/java/org/fdroid/fdroid/localrepo/SwapService.java b/app/src/full/java/org/fdroid/fdroid/localrepo/SwapService.java
index 332cea135..2d1848088 100644
--- a/app/src/full/java/org/fdroid/fdroid/localrepo/SwapService.java
+++ b/app/src/full/java/org/fdroid/fdroid/localrepo/SwapService.java
@@ -27,7 +27,6 @@ import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.UpdateService;
import org.fdroid.fdroid.Utils;
-import org.fdroid.fdroid.data.App;
import org.fdroid.fdroid.data.Repo;
import org.fdroid.fdroid.data.RepoProvider;
import org.fdroid.fdroid.data.Schema;
@@ -53,7 +52,6 @@ import java.util.HashSet;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
/**
* Central service which manages all of the different moving parts of swap which are required
@@ -74,11 +72,6 @@ public class SwapService extends Service {
@NonNull
private final Set