Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.load.Key;
import java.io.File;
/* loaded from: classes.dex */
public interface DiskCache {
public interface Factory {
DiskCache build();
}
public interface Writer {
boolean a(File file);
}
File a(Key key);
void a(Key key, Writer writer);
void clear();
}

View File

@@ -0,0 +1,21 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.cache.DiskCache;
import java.io.File;
/* loaded from: classes.dex */
public class DiskCacheAdapter implements DiskCache {
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public File a(Key key) {
return null;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public void a(Key key, DiskCache.Writer writer) {
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public void clear() {
}
}

View File

@@ -0,0 +1,83 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.util.Preconditions;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/* loaded from: classes.dex */
final class DiskCacheWriteLocker {
private final Map<String, WriteLock> a = new HashMap();
private final WriteLockPool b = new WriteLockPool();
private static class WriteLock {
final Lock a = new ReentrantLock();
int b;
WriteLock() {
}
}
DiskCacheWriteLocker() {
}
void a(String str) {
WriteLock writeLock;
synchronized (this) {
writeLock = this.a.get(str);
if (writeLock == null) {
writeLock = this.b.a();
this.a.put(str, writeLock);
}
writeLock.b++;
}
writeLock.a.lock();
}
void b(String str) {
WriteLock writeLock;
synchronized (this) {
WriteLock writeLock2 = this.a.get(str);
Preconditions.a(writeLock2);
writeLock = writeLock2;
if (writeLock.b < 1) {
throw new IllegalStateException("Cannot release a lock that is not held, safeKey: " + str + ", interestedThreads: " + writeLock.b);
}
writeLock.b--;
if (writeLock.b == 0) {
WriteLock remove = this.a.remove(str);
if (!remove.equals(writeLock)) {
throw new IllegalStateException("Removed the wrong lock, expected to remove: " + writeLock + ", but actually removed: " + remove + ", safeKey: " + str);
}
this.b.a(remove);
}
}
writeLock.a.unlock();
}
private static class WriteLockPool {
private final Queue<WriteLock> a = new ArrayDeque();
WriteLockPool() {
}
WriteLock a() {
WriteLock poll;
synchronized (this.a) {
poll = this.a.poll();
}
return poll == null ? new WriteLock() : poll;
}
void a(WriteLock writeLock) {
synchronized (this.a) {
if (this.a.size() < 10) {
this.a.offer(writeLock);
}
}
}
}
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.load.engine.cache.DiskCache;
import java.io.File;
/* loaded from: classes.dex */
public class DiskLruCacheFactory implements DiskCache.Factory {
private final long a;
private final CacheDirectoryGetter b;
public interface CacheDirectoryGetter {
File a();
}
public DiskLruCacheFactory(CacheDirectoryGetter cacheDirectoryGetter, long j) {
this.a = j;
this.b = cacheDirectoryGetter;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache.Factory
public DiskCache build() {
File a = this.b.a();
if (a == null) {
return null;
}
if (a.mkdirs() || (a.exists() && a.isDirectory())) {
return DiskLruCacheWrapper.a(a, this.a);
}
return null;
}
}

View File

@@ -0,0 +1,112 @@
package com.bumptech.glide.load.engine.cache;
import android.util.Log;
import com.bumptech.glide.disklrucache.DiskLruCache;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.cache.DiskCache;
import java.io.File;
import java.io.IOException;
/* loaded from: classes.dex */
public class DiskLruCacheWrapper implements DiskCache {
private final File b;
private final long c;
private DiskLruCache e;
private final DiskCacheWriteLocker d = new DiskCacheWriteLocker();
private final SafeKeyGenerator a = new SafeKeyGenerator();
@Deprecated
protected DiskLruCacheWrapper(File file, long j) {
this.b = file;
this.c = j;
}
public static DiskCache a(File file, long j) {
return new DiskLruCacheWrapper(file, j);
}
private synchronized void b() {
this.e = null;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public synchronized void clear() {
try {
try {
a().a();
} catch (IOException e) {
if (Log.isLoggable("DiskLruCacheWrapper", 5)) {
Log.w("DiskLruCacheWrapper", "Unable to clear disk cache or disk cache cleared externally", e);
}
}
} finally {
b();
}
}
private synchronized DiskLruCache a() throws IOException {
if (this.e == null) {
this.e = DiskLruCache.a(this.b, 1, 1, this.c);
}
return this.e;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public File a(Key key) {
String a = this.a.a(key);
if (Log.isLoggable("DiskLruCacheWrapper", 2)) {
Log.v("DiskLruCacheWrapper", "Get: Obtained: " + a + " for for Key: " + key);
}
try {
DiskLruCache.Value b = a().b(a);
if (b != null) {
return b.a(0);
}
return null;
} catch (IOException e) {
if (!Log.isLoggable("DiskLruCacheWrapper", 5)) {
return null;
}
Log.w("DiskLruCacheWrapper", "Unable to get from disk cache", e);
return null;
}
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public void a(Key key, DiskCache.Writer writer) {
DiskLruCache a;
String a2 = this.a.a(key);
this.d.a(a2);
try {
if (Log.isLoggable("DiskLruCacheWrapper", 2)) {
Log.v("DiskLruCacheWrapper", "Put: Obtained: " + a2 + " for for Key: " + key);
}
try {
a = a();
} catch (IOException e) {
if (Log.isLoggable("DiskLruCacheWrapper", 5)) {
Log.w("DiskLruCacheWrapper", "Unable to put to disk cache", e);
}
}
if (a.b(a2) != null) {
return;
}
DiskLruCache.Editor a3 = a.a(a2);
if (a3 != null) {
try {
if (writer.a(a3.a(0))) {
a3.c();
}
a3.b();
return;
} catch (Throwable th) {
a3.b();
throw th;
}
}
throw new IllegalStateException("Had two simultaneous puts for: " + a2);
} finally {
this.d.b(a2);
}
}
}

View File

@@ -0,0 +1,36 @@
package com.bumptech.glide.load.engine.cache;
import android.content.Context;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import java.io.File;
/* loaded from: classes.dex */
public final class ExternalPreferredCacheDiskCacheFactory extends DiskLruCacheFactory {
public ExternalPreferredCacheDiskCacheFactory(Context context, long j) {
this(context, "image_manager_disk_cache", j);
}
public ExternalPreferredCacheDiskCacheFactory(final Context context, final String str, long j) {
super(new DiskLruCacheFactory.CacheDirectoryGetter() { // from class: com.bumptech.glide.load.engine.cache.ExternalPreferredCacheDiskCacheFactory.1
private File b() {
File cacheDir = context.getCacheDir();
if (cacheDir == null) {
return null;
}
String str2 = str;
return str2 != null ? new File(cacheDir, str2) : cacheDir;
}
@Override // com.bumptech.glide.load.engine.cache.DiskLruCacheFactory.CacheDirectoryGetter
public File a() {
File externalCacheDir;
File b = b();
if ((b != null && b.exists()) || (externalCacheDir = context.getExternalCacheDir()) == null || !externalCacheDir.canWrite()) {
return b;
}
String str2 = str;
return str2 != null ? new File(externalCacheDir, str2) : externalCacheDir;
}
}, j);
}
}

View File

@@ -0,0 +1,30 @@
package com.bumptech.glide.load.engine.cache;
import android.content.Context;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import java.io.File;
/* loaded from: classes.dex */
public final class InternalCacheDiskCacheFactory extends DiskLruCacheFactory {
public InternalCacheDiskCacheFactory(Context context) {
this(context, "image_manager_disk_cache", 262144000L);
}
public InternalCacheDiskCacheFactory(Context context, long j) {
this(context, "image_manager_disk_cache", j);
}
public InternalCacheDiskCacheFactory(final Context context, final String str, long j) {
super(new DiskLruCacheFactory.CacheDirectoryGetter() { // from class: com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory.1
@Override // com.bumptech.glide.load.engine.cache.DiskLruCacheFactory.CacheDirectoryGetter
public File a() {
File cacheDir = context.getCacheDir();
if (cacheDir == null) {
return null;
}
String str2 = str;
return str2 != null ? new File(cacheDir, str2) : cacheDir;
}
}, j);
}
}

View File

@@ -0,0 +1,63 @@
package com.bumptech.glide.load.engine.cache;
import android.annotation.SuppressLint;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.cache.MemoryCache;
import com.bumptech.glide.util.LruCache;
/* loaded from: classes.dex */
public class LruResourceCache extends LruCache<Key, Resource<?>> implements MemoryCache {
private MemoryCache.ResourceRemovedListener d;
public LruResourceCache(long j) {
super(j);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.engine.cache.MemoryCache
public /* bridge */ /* synthetic */ Resource a(Key key, Resource resource) {
return (Resource) super.b((LruResourceCache) key, (Key) resource);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.util.LruCache
/* renamed from: b, reason: merged with bridge method [inline-methods] */
public void a(Key key, Resource<?> resource) {
MemoryCache.ResourceRemovedListener resourceRemovedListener = this.d;
if (resourceRemovedListener == null || resource == null) {
return;
}
resourceRemovedListener.a(resource);
}
@Override // com.bumptech.glide.load.engine.cache.MemoryCache
public /* bridge */ /* synthetic */ Resource a(Key key) {
return (Resource) super.c(key);
}
@Override // com.bumptech.glide.load.engine.cache.MemoryCache
public void a(MemoryCache.ResourceRemovedListener resourceRemovedListener) {
this.d = resourceRemovedListener;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.util.LruCache
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public int b(Resource<?> resource) {
if (resource == null) {
return super.b(null);
}
return resource.getSize();
}
@Override // com.bumptech.glide.load.engine.cache.MemoryCache
@SuppressLint({"InlinedApi"})
public void a(int i) {
if (i >= 40) {
a();
} else if (i >= 20 || i == 15) {
a(b() / 2);
}
}
}

View File

@@ -0,0 +1,22 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
public interface MemoryCache {
public interface ResourceRemovedListener {
void a(Resource<?> resource);
}
Resource<?> a(Key key);
Resource<?> a(Key key, Resource<?> resource);
void a();
void a(int i);
void a(ResourceRemovedListener resourceRemovedListener);
}

View File

@@ -0,0 +1,145 @@
package com.bumptech.glide.load.engine.cache;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.text.format.Formatter;
import android.util.DisplayMetrics;
import android.util.Log;
import com.ijm.dataencryption.de.DataDecryptTool;
/* loaded from: classes.dex */
public final class MemorySizeCalculator {
private final int a;
private final int b;
private final Context c;
private final int d;
public static final class Builder {
static final int i;
final Context a;
ActivityManager b;
ScreenDimensions c;
float e;
float d = 2.0f;
float f = 0.4f;
float g = 0.33f;
int h = 4194304;
static {
i = Build.VERSION.SDK_INT < 26 ? 4 : 1;
}
public Builder(Context context) {
this.e = i;
this.a = context;
this.b = (ActivityManager) context.getSystemService("activity");
this.c = new DisplayMetricsScreenDimensions(context.getResources().getDisplayMetrics());
if (Build.VERSION.SDK_INT < 26 || !MemorySizeCalculator.a(this.b)) {
return;
}
this.e = 0.0f;
}
public MemorySizeCalculator a() {
return new MemorySizeCalculator(this);
}
}
private static final class DisplayMetricsScreenDimensions implements ScreenDimensions {
private final DisplayMetrics a;
DisplayMetricsScreenDimensions(DisplayMetrics displayMetrics) {
this.a = displayMetrics;
}
@Override // com.bumptech.glide.load.engine.cache.MemorySizeCalculator.ScreenDimensions
public int a() {
return this.a.heightPixels;
}
@Override // com.bumptech.glide.load.engine.cache.MemorySizeCalculator.ScreenDimensions
public int b() {
return this.a.widthPixels;
}
}
interface ScreenDimensions {
int a();
int b();
}
MemorySizeCalculator(Builder builder) {
this.c = builder.a;
this.d = a(builder.b) ? builder.h / 2 : builder.h;
int a = a(builder.b, builder.f, builder.g);
float b = builder.c.b() * builder.c.a() * 4;
int round = Math.round(builder.e * b);
int round2 = Math.round(b * builder.d);
int i = a - this.d;
int i2 = round2 + round;
if (i2 <= i) {
this.b = round2;
this.a = round;
} else {
float f = i;
float f2 = builder.e;
float f3 = builder.d;
float f4 = f / (f2 + f3);
this.b = Math.round(f3 * f4);
this.a = Math.round(f4 * builder.e);
}
if (Log.isLoggable("MemorySizeCalculator", 3)) {
StringBuilder sb = new StringBuilder();
sb.append("Calculation complete, Calculated memory cache size: ");
sb.append(a(this.b));
sb.append(", pool size: ");
sb.append(a(this.a));
sb.append(", byte array size: ");
sb.append(a(this.d));
sb.append(", memory class limited? ");
sb.append(i2 > a);
sb.append(", max size: ");
sb.append(a(a));
sb.append(", memoryClass: ");
sb.append(builder.b.getMemoryClass());
sb.append(", isLowMemoryDevice: ");
sb.append(a(builder.b));
Log.d("MemorySizeCalculator", sb.toString());
}
}
public int a() {
return this.d;
}
public int b() {
return this.a;
}
public int c() {
return this.b;
}
private static int a(ActivityManager activityManager, float f, float f2) {
float memoryClass = activityManager.getMemoryClass() * DataDecryptTool.DECRYPT_SP_FILE * DataDecryptTool.DECRYPT_SP_FILE;
if (a(activityManager)) {
f = f2;
}
return Math.round(memoryClass * f);
}
private String a(int i) {
return Formatter.formatFileSize(this.c, i);
}
@TargetApi(19)
static boolean a(ActivityManager activityManager) {
if (Build.VERSION.SDK_INT >= 19) {
return activityManager.isLowRamDevice();
}
return true;
}
}

View File

@@ -0,0 +1,67 @@
package com.bumptech.glide.load.engine.cache;
import androidx.core.util.Pools$Pool;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.util.LruCache;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.Util;
import com.bumptech.glide.util.pool.FactoryPools;
import com.bumptech.glide.util.pool.StateVerifier;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/* loaded from: classes.dex */
public class SafeKeyGenerator {
private final LruCache<Key, String> a = new LruCache<>(1000);
private final Pools$Pool<PoolableDigestContainer> b = FactoryPools.b(10, new FactoryPools.Factory<PoolableDigestContainer>(this) { // from class: com.bumptech.glide.load.engine.cache.SafeKeyGenerator.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.util.pool.FactoryPools.Factory
public PoolableDigestContainer a() {
try {
return new PoolableDigestContainer(MessageDigest.getInstance("SHA-256"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
});
private static final class PoolableDigestContainer implements FactoryPools.Poolable {
final MessageDigest a;
private final StateVerifier b = StateVerifier.b();
PoolableDigestContainer(MessageDigest messageDigest) {
this.a = messageDigest;
}
@Override // com.bumptech.glide.util.pool.FactoryPools.Poolable
public StateVerifier c() {
return this.b;
}
}
private String b(Key key) {
PoolableDigestContainer a = this.b.a();
Preconditions.a(a);
PoolableDigestContainer poolableDigestContainer = a;
try {
key.a(poolableDigestContainer.a);
return Util.a(poolableDigestContainer.a.digest());
} finally {
this.b.a(poolableDigestContainer);
}
}
public String a(Key key) {
String a;
synchronized (this.a) {
a = this.a.a((LruCache<Key, String>) key);
}
if (a == null) {
a = b(key);
}
synchronized (this.a) {
this.a.b(key, a);
}
return a;
}
}