package com.google.vr.dynamite.client; import android.content.Context; import android.os.RemoteException; import android.util.ArrayMap; import android.util.Log; import dalvik.system.DexClassLoader; @UsedByNative /* loaded from: classes3.dex */ public final class DynamiteClient { public static final ArrayMap a = new ArrayMap(); private DynamiteClient() { } @UsedByNative public static synchronized int checkVersion(Context context, String str, String str2, String str3) { synchronized (DynamiteClient.class) { g gVar = new g(str, str2); e remoteLibraryLoaderFromInfo = getRemoteLibraryLoaderFromInfo(gVar); try { INativeLibraryLoader newNativeLibraryLoader = remoteLibraryLoaderFromInfo.b(context).newNativeLibraryLoader(ObjectWrapper.b(remoteLibraryLoaderFromInfo.a(context)), ObjectWrapper.b(context)); if (newNativeLibraryLoader != null) { return newNativeLibraryLoader.checkVersion(str3); } Log.e("DynamiteClient", "Failed to load native library " + gVar.toString() + " from remote package: no loader available."); return -1; } catch (RemoteException | d | IllegalArgumentException | IllegalStateException | SecurityException | UnsatisfiedLinkError e) { Log.e("DynamiteClient", "Failed to load native library " + gVar.toString() + " from remote package:\n ", e); return -1; } } } @UsedByNative public static synchronized ClassLoader getRemoteClassLoader(Context context, String str, String str2) { synchronized (DynamiteClient.class) { Context remoteContext = getRemoteContext(context, str, str2); if (remoteContext == null) { return null; } return remoteContext.getClassLoader(); } } @UsedByNative public static synchronized Context getRemoteContext(Context context, String str, String str2) { Context a2; synchronized (DynamiteClient.class) { g gVar = new g(str, str2); try { a2 = getRemoteLibraryLoaderFromInfo(gVar).a(context); } catch (d e) { Log.e("DynamiteClient", "Failed to get remote Context" + gVar.toString() + " from remote package:\n ", e); return null; } } return a2; } @UsedByNative public static synchronized ClassLoader getRemoteDexClassLoader(Context context, String str) { synchronized (DynamiteClient.class) { Context remoteContext = getRemoteContext(context, str, null); if (remoteContext == null) { return null; } try { return new DexClassLoader(remoteContext.getPackageCodePath(), context.getCodeCacheDir().getAbsolutePath(), remoteContext.getApplicationInfo().nativeLibraryDir, context.getClassLoader()); } catch (RuntimeException e) { Log.e("DynamiteClient", "Failed to create class loader for remote package\n ", e); return null; } } } @UsedByNative private static synchronized e getRemoteLibraryLoaderFromInfo(g gVar) { synchronized (DynamiteClient.class) { ArrayMap arrayMap = a; e eVar = (e) arrayMap.get(gVar); if (eVar != null) { return eVar; } e eVar2 = new e(gVar); arrayMap.put(gVar, eVar2); return eVar2; } } @UsedByNative public static synchronized long loadNativeRemoteLibrary(Context context, String str, String str2) { synchronized (DynamiteClient.class) { g gVar = new g(str, str2); e remoteLibraryLoaderFromInfo = getRemoteLibraryLoaderFromInfo(gVar); try { INativeLibraryLoader newNativeLibraryLoader = remoteLibraryLoaderFromInfo.b(context).newNativeLibraryLoader(ObjectWrapper.b(remoteLibraryLoaderFromInfo.a(context)), ObjectWrapper.b(context)); if (newNativeLibraryLoader != null) { return newNativeLibraryLoader.initializeAndLoadNativeLibrary(str2); } Log.e("DynamiteClient", "Failed to load native library " + gVar.toString() + " from remote package: no loader available."); return 0L; } catch (RemoteException | d | IllegalArgumentException | IllegalStateException | SecurityException | UnsatisfiedLinkError e) { Log.e("DynamiteClient", "Failed to load native library " + gVar.toString() + " from remote package:\n ", e); return 0L; } } } }