package com.google.vr.dynamite.client; import android.content.Context; import android.content.pm.PackageManager; import android.os.IBinder; import android.os.IInterface; import java.lang.reflect.InvocationTargetException; /* loaded from: classes3.dex */ public final class e { public Context a; public ILoadedInstanceCreator b; public final g c; public e(g gVar) { this.c = gVar; } public static IBinder c(ClassLoader classLoader) { try { return (IBinder) classLoader.loadClass("com.google.vr.dynamite.LoadedInstanceCreator").getDeclaredConstructor(new Class[0]).newInstance(new Object[0]); } catch (ClassNotFoundException e) { throw new IllegalStateException("Unable to find dynamic class ".concat("com.google.vr.dynamite.LoadedInstanceCreator"), e); } catch (IllegalAccessException e2) { throw new IllegalStateException("Unable to call the default constructor of ".concat("com.google.vr.dynamite.LoadedInstanceCreator"), e2); } catch (InstantiationException e3) { throw new IllegalStateException("Unable to instantiate the remote class ".concat("com.google.vr.dynamite.LoadedInstanceCreator"), e3); } catch (NoSuchMethodException e4) { throw new IllegalStateException("No constructor for dynamic class ".concat("com.google.vr.dynamite.LoadedInstanceCreator"), e4); } catch (InvocationTargetException e5) { throw new IllegalStateException("Unable to invoke constructor of dynamic class ".concat("com.google.vr.dynamite.LoadedInstanceCreator"), e5); } } public final synchronized Context a(Context context) { if (this.a == null) { try { this.a = context.createPackageContext(this.c.a(), 3); } catch (PackageManager.NameNotFoundException unused) { throw new d(); } } return this.a; } public final synchronized ILoadedInstanceCreator b(Context context) { ILoadedInstanceCreator aVar; try { if (this.b == null) { IBinder c = c(a(context).getClassLoader()); if (c == null) { aVar = null; } else { IInterface queryLocalInterface = c.queryLocalInterface("com.google.vr.dynamite.client.ILoadedInstanceCreator"); aVar = queryLocalInterface instanceof ILoadedInstanceCreator ? (ILoadedInstanceCreator) queryLocalInterface : new a(c); } this.b = aVar; } } catch (Throwable th) { throw th; } return this.b; } }