- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
202 lines
7.6 KiB
Java
202 lines
7.6 KiB
Java
package androidx.credentials;
|
|
|
|
import android.content.Context;
|
|
import android.content.pm.PackageInfo;
|
|
import android.content.pm.ServiceInfo;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import kotlin.collections.CollectionsKt___CollectionsKt;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class CredentialProviderFactory {
|
|
private static final String CREDENTIAL_PROVIDER_KEY = "androidx.credentials.CREDENTIAL_PROVIDER_KEY";
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int MAX_CRED_MAN_PRE_FRAMEWORK_API_LEVEL = 33;
|
|
private static final String TAG = "CredProviderFactory";
|
|
private final Context context;
|
|
private boolean testMode;
|
|
private CredentialProvider testPostUProvider;
|
|
private CredentialProvider testPreUProvider;
|
|
|
|
public final Context getContext() {
|
|
return this.context;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
@VisibleForTesting
|
|
public final boolean getTestMode() {
|
|
return this.testMode;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
@VisibleForTesting
|
|
public final CredentialProvider getTestPostUProvider() {
|
|
return this.testPostUProvider;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
@VisibleForTesting
|
|
public final CredentialProvider getTestPreUProvider() {
|
|
return this.testPreUProvider;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
@VisibleForTesting
|
|
public final void setTestMode(boolean z) {
|
|
this.testMode = z;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
@VisibleForTesting
|
|
public final void setTestPostUProvider(CredentialProvider credentialProvider) {
|
|
this.testPostUProvider = credentialProvider;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
@VisibleForTesting
|
|
public final void setTestPreUProvider(CredentialProvider credentialProvider) {
|
|
this.testPreUProvider = credentialProvider;
|
|
}
|
|
|
|
public CredentialProviderFactory(Context context) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
this.context = context;
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
}
|
|
|
|
public static /* synthetic */ CredentialProvider getBestAvailableProvider$default(CredentialProviderFactory credentialProviderFactory, Object obj, boolean z, int i, Object obj2) {
|
|
if ((i & 2) != 0) {
|
|
z = true;
|
|
}
|
|
return credentialProviderFactory.getBestAvailableProvider(obj, z);
|
|
}
|
|
|
|
public final CredentialProvider getBestAvailableProvider(Object request, boolean z) {
|
|
Intrinsics.checkNotNullParameter(request, "request");
|
|
if ((request instanceof CreateRestoreCredentialRequest) || Intrinsics.areEqual(request, ClearCredentialStateRequest.TYPE_CLEAR_RESTORE_CREDENTIAL)) {
|
|
return tryCreatePreUOemProvider();
|
|
}
|
|
if (request instanceof GetCredentialRequest) {
|
|
for (CredentialOption credentialOption : ((GetCredentialRequest) request).getCredentialOptions()) {
|
|
if ((credentialOption instanceof GetRestoreCredentialOption) || (credentialOption instanceof GetDigitalCredentialOption)) {
|
|
return tryCreatePreUOemProvider();
|
|
}
|
|
}
|
|
}
|
|
return getBestAvailableProvider(z);
|
|
}
|
|
|
|
public static /* synthetic */ CredentialProvider getBestAvailableProvider$default(CredentialProviderFactory credentialProviderFactory, boolean z, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
z = true;
|
|
}
|
|
return credentialProviderFactory.getBestAvailableProvider(z);
|
|
}
|
|
|
|
public final CredentialProvider getBestAvailableProvider(boolean z) {
|
|
int i = Build.VERSION.SDK_INT;
|
|
if (i >= 34) {
|
|
CredentialProvider tryCreatePostUProvider = tryCreatePostUProvider();
|
|
return (tryCreatePostUProvider == null && z) ? tryCreatePreUOemProvider() : tryCreatePostUProvider;
|
|
}
|
|
if (i <= 33) {
|
|
return tryCreatePreUOemProvider();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private final CredentialProvider tryCreatePreUOemProvider() {
|
|
if (!this.testMode) {
|
|
List<String> allowedProvidersFromManifest = getAllowedProvidersFromManifest(this.context);
|
|
if (allowedProvidersFromManifest.isEmpty()) {
|
|
return null;
|
|
}
|
|
return instantiatePreUProvider(allowedProvidersFromManifest, this.context);
|
|
}
|
|
CredentialProvider credentialProvider = this.testPreUProvider;
|
|
if (credentialProvider == null) {
|
|
return null;
|
|
}
|
|
Intrinsics.checkNotNull(credentialProvider);
|
|
if (credentialProvider.isAvailableOnDevice()) {
|
|
return this.testPreUProvider;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@RequiresApi(34)
|
|
private final CredentialProvider tryCreatePostUProvider() {
|
|
if (!this.testMode) {
|
|
CredentialProviderFrameworkImpl credentialProviderFrameworkImpl = new CredentialProviderFrameworkImpl(this.context);
|
|
if (credentialProviderFrameworkImpl.isAvailableOnDevice()) {
|
|
return credentialProviderFrameworkImpl;
|
|
}
|
|
return null;
|
|
}
|
|
CredentialProvider credentialProvider = this.testPostUProvider;
|
|
if (credentialProvider == null) {
|
|
return null;
|
|
}
|
|
Intrinsics.checkNotNull(credentialProvider);
|
|
if (credentialProvider.isAvailableOnDevice()) {
|
|
return this.testPostUProvider;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private final CredentialProvider instantiatePreUProvider(List<String> list, Context context) {
|
|
Iterator<String> it = list.iterator();
|
|
CredentialProvider credentialProvider = null;
|
|
while (it.hasNext()) {
|
|
try {
|
|
Object newInstance = Class.forName(it.next()).getConstructor(Context.class).newInstance(context);
|
|
Intrinsics.checkNotNull(newInstance, "null cannot be cast to non-null type androidx.credentials.CredentialProvider");
|
|
CredentialProvider credentialProvider2 = (CredentialProvider) newInstance;
|
|
if (!credentialProvider2.isAvailableOnDevice()) {
|
|
continue;
|
|
} else {
|
|
if (credentialProvider != null) {
|
|
return null;
|
|
}
|
|
credentialProvider = credentialProvider2;
|
|
}
|
|
} catch (Throwable unused) {
|
|
}
|
|
}
|
|
return credentialProvider;
|
|
}
|
|
|
|
private final List<String> getAllowedProvidersFromManifest(Context context) {
|
|
String string;
|
|
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 132);
|
|
ArrayList arrayList = new ArrayList();
|
|
ServiceInfo[] serviceInfoArr = packageInfo.services;
|
|
if (serviceInfoArr != null) {
|
|
Intrinsics.checkNotNull(serviceInfoArr);
|
|
for (ServiceInfo serviceInfo : serviceInfoArr) {
|
|
Bundle bundle = serviceInfo.metaData;
|
|
if (bundle != null && (string = bundle.getString(CREDENTIAL_PROVIDER_KEY)) != null) {
|
|
arrayList.add(string);
|
|
}
|
|
}
|
|
}
|
|
return CollectionsKt___CollectionsKt.toList(arrayList);
|
|
}
|
|
}
|