package v9; import com.facebook.common.memory.PooledByteBuffer; import com.facebook.imagepipeline.cache.CountingMemoryCache; import com.facebook.imagepipeline.cache.MemoryCacheParams; import com.facebook.imagepipeline.cache.d; import com.facebook.imagepipeline.core.ImagePipelineFactory; import java.lang.reflect.Field; import kotlin.Metadata; import kotlin.TypeCastException; import kotlin.jvm.internal.Intrinsics; import p4.c; import p9.a; import xs0.b; import z60.h; @Metadata(bv = {}, d1 = {"\u0000:\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0006\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0018\u0010\u0019J\u0012\u0010\u0005\u001a\u000e\u0012\u0004\u0012\u00020\u0003\u0012\u0004\u0012\u00020\u00040\u0002J\u0012\u0010\u0007\u001a\u000e\u0012\u0004\u0012\u00020\u0003\u0012\u0004\u0012\u00020\u00060\u0002J\u0006\u0010\t\u001a\u00020\bJ\u000e\u0010\f\u001a\u00020\u000b2\u0006\u0010\n\u001a\u00020\u0003J\u0006\u0010\u000e\u001a\u00020\rJ\u000e\u0010\u0010\u001a\u00020\b2\u0006\u0010\u000f\u001a\u00020\u000bJ\u0006\u0010\u0011\u001a\u00020\bJ*\u0010\u0017\u001a\u00020\b2\u0006\u0010\u0012\u001a\u00020\r2\u0006\u0010\u0013\u001a\u00020\r2\b\u0010\u0015\u001a\u0004\u0018\u00010\u00142\b\b\u0002\u0010\u0016\u001a\u00020\r¨\u0006\u001a"}, d2 = {"Lv9/e;", "", "Lcom/facebook/imagepipeline/cache/CountingMemoryCache;", "Lx2/e;", "Lp4/c;", "a", "Lcom/facebook/common/memory/PooledByteBuffer;", "d", "", "i", "cacheKey", "", "c", "", "b", "cacheSize", h.f160753a, "g", b.KV_KEY_HINT, "uriStr", "Lp9/a;", "bitmapLoadInfo", "size", "e", "<init>", "()V", "fasterfresco_release"}, k = 1, mv = {1, 4, 0}) /* compiled from: FrescoCacheUtils.kt */ public final class e { /* renamed from: a reason: collision with root package name */ public static volatile Field f139771a; /* renamed from: b reason: collision with root package name */ public static volatile Field f139772b; /* renamed from: c reason: collision with root package name */ public static volatile Field f139773c; /* renamed from: d reason: collision with root package name */ public static volatile Field f139774d; /* renamed from: e reason: collision with root package name */ public static volatile boolean f139775e; /* renamed from: f reason: collision with root package name */ public static int f139776f = -1; /* renamed from: g reason: collision with root package name */ public static int f139777g = -1; /* renamed from: h reason: collision with root package name */ public static final e f139778h = new e(); public static /* synthetic */ void f(e eVar, String str, String str2, a aVar, String str3, int i10, Object obj) { if ((i10 & 8) != 0) { str3 = ""; } eVar.e(str, str2, aVar, str3); } public final CountingMemoryCache<x2.e, c> a() { ImagePipelineFactory instance = ImagePipelineFactory.getInstance(); Intrinsics.checkExpressionValueIsNotNull(instance, "ImagePipelineFactory.getInstance()"); CountingMemoryCache<x2.e, c> bitmapCountingMemoryCache = instance.getBitmapCountingMemoryCache(); if (bitmapCountingMemoryCache != null) { return bitmapCountingMemoryCache; } throw new TypeCastException("null cannot be cast to non-null type com.facebook.imagepipeline.cache.CountingMemoryCache<com.facebook.cache.common.CacheKey, com.facebook.imagepipeline.image.CloseableImage>"); } public final String b() { return "[ " + b.i(Integer.valueOf(a().o())) + ", " + a().j() + ", " + b.i(Integer.valueOf(a().l())) + ", " + a().k() + " : " + b.i(Integer.valueOf(d().o())) + ", " + d().j() + ", " + b.i(Integer.valueOf(d().l())) + ", " + d().k() + " ]"; } public final int c(x2.e eVar) { Intrinsics.checkParameterIsNotNull(eVar, "cacheKey"); try { g3.a<PooledByteBuffer> aVar = d().get(eVar); PooledByteBuffer F = aVar != null ? aVar.F() : null; if (F != null) { return F.size(); } return -1; } catch (Exception e14) { n9.a.a("-------------------------- FrescoCacheUtils, FrescoCacheUtils.getEncodedCacheSize(), Exception: " + e14.getMessage()); return -1; } } public final CountingMemoryCache<x2.e, PooledByteBuffer> d() { ImagePipelineFactory instance = ImagePipelineFactory.getInstance(); Intrinsics.checkExpressionValueIsNotNull(instance, "ImagePipelineFactory.getInstance()"); d<x2.e, PooledByteBuffer> encodedCountingMemoryCache = instance.getEncodedCountingMemoryCache(); if (encodedCountingMemoryCache != null) { return (CountingMemoryCache) encodedCountingMemoryCache; } throw new TypeCastException("null cannot be cast to non-null type com.facebook.imagepipeline.cache.CountingMemoryCache<com.facebook.cache.common.CacheKey, com.facebook.common.memory.PooledByteBuffer>"); } public final void e(String str, String str2, a aVar, String str3) { Intrinsics.checkParameterIsNotNull(str, b.KV_KEY_HINT); Intrinsics.checkParameterIsNotNull(str2, "uriStr"); Intrinsics.checkParameterIsNotNull(str3, "size"); if (!(str3.length() == 0)) { if (aVar != null) { aVar.a("FrescoUtils, " + f139778h.b() + ", hint = " + str + ", size = " + str3); } } else if (aVar != null) { aVar.a("FrescoUtils, " + f139778h.b() + ", hint = " + str); } } public final void g() { n9.a.a("FrescoCacheUtils.restoreLastBitmapMemoryCacheSize()"); h(f139776f); } public final synchronized void h(int i10) { Field field; long nanoTime = System.nanoTime(); n9.a.a("FrescoCacheUtils.setBitmapMemoryCacheSize(), cacheSize = " + i10); if (f139773c == null || f139772b == null || f139774d == null || i10 < 0) { n9.a.c("FrescoCacheUtils.setBitmapMemoryCacheSize(), mMaxCacheSizeField == null || cacheSize < 0 is true"); return; } try { Field field2 = f139772b; if (field2 == null) { Intrinsics.throwNpe(); } Object obj = field2.get(a()); if (obj != null) { MemoryCacheParams memoryCacheParams = (MemoryCacheParams) obj; f139776f = memoryCacheParams.f21887a / 1048576; Field field3 = f139773c; if (field3 != null) { field3.set(memoryCacheParams, Integer.valueOf(i10 * 1048576)); } if (!(i10 == 0 || (field = f139774d) == null)) { field.set(memoryCacheParams, Integer.valueOf(i10 * 1048576)); } a().g(); n9.a.a("FrescoCacheUtils.setBitmapMemoryCacheSize(), mLastBitmapMemoryCacheSize = " + f139776f + ", bitmapMemoryCacheParams.maxCacheSize = " + b.i(Integer.valueOf(memoryCacheParams.f21887a)) + ", spendTime = " + ((System.nanoTime() - nanoTime) / ((long) 1000)) + " 微秒"); return; } throw new TypeCastException("null cannot be cast to non-null type com.facebook.imagepipeline.cache.MemoryCacheParams"); } catch (Exception e14) { n9.a.c("FrescoCacheUtils.setBitmapMemoryCacheSize(), Exception: " + e14.getCause()); } } public final synchronized void i() { n9.a.a("FrescoCacheUtils.tryInitCacheField() start, mHasFieldInit = " + f139775e); long nanoTime = System.nanoTime(); if (!f139775e) { boolean z14 = true; try { if (f139771a == null) { Field declaredField = Field.class.getDeclaredField("accessFlags"); Intrinsics.checkExpressionValueIsNotNull(declaredField, "Field::class.java.getDeclaredField(\"accessFlags\")"); if (declaredField == null) { n9.a.c("FrescoCacheUtils.tryInitCacheField(), modifersField is null"); return; } else { declaredField.setAccessible(true); f139771a = declaredField; } } if (f139772b == null) { Field declaredField2 = CountingMemoryCache.class.getDeclaredField("mMemoryCacheParams"); Intrinsics.checkExpressionValueIsNotNull(declaredField2, "CountingMemoryCache::cla…eld(\"mMemoryCacheParams\")"); if (declaredField2 == null) { n9.a.c("FrescoCacheUtils.tryInitCacheField(), memoryCacheParamsField is null"); return; } declaredField2.setAccessible(true); Field field = f139771a; if (field != null) { field.setInt(declaredField2, declaredField2.getModifiers() & -17); } f139772b = declaredField2; } if (f139773c == null) { Field declaredField3 = MemoryCacheParams.class.getDeclaredField("a"); Intrinsics.checkExpressionValueIsNotNull(declaredField3, "MemoryCacheParams::class…aredField(\"maxCacheSize\")"); if (declaredField3 == null) { n9.a.c("FrescoCacheUtils.tryInitCacheField(), maxCacheSizeField is null"); return; } Field field2 = f139771a; if (field2 != null) { field2.setInt(declaredField3, declaredField3.getModifiers() & -17); } declaredField3.setAccessible(true); f139773c = declaredField3; } if (f139774d == null) { Field declaredField4 = MemoryCacheParams.class.getDeclaredField("b"); Intrinsics.checkExpressionValueIsNotNull(declaredField4, "MemoryCacheParams::class…d(\"maxEvictionQueueSize\")"); if (declaredField4 == null) { n9.a.c("FrescoCacheUtils.tryInitCacheField(), maxEvictionQueueSizeField is null"); return; } Field field3 = f139771a; if (field3 != null) { field3.setInt(declaredField4, declaredField4.getModifiers() & -17); } declaredField4.setAccessible(true); f139774d = declaredField4; } } catch (Exception e14) { n9.a.e("FrescoCacheUtils.tryInitCacheField(), exception: cause = " + e14.getCause() + ", message = " + e14.getMessage(), e14); b.g(e14); } if (f139771a == null || f139772b == null || f139773c == null) { z14 = false; } f139775e = z14; long nanoTime2 = (System.nanoTime() - nanoTime) / ((long) 1000); n9.a.a("FrescoCacheUtils.tryInitCacheField() end, mHasFieldInit = " + f139775e + ", spendTime = " + nanoTime2 + " 微秒"); } } }