374 lines
18 KiB
Java
374 lines
18 KiB
Java
|
package com.google.android.gms.dynamite;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.pm.ApplicationInfo;
|
||
|
import android.content.pm.ComponentInfo;
|
||
|
import android.content.pm.PackageItemInfo;
|
||
|
import android.content.pm.ProviderInfo;
|
||
|
import android.database.Cursor;
|
||
|
import android.os.IBinder;
|
||
|
import android.os.IInterface;
|
||
|
import com.google.android.gms.common.GoogleApiAvailabilityLight;
|
||
|
import com.google.android.gms.common.internal.Objects;
|
||
|
import com.google.android.gms.common.internal.Preconditions;
|
||
|
import com.huawei.hms.framework.common.ExceptionCode;
|
||
|
import com.huawei.hms.support.api.entity.common.CommonConstant;
|
||
|
import java.lang.reflect.Field;
|
||
|
import java.lang.reflect.InvocationTargetException;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class DynamiteModule {
|
||
|
public static final int LOCAL = -1;
|
||
|
public static final int NONE = 0;
|
||
|
public static final int NO_SELECTION = 0;
|
||
|
public static final int REMOTE = 1;
|
||
|
private static Boolean zzb = null;
|
||
|
private static String zzc = null;
|
||
|
private static boolean zzd = false;
|
||
|
private static int zze = -1;
|
||
|
private static Boolean zzf;
|
||
|
private static zzq zzk;
|
||
|
private static zzr zzl;
|
||
|
private final Context zzj;
|
||
|
private static final ThreadLocal zzg = new ThreadLocal();
|
||
|
private static final ThreadLocal zzh = new zzd();
|
||
|
private static final VersionPolicy.IVersions zzi = new zze();
|
||
|
public static final VersionPolicy PREFER_REMOTE = new zzf();
|
||
|
public static final VersionPolicy PREFER_LOCAL = new zzg();
|
||
|
public static final VersionPolicy PREFER_REMOTE_VERSION_NO_FORCE_STAGING = new zzh();
|
||
|
public static final VersionPolicy PREFER_HIGHEST_OR_LOCAL_VERSION = new zzi();
|
||
|
public static final VersionPolicy PREFER_HIGHEST_OR_LOCAL_VERSION_NO_FORCE_STAGING = new zzj();
|
||
|
public static final VersionPolicy PREFER_HIGHEST_OR_REMOTE_VERSION = new zzk();
|
||
|
public static final VersionPolicy zza = new zzl();
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public static class DynamiteLoaderClassLoader {
|
||
|
public static ClassLoader sClassLoader;
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public static class LoadingException extends Exception {
|
||
|
/* synthetic */ LoadingException(String str, zzp zzpVar) {
|
||
|
super(str);
|
||
|
}
|
||
|
|
||
|
/* synthetic */ LoadingException(String str, Throwable th, zzp zzpVar) {
|
||
|
super(str, th);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public interface VersionPolicy {
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public interface IVersions {
|
||
|
int zza(Context context, String str);
|
||
|
|
||
|
int zzb(Context context, String str, boolean z) throws LoadingException;
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public static class SelectionResult {
|
||
|
public int localVersion = 0;
|
||
|
public int remoteVersion = 0;
|
||
|
public int selection = 0;
|
||
|
}
|
||
|
|
||
|
SelectionResult selectModule(Context context, String str, IVersions iVersions) throws LoadingException;
|
||
|
}
|
||
|
|
||
|
private DynamiteModule(Context context) {
|
||
|
Preconditions.checkNotNull(context);
|
||
|
this.zzj = context;
|
||
|
}
|
||
|
|
||
|
public static int getLocalVersion(Context context, String str) {
|
||
|
try {
|
||
|
ClassLoader classLoader = context.getApplicationContext().getClassLoader();
|
||
|
StringBuilder sb = new StringBuilder("com.google.android.gms.dynamite.descriptors.");
|
||
|
sb.append(str);
|
||
|
sb.append(".ModuleDescriptor");
|
||
|
Class<?> loadClass = classLoader.loadClass(sb.toString());
|
||
|
Field declaredField = loadClass.getDeclaredField("MODULE_ID");
|
||
|
Field declaredField2 = loadClass.getDeclaredField("MODULE_VERSION");
|
||
|
if (!Objects.equal(declaredField.get(null), str)) {
|
||
|
declaredField.get(null);
|
||
|
return 0;
|
||
|
}
|
||
|
return declaredField2.getInt(null);
|
||
|
} catch (ClassNotFoundException unused) {
|
||
|
return 0;
|
||
|
} catch (Exception e) {
|
||
|
e.getMessage();
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int getRemoteVersion(Context context, String str) {
|
||
|
return zza(context, str, false);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Removed duplicated region for block: B:28:0x023e */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:31:0x0251 */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:34:0x0244 */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public static com.google.android.gms.dynamite.DynamiteModule load(android.content.Context r18, com.google.android.gms.dynamite.DynamiteModule.VersionPolicy r19, java.lang.String r20) throws com.google.android.gms.dynamite.DynamiteModule.LoadingException {
|
||
|
/*
|
||
|
Method dump skipped, instructions count: 602
|
||
|
To view this dump add '--comments-level debug' option
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.dynamite.DynamiteModule.load(android.content.Context, com.google.android.gms.dynamite.DynamiteModule$VersionPolicy, java.lang.String):com.google.android.gms.dynamite.DynamiteModule");
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Code restructure failed: missing block: B:39:0x011d, code lost:
|
||
|
|
||
|
if (zze(r11) != false) goto L83;
|
||
|
*/
|
||
|
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:48:0x014f -> B:24:0x0154). Please report as a decompilation issue!!! */
|
||
|
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:49:0x0151 -> B:24:0x0154). Please report as a decompilation issue!!! */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public static int zza(android.content.Context r10, java.lang.String r11, boolean r12) {
|
||
|
/*
|
||
|
Method dump skipped, instructions count: 357
|
||
|
To view this dump add '--comments-level debug' option
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.dynamite.DynamiteModule.zza(android.content.Context, java.lang.String, boolean):int");
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Code restructure failed: missing block: B:45:0x009c, code lost:
|
||
|
|
||
|
r10.close();
|
||
|
*/
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:57:0x00c1 */
|
||
|
/* JADX WARN: Type inference failed for: r0v0 */
|
||
|
/* JADX WARN: Type inference failed for: r0v1, types: [android.database.Cursor] */
|
||
|
/* JADX WARN: Type inference failed for: r0v2 */
|
||
|
/* JADX WARN: Type inference failed for: r0v3 */
|
||
|
/* JADX WARN: Type inference failed for: r0v4 */
|
||
|
/* JADX WARN: Type inference failed for: r0v5 */
|
||
|
/* JADX WARN: Type inference failed for: r0v6 */
|
||
|
/* JADX WARN: Type inference failed for: r0v7 */
|
||
|
/* JADX WARN: Type inference failed for: r0v8 */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
private static int zzb(android.content.Context r10, java.lang.String r11, boolean r12, boolean r13) throws com.google.android.gms.dynamite.DynamiteModule.LoadingException {
|
||
|
/*
|
||
|
r0 = 0
|
||
|
java.lang.ThreadLocal r1 = com.google.android.gms.dynamite.DynamiteModule.zzh // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
java.lang.Object r1 = r1.get() // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
java.lang.Long r1 = (java.lang.Long) r1 // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
long r1 = r1.longValue() // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
android.content.ContentResolver r3 = r10.getContentResolver() // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
java.lang.String r10 = "api_force_staging"
|
||
|
r9 = 1
|
||
|
if (r9 == r12) goto L18
|
||
|
java.lang.String r10 = "api"
|
||
|
L18:
|
||
|
android.net.Uri$Builder r12 = new android.net.Uri$Builder // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
r12.<init>() // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
java.lang.String r4 = "content"
|
||
|
android.net.Uri$Builder r12 = r12.scheme(r4) // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
java.lang.String r4 = "com.google.android.gms.chimera"
|
||
|
android.net.Uri$Builder r12 = r12.authority(r4) // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
android.net.Uri$Builder r10 = r12.path(r10) // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
android.net.Uri$Builder r10 = r10.appendPath(r11) // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
java.lang.String r11 = "requestStartTime"
|
||
|
java.lang.String r12 = java.lang.String.valueOf(r1) // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
android.net.Uri$Builder r10 = r10.appendQueryParameter(r11, r12) // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
android.net.Uri r4 = r10.build() // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
r5 = 0
|
||
|
r6 = 0
|
||
|
r7 = 0
|
||
|
r8 = 0
|
||
|
android.database.Cursor r10 = r3.query(r4, r5, r6, r7, r8) // Catch: java.lang.Throwable -> Laa java.lang.Exception -> Lac
|
||
|
if (r10 == 0) goto La0
|
||
|
boolean r11 = r10.moveToFirst() // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
if (r11 == 0) goto La0
|
||
|
r11 = 0
|
||
|
int r12 = r10.getInt(r11) // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
if (r12 <= 0) goto L8d
|
||
|
java.lang.Class<com.google.android.gms.dynamite.DynamiteModule> r1 = com.google.android.gms.dynamite.DynamiteModule.class
|
||
|
monitor-enter(r1) // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
r2 = 2
|
||
|
java.lang.String r2 = r10.getString(r2) // Catch: java.lang.Throwable -> L8a
|
||
|
com.google.android.gms.dynamite.DynamiteModule.zzc = r2 // Catch: java.lang.Throwable -> L8a
|
||
|
java.lang.String r2 = "loaderVersion"
|
||
|
int r2 = r10.getColumnIndex(r2) // Catch: java.lang.Throwable -> L8a
|
||
|
if (r2 < 0) goto L6e
|
||
|
int r2 = r10.getInt(r2) // Catch: java.lang.Throwable -> L8a
|
||
|
com.google.android.gms.dynamite.DynamiteModule.zze = r2 // Catch: java.lang.Throwable -> L8a
|
||
|
L6e:
|
||
|
java.lang.String r2 = "disableStandaloneDynamiteLoader2"
|
||
|
int r2 = r10.getColumnIndex(r2) // Catch: java.lang.Throwable -> L8a
|
||
|
if (r2 < 0) goto L81
|
||
|
int r2 = r10.getInt(r2) // Catch: java.lang.Throwable -> L8a
|
||
|
if (r2 == 0) goto L7d
|
||
|
goto L7e
|
||
|
L7d:
|
||
|
r9 = r11
|
||
|
L7e:
|
||
|
com.google.android.gms.dynamite.DynamiteModule.zzd = r9 // Catch: java.lang.Throwable -> L8a
|
||
|
r11 = r9
|
||
|
L81:
|
||
|
monitor-exit(r1)
|
||
|
boolean r1 = zze(r10) // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
if (r1 == 0) goto L8d
|
||
|
r10 = r0
|
||
|
goto L8d
|
||
|
L8a:
|
||
|
r11 = move-exception
|
||
|
monitor-exit(r1)
|
||
|
throw r11 // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
L8d:
|
||
|
if (r13 == 0) goto L9a
|
||
|
if (r11 != 0) goto L92
|
||
|
goto L9a
|
||
|
L92:
|
||
|
com.google.android.gms.dynamite.DynamiteModule$LoadingException r11 = new com.google.android.gms.dynamite.DynamiteModule$LoadingException // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
java.lang.String r12 = "forcing fallback to container DynamiteLoader impl"
|
||
|
r11.<init>(r12, r0) // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
throw r11 // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
L9a:
|
||
|
if (r10 == 0) goto L9f
|
||
|
r10.close()
|
||
|
L9f:
|
||
|
return r12
|
||
|
La0:
|
||
|
com.google.android.gms.dynamite.DynamiteModule$LoadingException r11 = new com.google.android.gms.dynamite.DynamiteModule$LoadingException // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
java.lang.String r12 = "Failed to connect to dynamite module ContentResolver."
|
||
|
r11.<init>(r12, r0) // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
throw r11 // Catch: java.lang.Exception -> La8 java.lang.Throwable -> Lbc
|
||
|
La8:
|
||
|
r11 = move-exception
|
||
|
goto Laf
|
||
|
Laa:
|
||
|
r10 = move-exception
|
||
|
goto Lbf
|
||
|
Lac:
|
||
|
r10 = move-exception
|
||
|
r11 = r10
|
||
|
r10 = r0
|
||
|
Laf:
|
||
|
boolean r12 = r11 instanceof com.google.android.gms.dynamite.DynamiteModule.LoadingException
|
||
|
if (r12 == 0) goto Lb4
|
||
|
throw r11 // Catch: java.lang.Throwable -> Lbc
|
||
|
Lb4:
|
||
|
com.google.android.gms.dynamite.DynamiteModule$LoadingException r12 = new com.google.android.gms.dynamite.DynamiteModule$LoadingException // Catch: java.lang.Throwable -> Lbc
|
||
|
java.lang.String r13 = "V2 version check failed"
|
||
|
r12.<init>(r13, r11, r0) // Catch: java.lang.Throwable -> Lbc
|
||
|
throw r12 // Catch: java.lang.Throwable -> Lbc
|
||
|
Lbc:
|
||
|
r11 = move-exception
|
||
|
r0 = r10
|
||
|
r10 = r11
|
||
|
Lbf:
|
||
|
if (r0 == 0) goto Lc4
|
||
|
r0.close()
|
||
|
Lc4:
|
||
|
throw r10
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.dynamite.DynamiteModule.zzb(android.content.Context, java.lang.String, boolean, boolean):int");
|
||
|
}
|
||
|
|
||
|
private static void zzd(ClassLoader classLoader) throws LoadingException {
|
||
|
zzr zzrVar;
|
||
|
zzp zzpVar = null;
|
||
|
try {
|
||
|
IBinder iBinder = (IBinder) classLoader.loadClass("com.google.android.gms.dynamiteloader.DynamiteLoaderV2").getConstructor(new Class[0]).newInstance(new Object[0]);
|
||
|
if (iBinder == null) {
|
||
|
zzrVar = null;
|
||
|
} else {
|
||
|
IInterface queryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.dynamite.IDynamiteLoaderV2");
|
||
|
if (queryLocalInterface instanceof zzr) {
|
||
|
zzrVar = (zzr) queryLocalInterface;
|
||
|
} else {
|
||
|
zzrVar = new zzr(iBinder);
|
||
|
}
|
||
|
}
|
||
|
zzl = zzrVar;
|
||
|
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||
|
throw new LoadingException("Failed to instantiate dynamite loader", e, zzpVar);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static boolean zze(Cursor cursor) {
|
||
|
zzn zznVar = (zzn) zzg.get();
|
||
|
if (zznVar == null || zznVar.zza != null) {
|
||
|
return false;
|
||
|
}
|
||
|
zznVar.zza = cursor;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
private static boolean zzf(Context context) {
|
||
|
if (Boolean.TRUE.equals(null) || Boolean.TRUE.equals(zzf)) {
|
||
|
return true;
|
||
|
}
|
||
|
boolean z = false;
|
||
|
if (zzf == null) {
|
||
|
ProviderInfo resolveContentProvider = context.getPackageManager().resolveContentProvider("com.google.android.gms.chimera", 0);
|
||
|
if (GoogleApiAvailabilityLight.getInstance().isGooglePlayServicesAvailable(context, ExceptionCode.CRASH_EXCEPTION) == 0 && resolveContentProvider != null && "com.google.android.gms".equals(PackageItemInfo.class.getField(CommonConstant.ReqAccessTokenParam.PACKAGE_NAME).get(resolveContentProvider))) {
|
||
|
z = true;
|
||
|
}
|
||
|
Boolean valueOf = Boolean.valueOf(z);
|
||
|
zzf = valueOf;
|
||
|
z = valueOf.booleanValue();
|
||
|
if (z && resolveContentProvider != null && ComponentInfo.class.getField("applicationInfo").get(resolveContentProvider) != null && (((ApplicationInfo) ComponentInfo.class.getField("applicationInfo").get(resolveContentProvider)).flags & 129) == 0) {
|
||
|
zzd = true;
|
||
|
}
|
||
|
}
|
||
|
return z;
|
||
|
}
|
||
|
|
||
|
private static zzq zzg(Context context) {
|
||
|
zzq zzqVar;
|
||
|
synchronized (DynamiteModule.class) {
|
||
|
zzq zzqVar2 = zzk;
|
||
|
if (zzqVar2 != null) {
|
||
|
return zzqVar2;
|
||
|
}
|
||
|
try {
|
||
|
IBinder iBinder = (IBinder) context.createPackageContext("com.google.android.gms", 3).getClassLoader().loadClass("com.google.android.gms.chimera.container.DynamiteLoaderImpl").newInstance();
|
||
|
if (iBinder == null) {
|
||
|
zzqVar = null;
|
||
|
} else {
|
||
|
IInterface queryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.dynamite.IDynamiteLoader");
|
||
|
zzqVar = queryLocalInterface instanceof zzq ? (zzq) queryLocalInterface : new zzq(iBinder);
|
||
|
}
|
||
|
if (zzqVar != null) {
|
||
|
zzk = zzqVar;
|
||
|
return zzqVar;
|
||
|
}
|
||
|
} catch (Exception e) {
|
||
|
e.getMessage();
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final IBinder instantiate(String str) throws LoadingException {
|
||
|
try {
|
||
|
return (IBinder) this.zzj.getClassLoader().loadClass(str).newInstance();
|
||
|
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
||
|
throw new LoadingException("Failed to instantiate module class: ".concat(String.valueOf(str)), e, null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static DynamiteModule zzc(Context context, String str) {
|
||
|
return new DynamiteModule(context.getApplicationContext());
|
||
|
}
|
||
|
|
||
|
public final Context getModuleContext() {
|
||
|
return this.zzj;
|
||
|
}
|
||
|
}
|