157 lines
6.3 KiB
Java
157 lines
6.3 KiB
Java
package c.i.a.f.e;
|
|
|
|
import android.content.Context;
|
|
import android.content.pm.ApplicationInfo;
|
|
import android.content.pm.PackageInfo;
|
|
import android.content.pm.PackageManager;
|
|
import android.content.pm.Signature;
|
|
import android.os.StrictMode;
|
|
import android.util.Log;
|
|
import androidx.annotation.RecentlyNonNull;
|
|
import c.i.a.f.e.k.o0;
|
|
import java.util.Objects;
|
|
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
|
|
public class f {
|
|
public static f a;
|
|
public final Context b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public volatile String f1031c;
|
|
|
|
public f(Context context) {
|
|
this.b = context.getApplicationContext();
|
|
}
|
|
|
|
@RecentlyNonNull
|
|
public static f a(@RecentlyNonNull Context context) {
|
|
Objects.requireNonNull(context, "null reference");
|
|
synchronized (f.class) {
|
|
if (a == null) {
|
|
o0 o0Var = s.a;
|
|
synchronized (s.class) {
|
|
if (s.f1064c == null) {
|
|
s.f1064c = context.getApplicationContext();
|
|
} else {
|
|
Log.w("GoogleCertificates", "GoogleCertificates has been initialized already");
|
|
}
|
|
}
|
|
a = new f(context);
|
|
}
|
|
}
|
|
return a;
|
|
}
|
|
|
|
public static t c(PackageInfo packageInfo, t... tVarArr) {
|
|
Signature[] signatureArr = packageInfo.signatures;
|
|
if (signatureArr == null) {
|
|
return null;
|
|
}
|
|
if (signatureArr.length != 1) {
|
|
Log.w("GoogleSignatureVerifier", "Package has more than one signature.");
|
|
return null;
|
|
}
|
|
w wVar = new w(packageInfo.signatures[0].toByteArray());
|
|
for (int i = 0; i < tVarArr.length; i++) {
|
|
if (tVarArr[i].equals(wVar)) {
|
|
return tVarArr[i];
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@RecentlyNonNull
|
|
public static boolean d(@RecentlyNonNull PackageInfo packageInfo, @RecentlyNonNull boolean z2) {
|
|
if (!(packageInfo == null || packageInfo.signatures == null)) {
|
|
if ((z2 ? c(packageInfo, y.a) : c(packageInfo, y.a[0])) != null) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* JADX INFO: finally extract failed */
|
|
@RecentlyNonNull
|
|
public boolean b(@RecentlyNonNull int i) {
|
|
a0 a0Var;
|
|
a0 a0Var2;
|
|
ApplicationInfo applicationInfo;
|
|
String[] packagesForUid = this.b.getPackageManager().getPackagesForUid(i);
|
|
if (packagesForUid == null || packagesForUid.length == 0) {
|
|
a0Var = a0.a("no pkgs");
|
|
} else {
|
|
a0Var = null;
|
|
int length = packagesForUid.length;
|
|
int i2 = 0;
|
|
while (true) {
|
|
if (i2 >= length) {
|
|
Objects.requireNonNull(a0Var, "null reference");
|
|
break;
|
|
}
|
|
String str = packagesForUid[i2];
|
|
if (str == null) {
|
|
a0Var = a0.a("null pkg");
|
|
} else if (str.equals(this.f1031c)) {
|
|
a0Var = a0.a;
|
|
} else {
|
|
try {
|
|
PackageInfo packageInfo = this.b.getPackageManager().getPackageInfo(str, 64);
|
|
boolean a2 = e.a(this.b);
|
|
if (packageInfo == null) {
|
|
a0Var2 = a0.a("null pkg");
|
|
} else {
|
|
Signature[] signatureArr = packageInfo.signatures;
|
|
if (signatureArr == null || signatureArr.length != 1) {
|
|
a0Var2 = a0.a("single cert required");
|
|
} else {
|
|
w wVar = new w(packageInfo.signatures[0].toByteArray());
|
|
String str2 = packageInfo.packageName;
|
|
o0 o0Var = s.a;
|
|
StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
|
|
try {
|
|
a0 a3 = s.a(str2, wVar, a2, false);
|
|
StrictMode.setThreadPolicy(allowThreadDiskReads);
|
|
if (!(!a3.b || (applicationInfo = packageInfo.applicationInfo) == null || (applicationInfo.flags & 2) == 0)) {
|
|
StrictMode.ThreadPolicy allowThreadDiskReads2 = StrictMode.allowThreadDiskReads();
|
|
try {
|
|
a0 a4 = s.a(str2, wVar, false, true);
|
|
StrictMode.setThreadPolicy(allowThreadDiskReads2);
|
|
if (a4.b) {
|
|
a0Var2 = a0.a("debuggable release cert app rejected");
|
|
}
|
|
} catch (Throwable th) {
|
|
StrictMode.setThreadPolicy(allowThreadDiskReads2);
|
|
throw th;
|
|
}
|
|
}
|
|
a0Var2 = a3;
|
|
} catch (Throwable th2) {
|
|
StrictMode.setThreadPolicy(allowThreadDiskReads);
|
|
throw th2;
|
|
}
|
|
}
|
|
}
|
|
if (a0Var2.b) {
|
|
this.f1031c = str;
|
|
}
|
|
a0Var = a0Var2;
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
a0Var = a0.b(str.length() != 0 ? "no pkg ".concat(str) : new String("no pkg "), e);
|
|
}
|
|
}
|
|
if (a0Var.b) {
|
|
break;
|
|
}
|
|
i2++;
|
|
}
|
|
}
|
|
if (!a0Var.b && Log.isLoggable("GoogleCertificatesRslt", 3)) {
|
|
if (a0Var.d != null) {
|
|
Log.d("GoogleCertificatesRslt", a0Var.c(), a0Var.d);
|
|
} else {
|
|
Log.d("GoogleCertificatesRslt", a0Var.c());
|
|
}
|
|
}
|
|
return a0Var.b;
|
|
}
|
|
}
|