mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-12-24 11:45:50 +01:00
Fix incomplete certificate requests causing crashes
This commit is contained in:
parent
5d6e9ac01c
commit
8a0010a1d8
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.google.android.gms.common;
|
package com.google.android.gms.common;
|
||||||
|
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.support.annotation.Keep;
|
import android.support.annotation.Keep;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -55,6 +56,14 @@ public class GoogleCertificatesImpl extends IGoogleCertificatesApi.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGoogleOrPlatformSigned(GoogleCertificatesQuery query, IObjectWrapper packageManager) throws RemoteException {
|
public boolean isGoogleOrPlatformSigned(GoogleCertificatesQuery query, IObjectWrapper packageManager) throws RemoteException {
|
||||||
return PackageUtils.isGooglePackage(query.getPackageName(), query.getCertData().getBytes());
|
PackageManager pm = ObjectWrapper.unwrapTyped(packageManager, PackageManager.class);
|
||||||
|
if (query == null || query.getPackageName() == null) {
|
||||||
|
return false;
|
||||||
|
} else if (query.getCertData() == null) {
|
||||||
|
if (pm == null) return false;
|
||||||
|
return PackageUtils.isGooglePackage(pm, query.getPackageName());
|
||||||
|
} else {
|
||||||
|
return PackageUtils.isGooglePackage(query.getPackageName(), query.getCertData().getBytes());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,11 @@ public class PackageUtils {
|
|||||||
return isGooglePackage(packageName, signatureDigest);
|
return isGooglePackage(packageName, signatureDigest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isGooglePackage(PackageManager packageManager, String packageName) {
|
||||||
|
String signatureDigest = firstSignatureDigest(packageManager, packageName);
|
||||||
|
return isGooglePackage(packageName, signatureDigest);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isGooglePackage(String packageName, byte[] bytes) {
|
public static boolean isGooglePackage(String packageName, byte[] bytes) {
|
||||||
return isGooglePackage(packageName, sha1sum(bytes));
|
return isGooglePackage(packageName, sha1sum(bytes));
|
||||||
}
|
}
|
||||||
@ -102,7 +107,11 @@ public class PackageUtils {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String firstSignatureDigest(Context context, String packageName) {
|
public static String firstSignatureDigest(Context context, String packageName) {
|
||||||
PackageManager packageManager = context.getPackageManager();
|
return firstSignatureDigest(context.getPackageManager(), packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static String firstSignatureDigest(PackageManager packageManager, String packageName) {
|
||||||
final PackageInfo info;
|
final PackageInfo info;
|
||||||
try {
|
try {
|
||||||
info = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
|
info = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
|
||||||
|
Loading…
Reference in New Issue
Block a user