mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-15 02:17:18 +01:00
469 lines
22 KiB
Java
469 lines
22 KiB
Java
package com.google.android.gms.dynamite;
|
|
|
|
import android.content.Context;
|
|
import android.content.pm.ApplicationInfo;
|
|
import android.content.pm.ProviderInfo;
|
|
import android.database.Cursor;
|
|
import android.os.IBinder;
|
|
import android.os.IInterface;
|
|
import android.os.RemoteException;
|
|
import android.util.Log;
|
|
import androidx.annotation.NonNull;
|
|
import com.google.android.gms.common.GoogleApiAvailabilityLight;
|
|
import com.google.android.gms.common.annotation.KeepForSdk;
|
|
import com.google.android.gms.common.internal.Objects;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import com.google.android.gms.common.util.CrashUtils;
|
|
import com.google.android.gms.common.util.DynamiteApi;
|
|
import com.google.android.gms.common.util.PlatformVersion;
|
|
import com.google.android.gms.dynamic.ObjectWrapper;
|
|
import dalvik.system.DelegateLastClassLoader;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@KeepForSdk
|
|
/* loaded from: classes7.dex */
|
|
public final class DynamiteModule {
|
|
|
|
@KeepForSdk
|
|
public static final int LOCAL = -1;
|
|
|
|
@KeepForSdk
|
|
public static final int NONE = 0;
|
|
|
|
@KeepForSdk
|
|
public static final int NO_SELECTION = 0;
|
|
|
|
@KeepForSdk
|
|
public static final int REMOTE = 1;
|
|
private static Boolean zzc = null;
|
|
private static String zzd = null;
|
|
private static boolean zze = false;
|
|
private static int zzf = -1;
|
|
private static Boolean zzg;
|
|
private static zzp zzl;
|
|
private static zzq zzm;
|
|
private final Context zzk;
|
|
private static final ThreadLocal zzh = new ThreadLocal();
|
|
private static final ThreadLocal zzi = new zze();
|
|
private static final VersionPolicy.IVersions zzj = new zzf();
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static final VersionPolicy PREFER_REMOTE = new zzg();
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static final VersionPolicy PREFER_LOCAL = new zzh();
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static final VersionPolicy PREFER_REMOTE_VERSION_NO_FORCE_STAGING = new zzi();
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static final VersionPolicy PREFER_HIGHEST_OR_LOCAL_VERSION = new zzj();
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static final VersionPolicy PREFER_HIGHEST_OR_LOCAL_VERSION_NO_FORCE_STAGING = new zzk();
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public static final VersionPolicy PREFER_HIGHEST_OR_REMOTE_VERSION = new zzl();
|
|
|
|
@NonNull
|
|
public static final VersionPolicy zza = new zzm();
|
|
|
|
@NonNull
|
|
public static final VersionPolicy zzb = new zzc();
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@DynamiteApi
|
|
public static class DynamiteLoaderClassLoader {
|
|
|
|
@NonNull
|
|
public static ClassLoader sClassLoader;
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public interface VersionPolicy {
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@KeepForSdk
|
|
public interface IVersions {
|
|
int zza(@NonNull Context context, @NonNull String str, boolean z) throws LoadingException;
|
|
|
|
int zzb(@NonNull Context context, @NonNull String str);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@KeepForSdk
|
|
public static class SelectionResult {
|
|
|
|
@KeepForSdk
|
|
public int localVersion = 0;
|
|
|
|
@KeepForSdk
|
|
public int remoteVersion = 0;
|
|
|
|
@KeepForSdk
|
|
public int selection = 0;
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
SelectionResult selectModule(@NonNull Context context, @NonNull String str, @NonNull IVersions iVersions) throws LoadingException;
|
|
}
|
|
|
|
private DynamiteModule(Context context) {
|
|
Preconditions.checkNotNull(context);
|
|
this.zzk = context;
|
|
}
|
|
|
|
@KeepForSdk
|
|
public static int getLocalVersion(@NonNull Context context, @NonNull String str) {
|
|
try {
|
|
ClassLoader classLoader = context.getApplicationContext().getClassLoader();
|
|
StringBuilder sb = new StringBuilder(String.valueOf(str).length() + 61);
|
|
sb.append("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)) {
|
|
return declaredField2.getInt(null);
|
|
}
|
|
String valueOf = String.valueOf(declaredField.get(null));
|
|
StringBuilder sb2 = new StringBuilder(valueOf.length() + 50 + String.valueOf(str).length() + 1);
|
|
sb2.append("Module descriptor id '");
|
|
sb2.append(valueOf);
|
|
sb2.append("' didn't match expected id '");
|
|
sb2.append(str);
|
|
sb2.append("'");
|
|
Log.e("DynamiteModule", sb2.toString());
|
|
return 0;
|
|
} catch (ClassNotFoundException unused) {
|
|
StringBuilder sb3 = new StringBuilder(String.valueOf(str).length() + 45);
|
|
sb3.append("Local module descriptor class for ");
|
|
sb3.append(str);
|
|
sb3.append(" not found.");
|
|
Log.w("DynamiteModule", sb3.toString());
|
|
return 0;
|
|
} catch (Exception e) {
|
|
Log.e("DynamiteModule", "Failed to load module descriptor class: ".concat(String.valueOf(e.getMessage())));
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
@KeepForSdk
|
|
public static int getRemoteVersion(@NonNull Context context, @NonNull String str) {
|
|
return zza(context, str, false);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Removed duplicated region for block: B:68:0x02d0 A[DONT_GENERATE] */
|
|
/* JADX WARN: Removed duplicated region for block: B:71:0x02df A[DONT_GENERATE] */
|
|
/* JADX WARN: Removed duplicated region for block: B:74:0x02d6 A[DONT_GENERATE] */
|
|
/* JADX WARN: Type inference failed for: r4v0, types: [java.lang.String] */
|
|
@androidx.annotation.NonNull
|
|
@com.google.android.gms.common.annotation.KeepForSdk
|
|
/*
|
|
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(@androidx.annotation.NonNull android.content.Context r30, @androidx.annotation.NonNull com.google.android.gms.dynamite.DynamiteModule.VersionPolicy r31, @androidx.annotation.NonNull java.lang.String r32) throws com.google.android.gms.dynamite.DynamiteModule.LoadingException {
|
|
/*
|
|
Method dump skipped, instructions count: 907
|
|
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: Unsupported multi-entry loop pattern (BACK_EDGE: B:50:0x01c5 -> B:25:0x01ca). Please report as a decompilation issue!!! */
|
|
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:51:0x01c7 -> B:25:0x01ca). Please report as a decompilation issue!!! */
|
|
public static int zza(@NonNull Context context, @NonNull String str, boolean z) {
|
|
Field declaredField;
|
|
Throwable th;
|
|
RemoteException remoteException;
|
|
Cursor cursor;
|
|
try {
|
|
synchronized (DynamiteModule.class) {
|
|
Boolean bool = zzc;
|
|
int i = 0;
|
|
if (bool == null) {
|
|
try {
|
|
declaredField = context.getApplicationContext().getClassLoader().loadClass(DynamiteLoaderClassLoader.class.getName()).getDeclaredField("sClassLoader");
|
|
} catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException e) {
|
|
String obj = e.toString();
|
|
StringBuilder sb = new StringBuilder(obj.length() + 30);
|
|
sb.append("Failed to load module via V2: ");
|
|
sb.append(obj);
|
|
Log.w("DynamiteModule", sb.toString());
|
|
bool = Boolean.FALSE;
|
|
}
|
|
synchronized (declaredField.getDeclaringClass()) {
|
|
ClassLoader classLoader = (ClassLoader) declaredField.get(null);
|
|
if (classLoader == ClassLoader.getSystemClassLoader()) {
|
|
bool = Boolean.FALSE;
|
|
} else if (classLoader != null) {
|
|
try {
|
|
zzf(classLoader);
|
|
} catch (LoadingException unused) {
|
|
}
|
|
bool = Boolean.TRUE;
|
|
} else {
|
|
if (!zzb(context)) {
|
|
return 0;
|
|
}
|
|
if (!zze) {
|
|
Boolean bool2 = Boolean.TRUE;
|
|
if (!bool2.equals(null)) {
|
|
try {
|
|
int zzc2 = zzc(context, str, z, true);
|
|
String str2 = zzd;
|
|
if (str2 != null && !str2.isEmpty()) {
|
|
ClassLoader zza2 = zzb.zza();
|
|
if (zza2 == null) {
|
|
String str3 = zzd;
|
|
Preconditions.checkNotNull(str3);
|
|
zza2 = new DelegateLastClassLoader(str3, ClassLoader.getSystemClassLoader());
|
|
}
|
|
zzf(zza2);
|
|
declaredField.set(null, zza2);
|
|
zzc = bool2;
|
|
return zzc2;
|
|
}
|
|
return zzc2;
|
|
} catch (LoadingException unused2) {
|
|
declaredField.set(null, ClassLoader.getSystemClassLoader());
|
|
bool = Boolean.FALSE;
|
|
}
|
|
}
|
|
}
|
|
declaredField.set(null, ClassLoader.getSystemClassLoader());
|
|
bool = Boolean.FALSE;
|
|
}
|
|
zzc = bool;
|
|
}
|
|
}
|
|
if (bool.booleanValue()) {
|
|
try {
|
|
return zzc(context, str, z, false);
|
|
} catch (LoadingException e2) {
|
|
String message = e2.getMessage();
|
|
StringBuilder sb2 = new StringBuilder(String.valueOf(message).length() + 42);
|
|
sb2.append("Failed to retrieve remote module version: ");
|
|
sb2.append(message);
|
|
Log.w("DynamiteModule", sb2.toString());
|
|
return 0;
|
|
}
|
|
}
|
|
zzp zzg2 = zzg(context);
|
|
try {
|
|
if (zzg2 != null) {
|
|
try {
|
|
int zzi2 = zzg2.zzi();
|
|
if (zzi2 >= 3) {
|
|
zzn zznVar = (zzn) zzh.get();
|
|
if (zznVar == null || (cursor = zznVar.zza) == null) {
|
|
Cursor cursor2 = (Cursor) ObjectWrapper.unwrap(zzg2.zzj(ObjectWrapper.wrap(context), str, z, ((Long) zzi.get()).longValue()));
|
|
if (cursor2 != null) {
|
|
try {
|
|
if (cursor2.moveToFirst()) {
|
|
int i2 = cursor2.getInt(0);
|
|
r4 = (i2 <= 0 || !zzd(cursor2)) ? cursor2 : null;
|
|
if (r4 != null) {
|
|
r4.close();
|
|
}
|
|
i = i2;
|
|
}
|
|
} catch (RemoteException e3) {
|
|
remoteException = e3;
|
|
r4 = cursor2;
|
|
String message2 = remoteException.getMessage();
|
|
StringBuilder sb3 = new StringBuilder(String.valueOf(message2).length() + 42);
|
|
sb3.append("Failed to retrieve remote module version: ");
|
|
sb3.append(message2);
|
|
Log.w("DynamiteModule", sb3.toString());
|
|
if (r4 != null) {
|
|
r4.close();
|
|
}
|
|
return i;
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
r4 = cursor2;
|
|
if (r4 == null) {
|
|
throw th;
|
|
}
|
|
r4.close();
|
|
throw th;
|
|
}
|
|
}
|
|
Log.w("DynamiteModule", "Failed to retrieve remote module version.");
|
|
if (cursor2 != null) {
|
|
cursor2.close();
|
|
}
|
|
} else {
|
|
i = cursor.getInt(0);
|
|
}
|
|
} else if (zzi2 == 2) {
|
|
Log.w("DynamiteModule", "IDynamite loader version = 2, no high precision latency measurement.");
|
|
i = zzg2.zzh(ObjectWrapper.wrap(context), str, z);
|
|
} else {
|
|
Log.w("DynamiteModule", "IDynamite loader version < 2, falling back to getModuleVersion2");
|
|
i = zzg2.zzf(ObjectWrapper.wrap(context), str, z);
|
|
}
|
|
} catch (RemoteException e4) {
|
|
remoteException = e4;
|
|
}
|
|
}
|
|
return i;
|
|
} catch (Throwable th3) {
|
|
th = th3;
|
|
}
|
|
}
|
|
} catch (Throwable th4) {
|
|
CrashUtils.addDynamiteErrorToDropBox(context, th4);
|
|
throw th4;
|
|
}
|
|
}
|
|
|
|
private static boolean zzb(Context context) {
|
|
ApplicationInfo applicationInfo;
|
|
Boolean bool = Boolean.TRUE;
|
|
if (bool.equals(null) || bool.equals(zzg)) {
|
|
return true;
|
|
}
|
|
boolean z = false;
|
|
if (zzg == null) {
|
|
ProviderInfo resolveContentProvider = context.getPackageManager().resolveContentProvider("com.google.android.gms.chimera", true != PlatformVersion.isAtLeastQ() ? 0 : 268435456);
|
|
if (GoogleApiAvailabilityLight.getInstance().isGooglePlayServicesAvailable(context, 10000000) == 0 && resolveContentProvider != null && "com.google.android.gms".equals(resolveContentProvider.packageName)) {
|
|
z = true;
|
|
}
|
|
zzg = Boolean.valueOf(z);
|
|
if (z && (applicationInfo = resolveContentProvider.applicationInfo) != null && (applicationInfo.flags & 129) == 0) {
|
|
Log.i("DynamiteModule", "Non-system-image GmsCore APK, forcing V1");
|
|
zze = true;
|
|
}
|
|
}
|
|
if (!z) {
|
|
Log.e("DynamiteModule", "Invalid GmsCore APK, remote loading disabled.");
|
|
}
|
|
return z;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:47:0x014b, code lost:
|
|
|
|
r8.close();
|
|
*/
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Not initialized variable reg: 8, insn: 0x0147: MOVE (r2 I:??[OBJECT, ARRAY]) = (r8 I:??[OBJECT, ARRAY]) (LINE:328), block:B:114:0x0147 */
|
|
/* JADX WARN: Removed duplicated region for block: B:116:0x0189 */
|
|
/* JADX WARN: Removed duplicated region for block: B:118:? A[SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:14:0x00ef A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:53:0x0163 A[Catch: all -> 0x0141, TryCatch #0 {all -> 0x0141, blocks: (B:15:0x00ef, B:17:0x00f5, B:20:0x00fd, B:33:0x012a, B:40:0x0133, B:44:0x0139, B:45:0x0140, B:11:0x014f, B:12:0x015d, B:51:0x015f, B:53:0x0163, B:54:0x0185, B:55:0x0186), top: B:2:0x0003 }] */
|
|
/* JADX WARN: Removed duplicated region for block: B:55:0x0186 A[Catch: all -> 0x0141, TRY_LEAVE, TryCatch #0 {all -> 0x0141, blocks: (B:15:0x00ef, B:17:0x00f5, B:20:0x00fd, B:33:0x012a, B:40:0x0133, B:44:0x0139, B:45:0x0140, B:11:0x014f, B:12:0x015d, B:51:0x015f, B:53:0x0163, B:54:0x0185, B:55:0x0186), top: B:2:0x0003 }] */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
private static int zzc(android.content.Context r14, java.lang.String r15, boolean r16, boolean r17) throws com.google.android.gms.dynamite.DynamiteModule.LoadingException {
|
|
/*
|
|
Method dump skipped, instructions count: 397
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.dynamite.DynamiteModule.zzc(android.content.Context, java.lang.String, boolean, boolean):int");
|
|
}
|
|
|
|
private static boolean zzd(Cursor cursor) {
|
|
zzn zznVar = (zzn) zzh.get();
|
|
if (zznVar == null || zznVar.zza != null) {
|
|
return false;
|
|
}
|
|
zznVar.zza = cursor;
|
|
return true;
|
|
}
|
|
|
|
private static DynamiteModule zze(Context context, String str) {
|
|
Log.i("DynamiteModule", "Selected local version of ".concat(String.valueOf(str)));
|
|
return new DynamiteModule(context);
|
|
}
|
|
|
|
private static void zzf(ClassLoader classLoader) throws LoadingException {
|
|
zzq zzqVar;
|
|
byte[] bArr = null;
|
|
try {
|
|
IBinder iBinder = (IBinder) classLoader.loadClass("com.google.android.gms.dynamiteloader.DynamiteLoaderV2").getConstructor(null).newInstance(null);
|
|
if (iBinder == null) {
|
|
zzqVar = null;
|
|
} else {
|
|
IInterface queryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.dynamite.IDynamiteLoaderV2");
|
|
zzqVar = queryLocalInterface instanceof zzq ? (zzq) queryLocalInterface : new zzq(iBinder);
|
|
}
|
|
zzm = zzqVar;
|
|
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
|
throw new LoadingException("Failed to instantiate dynamite loader", e, bArr);
|
|
}
|
|
}
|
|
|
|
private static zzp zzg(Context context) {
|
|
zzp zzpVar;
|
|
synchronized (DynamiteModule.class) {
|
|
zzp zzpVar2 = zzl;
|
|
if (zzpVar2 != null) {
|
|
return zzpVar2;
|
|
}
|
|
try {
|
|
IBinder iBinder = (IBinder) context.createPackageContext("com.google.android.gms", 3).getClassLoader().loadClass("com.google.android.gms.chimera.container.DynamiteLoaderImpl").newInstance();
|
|
if (iBinder == null) {
|
|
zzpVar = null;
|
|
} else {
|
|
IInterface queryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.dynamite.IDynamiteLoader");
|
|
zzpVar = queryLocalInterface instanceof zzp ? (zzp) queryLocalInterface : new zzp(iBinder);
|
|
}
|
|
if (zzpVar != null) {
|
|
zzl = zzpVar;
|
|
return zzpVar;
|
|
}
|
|
} catch (Exception e) {
|
|
String message = e.getMessage();
|
|
StringBuilder sb = new StringBuilder(String.valueOf(message).length() + 45);
|
|
sb.append("Failed to load IDynamiteLoader from GmsCore: ");
|
|
sb.append(message);
|
|
Log.e("DynamiteModule", sb.toString());
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public Context getModuleContext() {
|
|
return this.zzk;
|
|
}
|
|
|
|
@NonNull
|
|
@KeepForSdk
|
|
public IBinder instantiate(@NonNull String str) throws LoadingException {
|
|
try {
|
|
return (IBinder) this.zzk.getClassLoader().loadClass(str).newInstance();
|
|
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
|
throw new LoadingException("Failed to instantiate module class: ".concat(String.valueOf(str)), e, null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@KeepForSdk
|
|
public static class LoadingException extends Exception {
|
|
public /* synthetic */ LoadingException(String str, Throwable th, byte[] bArr) {
|
|
super(str, th);
|
|
}
|
|
|
|
public /* synthetic */ LoadingException(String str, byte[] bArr) {
|
|
super(str);
|
|
}
|
|
}
|
|
}
|