44 lines
1.4 KiB
Java
44 lines
1.4 KiB
Java
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;
|
|
}
|
|
}
|
|
}
|