Merge branch 'support-platform-signature' into 'master'
* tag 'mergeeme': remove unused import Fixed bug package signature info not included Changed to static property Fixed "apply suggestion" error Replaced `equalsIgnoreCase()` with `equals()` Apply 1 suggestion(s) to 1 file(s) Added check platform signature available fdroid/fdroidclient!943
This commit is contained in:
commit
a1827f6266
@ -24,7 +24,7 @@ package org.fdroid.fdroid;
|
|||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -92,6 +92,8 @@ public class IndexV1Updater extends IndexUpdater {
|
|||||||
public static final String SIGNED_FILE_NAME = "index-v1.jar";
|
public static final String SIGNED_FILE_NAME = "index-v1.jar";
|
||||||
public static final String DATA_FILE_NAME = "index-v1.json";
|
public static final String DATA_FILE_NAME = "index-v1.json";
|
||||||
|
|
||||||
|
private static String platformSigCache;
|
||||||
|
|
||||||
public IndexV1Updater(@NonNull Context context, @NonNull Repo repo) {
|
public IndexV1Updater(@NonNull Context context, @NonNull Repo repo) {
|
||||||
super(context, repo);
|
super(context, repo);
|
||||||
}
|
}
|
||||||
@ -298,6 +300,11 @@ public class IndexV1Updater extends IndexUpdater {
|
|||||||
repo.maxage = getIntRepoValue(repoMap, "maxage");
|
repo.maxage = getIntRepoValue(repoMap, "maxage");
|
||||||
repo.version = getIntRepoValue(repoMap, "version");
|
repo.version = getIntRepoValue(repoMap, "version");
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(platformSigCache)) {
|
||||||
|
PackageInfo androidPackageInfo = Utils.getPackageInfoWithSignatures(context, "android");
|
||||||
|
platformSigCache = Utils.getPackageSig(androidPackageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
RepoPersister repoPersister = new RepoPersister(context, repo);
|
RepoPersister repoPersister = new RepoPersister(context, repo);
|
||||||
if (apps != null && apps.length > 0) {
|
if (apps != null && apps.length > 0) {
|
||||||
int appCount = 0;
|
int appCount = 0;
|
||||||
@ -319,6 +326,8 @@ public class IndexV1Updater extends IndexUpdater {
|
|||||||
for (Apk apk : apks) {
|
for (Apk apk : apks) {
|
||||||
if (!apk.isApk()) {
|
if (!apk.isApk()) {
|
||||||
app.isApk = false;
|
app.isApk = false;
|
||||||
|
} else if (apk.sig.equals(platformSigCache)) {
|
||||||
|
app.preferredSigner = platformSigCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package org.fdroid.fdroid;
|
package org.fdroid.fdroid;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@ -808,6 +809,21 @@ public final class Utils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to get the {@link PackageInfo} with signature info for the {@code packageName} provided.
|
||||||
|
*
|
||||||
|
* @return null on failure
|
||||||
|
*/
|
||||||
|
@SuppressLint("PackageManagerGetSignatures")
|
||||||
|
public static PackageInfo getPackageInfoWithSignatures(Context context, String packageName) {
|
||||||
|
try {
|
||||||
|
return context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
debugLog(TAG, "Could not get PackageInfo: ", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Useful for debugging during development, so that arbitrary queries can be made, and their
|
* Useful for debugging during development, so that arbitrary queries can be made, and their
|
||||||
* results inspected in the debugger.
|
* results inspected in the debugger.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user