Initial commit
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.bumptech.glide.signature;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
import com.bumptech.glide.load.Key;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ApplicationVersionSignature {
|
||||
private static final ConcurrentMap<String, Key> a = new ConcurrentHashMap();
|
||||
|
||||
private static String a(PackageInfo packageInfo) {
|
||||
return packageInfo != null ? String.valueOf(packageInfo.versionCode) : UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public static Key b(Context context) {
|
||||
String packageName = context.getPackageName();
|
||||
Key key = a.get(packageName);
|
||||
if (key != null) {
|
||||
return key;
|
||||
}
|
||||
Key c = c(context);
|
||||
Key putIfAbsent = a.putIfAbsent(packageName, c);
|
||||
return putIfAbsent == null ? c : putIfAbsent;
|
||||
}
|
||||
|
||||
private static Key c(Context context) {
|
||||
return new ObjectKey(a(a(context)));
|
||||
}
|
||||
|
||||
private static PackageInfo a(Context context) {
|
||||
try {
|
||||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e("AppVersionSignature", "Cannot resolve info for" + context.getPackageName(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
24
sources/com/bumptech/glide/signature/EmptySignature.java
Normal file
24
sources/com/bumptech/glide/signature/EmptySignature.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.bumptech.glide.signature;
|
||||
|
||||
import com.bumptech.glide.load.Key;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class EmptySignature implements Key {
|
||||
private static final EmptySignature b = new EmptySignature();
|
||||
|
||||
private EmptySignature() {
|
||||
}
|
||||
|
||||
public static EmptySignature a() {
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.Key
|
||||
public void a(MessageDigest messageDigest) {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "EmptySignature";
|
||||
}
|
||||
}
|
37
sources/com/bumptech/glide/signature/ObjectKey.java
Normal file
37
sources/com/bumptech/glide/signature/ObjectKey.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.bumptech.glide.signature;
|
||||
|
||||
import com.bumptech.glide.load.Key;
|
||||
import com.bumptech.glide.util.Preconditions;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ObjectKey implements Key {
|
||||
private final Object b;
|
||||
|
||||
public ObjectKey(Object obj) {
|
||||
Preconditions.a(obj);
|
||||
this.b = obj;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.Key
|
||||
public void a(MessageDigest messageDigest) {
|
||||
messageDigest.update(this.b.toString().getBytes(Key.a));
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.Key
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof ObjectKey) {
|
||||
return this.b.equals(((ObjectKey) obj).b);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.bumptech.glide.load.Key
|
||||
public int hashCode() {
|
||||
return this.b.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ObjectKey{object=" + this.b + '}';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user