Initial commit
This commit is contained in:
110
sources/io/fabric/sdk/android/FabricKitsFinder.java
Normal file
110
sources/io/fabric/sdk/android/FabricKitsFinder.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package io.fabric.sdk.android;
|
||||
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class FabricKitsFinder implements Callable<Map<String, KitInfo>> {
|
||||
final String a;
|
||||
|
||||
FabricKitsFinder(String str) {
|
||||
this.a = str;
|
||||
}
|
||||
|
||||
private KitInfo a(ZipEntry zipEntry, ZipFile zipFile) {
|
||||
InputStream inputStream;
|
||||
try {
|
||||
try {
|
||||
inputStream = zipFile.getInputStream(zipEntry);
|
||||
} catch (IOException e) {
|
||||
e = e;
|
||||
inputStream = null;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
zipFile = null;
|
||||
CommonUtils.a(zipFile);
|
||||
throw th;
|
||||
}
|
||||
try {
|
||||
Properties properties = new Properties();
|
||||
properties.load(inputStream);
|
||||
String property = properties.getProperty("fabric-identifier");
|
||||
String property2 = properties.getProperty("fabric-version");
|
||||
String property3 = properties.getProperty("fabric-build-type");
|
||||
if (!TextUtils.isEmpty(property) && !TextUtils.isEmpty(property2)) {
|
||||
KitInfo kitInfo = new KitInfo(property, property2, property3);
|
||||
CommonUtils.a((Closeable) inputStream);
|
||||
return kitInfo;
|
||||
}
|
||||
throw new IllegalStateException("Invalid format of fabric file," + zipEntry.getName());
|
||||
} catch (IOException e2) {
|
||||
e = e2;
|
||||
Fabric.g().b("Fabric", "Error when parsing fabric properties " + zipEntry.getName(), e);
|
||||
CommonUtils.a((Closeable) inputStream);
|
||||
return null;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
CommonUtils.a(zipFile);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, KitInfo> b() {
|
||||
HashMap hashMap = new HashMap();
|
||||
try {
|
||||
Class.forName("com.google.android.gms.ads.AdView");
|
||||
KitInfo kitInfo = new KitInfo("com.google.firebase.firebase-ads", "0.0.0", "binary");
|
||||
hashMap.put(kitInfo.b(), kitInfo);
|
||||
Fabric.g().v("Fabric", "Found kit: com.google.firebase.firebase-ads");
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
private Map<String, KitInfo> c() throws Exception {
|
||||
KitInfo a;
|
||||
HashMap hashMap = new HashMap();
|
||||
ZipFile a2 = a();
|
||||
Enumeration<? extends ZipEntry> entries = a2.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry nextElement = entries.nextElement();
|
||||
if (nextElement.getName().startsWith("fabric/") && nextElement.getName().length() > 7 && (a = a(nextElement, a2)) != null) {
|
||||
hashMap.put(a.b(), a);
|
||||
Fabric.g().v("Fabric", String.format("Found kit:[%s] version:[%s]", a.b(), a.c()));
|
||||
}
|
||||
}
|
||||
if (a2 != null) {
|
||||
try {
|
||||
a2.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.Callable
|
||||
public Map<String, KitInfo> call() throws Exception {
|
||||
HashMap hashMap = new HashMap();
|
||||
long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
hashMap.putAll(b());
|
||||
hashMap.putAll(c());
|
||||
Fabric.g().v("Fabric", "finish scanning in " + (SystemClock.elapsedRealtime() - elapsedRealtime));
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
protected ZipFile a() throws IOException {
|
||||
return new ZipFile(this.a);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user