95 lines
4.3 KiB
Java
95 lines
4.3 KiB
Java
|
package com.google.android.gms.security;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.Intent;
|
||
|
import android.os.SystemClock;
|
||
|
import android.util.Log;
|
||
|
import com.google.android.gms.common.GoogleApiAvailabilityLight;
|
||
|
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
|
||
|
import com.google.android.gms.common.GooglePlayServicesRepairableException;
|
||
|
import com.google.android.gms.common.GooglePlayServicesUtilLight;
|
||
|
import com.google.android.gms.common.internal.Preconditions;
|
||
|
import com.google.android.gms.dynamite.DynamiteModule;
|
||
|
import java.lang.reflect.Method;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class ProviderInstaller {
|
||
|
public static final String PROVIDER_NAME = "GmsCore_OpenSSL";
|
||
|
private static final GoogleApiAvailabilityLight zza = GoogleApiAvailabilityLight.getInstance();
|
||
|
private static final Object zzb = new Object();
|
||
|
private static Method zzc = null;
|
||
|
private static Method zzd = null;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public interface ProviderInstallListener {
|
||
|
void onProviderInstallFailed(int i, Intent intent);
|
||
|
|
||
|
void onProviderInstalled();
|
||
|
}
|
||
|
|
||
|
public static void installIfNeeded(Context context) throws GooglePlayServicesRepairableException, GooglePlayServicesNotAvailableException {
|
||
|
Context context2;
|
||
|
Preconditions.checkNotNull(context, "Context must not be null");
|
||
|
zza.verifyGooglePlayServicesIsAvailable(context, 11925000);
|
||
|
synchronized (zzb) {
|
||
|
long elapsedRealtime = SystemClock.elapsedRealtime();
|
||
|
try {
|
||
|
context2 = DynamiteModule.load(context, DynamiteModule.PREFER_HIGHEST_OR_LOCAL_VERSION_NO_FORCE_STAGING, "com.google.android.gms.providerinstaller.dynamite").getModuleContext();
|
||
|
} catch (DynamiteModule.LoadingException e) {
|
||
|
e.getMessage();
|
||
|
context2 = null;
|
||
|
}
|
||
|
if (context2 == null) {
|
||
|
long elapsedRealtime2 = SystemClock.elapsedRealtime();
|
||
|
Context remoteContext = GooglePlayServicesUtilLight.getRemoteContext(context);
|
||
|
if (remoteContext != null) {
|
||
|
try {
|
||
|
if (zzd == null) {
|
||
|
zzd = zzb(remoteContext, "com.google.android.gms.common.security.ProviderInstallerImpl", "reportRequestStats", new Class[]{Context.class, Long.TYPE, Long.TYPE});
|
||
|
}
|
||
|
zzd.invoke(null, context, Long.valueOf(elapsedRealtime), Long.valueOf(elapsedRealtime2));
|
||
|
} catch (Exception e2) {
|
||
|
e2.getMessage();
|
||
|
}
|
||
|
}
|
||
|
if (remoteContext != null) {
|
||
|
zzc(remoteContext, context, "com.google.android.gms.common.security.ProviderInstallerImpl");
|
||
|
return;
|
||
|
}
|
||
|
throw new GooglePlayServicesNotAvailableException(8);
|
||
|
}
|
||
|
zzc(context2, context, "com.google.android.gms.providerinstaller.ProviderInstallerImpl");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void installIfNeededAsync(Context context, ProviderInstallListener providerInstallListener) {
|
||
|
Preconditions.checkNotNull(context, "Context must not be null");
|
||
|
Preconditions.checkNotNull(providerInstallListener, "Listener must not be null");
|
||
|
Preconditions.checkMainThread("Must be called on the UI thread");
|
||
|
new zza(context, providerInstallListener).execute(new Void[0]);
|
||
|
}
|
||
|
|
||
|
private static Method zzb(Context context, String str, String str2, Class[] clsArr) throws ClassNotFoundException, NoSuchMethodException {
|
||
|
return context.getClassLoader().loadClass(str).getMethod(str2, clsArr);
|
||
|
}
|
||
|
|
||
|
private static void zzc(Context context, Context context2, String str) throws GooglePlayServicesNotAvailableException {
|
||
|
try {
|
||
|
if (zzc == null) {
|
||
|
zzc = zzb(context, str, "insertProvider", new Class[]{Context.class});
|
||
|
}
|
||
|
zzc.invoke(null, context);
|
||
|
} catch (Exception e) {
|
||
|
Throwable cause = e.getCause();
|
||
|
if (Log.isLoggable("ProviderInstaller", 6)) {
|
||
|
if (cause == null) {
|
||
|
e.getMessage();
|
||
|
} else {
|
||
|
cause.getMessage();
|
||
|
}
|
||
|
}
|
||
|
throw new GooglePlayServicesNotAvailableException(8);
|
||
|
}
|
||
|
}
|
||
|
}
|