diff --git a/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java b/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java index a0ac78cbb..1b61d69a1 100644 --- a/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java +++ b/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java @@ -1,3 +1,25 @@ +/* + * Copyright (C) 2017-2018 Hans-Christoph Steiner + * Copyright (C) 2017 Peter Serwylo + * Copyright (C) 2017 Chirayu Desai + * Copyright (C) 2018 Senecto Limited + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + package org.fdroid.fdroid; import android.content.ContentValues; @@ -20,6 +42,7 @@ import org.fdroid.fdroid.data.App; import org.fdroid.fdroid.data.Repo; import org.fdroid.fdroid.data.RepoPersister; import org.fdroid.fdroid.data.RepoProvider; +import org.fdroid.fdroid.data.RepoPushRequest; import org.fdroid.fdroid.data.Schema; import org.fdroid.fdroid.net.Downloader; import org.fdroid.fdroid.net.DownloaderFactory; @@ -312,9 +335,8 @@ public class IndexV1Updater extends RepoUpdater { repoPersister.commit(contentValues, repo.getId()); profiler.log("Persited to database."); - - // TODO RepoUpdater.processRepoPushRequests(context, repoPushRequestList); - Utils.debugLog(TAG, "Repo Push Requests: " + requests); + processRepoPushRequests(requests); + Utils.debugLog(TAG, "Completed Repo Push Requests: " + requests); } private int getIntRepoValue(Map repoMap, String key) { @@ -434,4 +456,21 @@ public class IndexV1Updater extends RepoUpdater { throw new SigningException("Signing certificate does not match!"); } + /** + * The {@code index-v1} version of {@link RepoUpdater#processRepoPushRequests(List)} + */ + private void processRepoPushRequests(Map requests) { + if (requests == null) { + Utils.debugLog(TAG, "RepoPushRequests are null"); + } else { + List repoPushRequestList = new ArrayList<>(); + for (Map.Entry requestEntry : requests.entrySet()) { + String request = requestEntry.getKey(); + for (String packageName : requestEntry.getValue()) { + repoPushRequestList.add(new RepoPushRequest(request, packageName, null)); + } + } + processRepoPushRequests(repoPushRequestList); + } + } } diff --git a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java index 95fedf9c5..ba6095efd 100644 --- a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java +++ b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java @@ -1,7 +1,8 @@ /* + * Copyright (C) 2018 Senecto Limited * Copyright (C) 2016 Blue Jay Wireless * Copyright (C) 2015-2016 Daniel Martí - * Copyright (C) 2014-2016 Hans-Christoph Steiner + * Copyright (C) 2014-2018 Hans-Christoph Steiner * Copyright (C) 2014-2016 Peter Serwylo * * This program is free software; you can redistribute it and/or @@ -162,7 +163,7 @@ public class RepoUpdater { // successful download, then we will have a file ready to use: cacheTag = downloader.getCacheTag(); processDownloadedFile(downloader.outputFile); - processRepoPushRequests(); + processRepoPushRequests(repoPushRequestList); } return true; } @@ -448,8 +449,8 @@ public class RepoUpdater { * should always accept, prompt the user, or ignore those requests on a * per repo basis. */ - void processRepoPushRequests() { - for (RepoPushRequest repoPushRequest : repoPushRequestList) { + void processRepoPushRequests(List requestEntries) { + for (RepoPushRequest repoPushRequest : requestEntries) { String packageName = repoPushRequest.packageName; PackageInfo packageInfo = Utils.getPackageInfo(context, packageName); if (RepoPushRequest.INSTALL.equals(repoPushRequest.request)) { diff --git a/app/src/main/java/org/fdroid/fdroid/data/RepoPushRequest.java b/app/src/main/java/org/fdroid/fdroid/data/RepoPushRequest.java index 1c89b0884..49082c873 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/RepoPushRequest.java +++ b/app/src/main/java/org/fdroid/fdroid/data/RepoPushRequest.java @@ -38,7 +38,7 @@ public class RepoPushRequest { @Nullable public final Integer versionCode; - public RepoPushRequest(String request, String packageName, String versionCode) { + public RepoPushRequest(String request, String packageName, @Nullable String versionCode) { this.request = request; this.packageName = packageName;