support push requests when using the index-v1.json
Before, push requests were only supported when using index.xml. This adds support for using push requests in index-v1.json. `fdroid update` has been generating them in both index versions for a while now.
This commit is contained in:
parent
d5d3abe2a3
commit
c8f804d0f6
@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2018 Hans-Christoph Steiner <hans@eds.org>
|
||||
* Copyright (C) 2017 Peter Serwylo <peter@serwylo.com>
|
||||
* 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<String, Object> 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<String, String[]> requests) {
|
||||
if (requests == null) {
|
||||
Utils.debugLog(TAG, "RepoPushRequests are null");
|
||||
} else {
|
||||
List<RepoPushRequest> repoPushRequestList = new ArrayList<>();
|
||||
for (Map.Entry<String, String[]> requestEntry : requests.entrySet()) {
|
||||
String request = requestEntry.getKey();
|
||||
for (String packageName : requestEntry.getValue()) {
|
||||
repoPushRequestList.add(new RepoPushRequest(request, packageName, null));
|
||||
}
|
||||
}
|
||||
processRepoPushRequests(repoPushRequestList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Senecto Limited
|
||||
* Copyright (C) 2016 Blue Jay Wireless
|
||||
* Copyright (C) 2015-2016 Daniel Martí <mvdan@mvdan.cc>
|
||||
* Copyright (C) 2014-2016 Hans-Christoph Steiner <hans@eds.org>
|
||||
* Copyright (C) 2014-2018 Hans-Christoph Steiner <hans@eds.org>
|
||||
* Copyright (C) 2014-2016 Peter Serwylo <peter@serwylo.com>
|
||||
*
|
||||
* 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<RepoPushRequest> requestEntries) {
|
||||
for (RepoPushRequest repoPushRequest : requestEntries) {
|
||||
String packageName = repoPushRequest.packageName;
|
||||
PackageInfo packageInfo = Utils.getPackageInfo(context, packageName);
|
||||
if (RepoPushRequest.INSTALL.equals(repoPushRequest.request)) {
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user