- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
253 lines
10 KiB
Java
253 lines
10 KiB
Java
package com.tapjoy;
|
|
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import android.os.Environment;
|
|
import csdk.gluads.Consts;
|
|
import java.io.File;
|
|
import java.net.MalformedURLException;
|
|
import java.net.URL;
|
|
import java.util.Map;
|
|
import java.util.Vector;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Future;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public class TapjoyCache {
|
|
public static final String CACHE_DIRECTORY_NAME = "Tapjoy/Cache/";
|
|
public static final int CACHE_LIMIT = -1;
|
|
public static TapjoyCache f;
|
|
public static boolean unit_test_mode;
|
|
public final Context a;
|
|
public TapjoyCacheMap b;
|
|
public final Vector c;
|
|
public final ExecutorService d;
|
|
public final File e;
|
|
|
|
public class CacheAssetThread implements Callable<Boolean> {
|
|
public final URL a;
|
|
public final String b;
|
|
public final long c;
|
|
|
|
public CacheAssetThread(URL url, String str, long j) {
|
|
this.a = url;
|
|
this.b = str;
|
|
this.c = j;
|
|
if (j <= 0) {
|
|
this.c = 86400L;
|
|
}
|
|
TapjoyCache.this.c.add(TapjoyCache.a(url.toString()));
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Removed duplicated region for block: B:75:0x01e8 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:81:? A[SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:82:0x01e3 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
|
/* JADX WARN: Type inference failed for: r7v10 */
|
|
/* JADX WARN: Type inference failed for: r7v11 */
|
|
/* JADX WARN: Type inference failed for: r7v19 */
|
|
/* JADX WARN: Type inference failed for: r7v20 */
|
|
/* JADX WARN: Type inference failed for: r7v21 */
|
|
/* JADX WARN: Type inference failed for: r7v22 */
|
|
/* JADX WARN: Type inference failed for: r7v23, types: [java.io.BufferedOutputStream, java.io.OutputStream] */
|
|
/* JADX WARN: Type inference failed for: r7v6, types: [java.lang.String] */
|
|
/* JADX WARN: Type inference failed for: r7v7 */
|
|
@Override // java.util.concurrent.Callable
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public java.lang.Boolean call() {
|
|
/*
|
|
Method dump skipped, instructions count: 502
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.tapjoy.TapjoyCache.CacheAssetThread.call():java.lang.Boolean");
|
|
}
|
|
}
|
|
|
|
public TapjoyCache(Context context) {
|
|
if (f == null || unit_test_mode) {
|
|
f = this;
|
|
this.a = context;
|
|
this.b = new TapjoyCacheMap(context, -1);
|
|
this.c = new Vector();
|
|
this.d = Executors.newFixedThreadPool(5);
|
|
if (Environment.getExternalStorageDirectory() != null) {
|
|
TapjoyUtil.deleteFileOrDirectory(new File(Environment.getExternalStorageDirectory(), Consts.SDK_TAPJOY));
|
|
TapjoyUtil.deleteFileOrDirectory(new File(Environment.getExternalStorageDirectory(), "tjcache/tmp/"));
|
|
}
|
|
File file = new File(context.getFilesDir() + "/Tapjoy/Cache/");
|
|
this.e = file;
|
|
if (!file.exists()) {
|
|
if (file.mkdirs()) {
|
|
TapjoyLog.d("TapjoyCache", "Created directory at: " + file.getPath());
|
|
} else {
|
|
TapjoyLog.e("TapjoyCache", "Error initalizing cache");
|
|
f = null;
|
|
}
|
|
}
|
|
SharedPreferences sharedPreferences = context.getSharedPreferences(TapjoyConstants.PREF_TAPJOY_CACHE, 0);
|
|
SharedPreferences.Editor edit = sharedPreferences.edit();
|
|
for (Map.Entry<String, ?> entry : sharedPreferences.getAll().entrySet()) {
|
|
File file2 = new File(entry.getKey());
|
|
if (file2.exists() && file2.isFile()) {
|
|
TapjoyCachedAssetData fromRawJSONString = TapjoyCachedAssetData.fromRawJSONString(entry.getValue().toString());
|
|
if (fromRawJSONString != null) {
|
|
TapjoyLog.d("TapjoyCache", "Loaded Asset: " + fromRawJSONString.getAssetURL());
|
|
String a = a(fromRawJSONString.getAssetURL());
|
|
if (a == null || "".equals(a) || a.length() <= 0) {
|
|
TapjoyLog.e("TapjoyCache", "Removing asset because deserialization failed.");
|
|
edit.remove(entry.getKey()).apply();
|
|
} else if (fromRawJSONString.getTimeOfDeathInSeconds() < System.currentTimeMillis() / 1000) {
|
|
TapjoyLog.d("TapjoyCache", "Asset expired, removing from cache: " + fromRawJSONString.getAssetURL());
|
|
if (fromRawJSONString.getLocalFilePath() != null && fromRawJSONString.getLocalFilePath().length() > 0) {
|
|
TapjoyUtil.deleteFileOrDirectory(new File(fromRawJSONString.getLocalFilePath()));
|
|
}
|
|
} else {
|
|
this.b.put(a, fromRawJSONString);
|
|
}
|
|
} else {
|
|
TapjoyLog.e("TapjoyCache", "Removing asset because deserialization failed.");
|
|
edit.remove(entry.getKey()).apply();
|
|
}
|
|
} else {
|
|
TapjoyLog.d("TapjoyCache", "Removing reference to missing asset: " + entry.getKey());
|
|
edit.remove(entry.getKey()).apply();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static String a(String str) {
|
|
if (str.startsWith("//")) {
|
|
str = "http:".concat(str);
|
|
}
|
|
try {
|
|
return new URL(str).getFile();
|
|
} catch (MalformedURLException unused) {
|
|
TapjoyLog.e("TapjoyCache", "Invalid URL " + str);
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public static TapjoyCache getInstance() {
|
|
return f;
|
|
}
|
|
|
|
public static void setInstance(TapjoyCache tapjoyCache) {
|
|
f = tapjoyCache;
|
|
}
|
|
|
|
public Future<Boolean> cacheAssetFromJSONObject(JSONObject jSONObject) {
|
|
try {
|
|
return cacheAssetFromURL(jSONObject.getString("url"), jSONObject.optString(TapjoyConstants.TJC_PLACEMENT_OFFER_ID), jSONObject.optLong(TapjoyConstants.TJC_TIME_TO_LIVE));
|
|
} catch (JSONException unused) {
|
|
TapjoyLog.e("TapjoyCache", "Required parameters to cache an asset from JSON is not present");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public Future<Boolean> cacheAssetFromURL(String str, String str2, long j) {
|
|
try {
|
|
URL url = new URL(str);
|
|
if (!this.c.contains(a(str))) {
|
|
return startCachingThread(url, str2, j);
|
|
}
|
|
TapjoyLog.d("TapjoyCache", "URL is already in the process of being cached: ".concat(str));
|
|
return null;
|
|
} catch (MalformedURLException unused) {
|
|
TapjoyLog.d("TapjoyCache", "Invalid cache assetURL");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public void cacheAssetGroup(JSONArray jSONArray, TJCacheListener tJCacheListener) {
|
|
if (jSONArray != null && jSONArray.length() > 0) {
|
|
new n1(this, jSONArray, tJCacheListener).start();
|
|
} else if (tJCacheListener != null) {
|
|
tJCacheListener.onCachingComplete(1);
|
|
}
|
|
}
|
|
|
|
public String cachedAssetsToJSON() {
|
|
JSONObject jSONObject = new JSONObject();
|
|
for (Map.Entry<String, TapjoyCachedAssetData> entry : this.b.entrySet()) {
|
|
try {
|
|
jSONObject.put(entry.getKey().toString(), entry.getValue().toRawJSONString());
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
return jSONObject.toString();
|
|
}
|
|
|
|
public void clearTapjoyCache() {
|
|
TapjoyLog.d("TapjoyCache", "Cleaning Tapjoy cache!");
|
|
TapjoyUtil.deleteFileOrDirectory(this.e);
|
|
if (this.e.mkdirs()) {
|
|
TapjoyLog.d("TapjoyCache", "Created new cache directory at: " + this.e.getPath());
|
|
}
|
|
this.b = new TapjoyCacheMap(this.a, -1);
|
|
}
|
|
|
|
public TapjoyCacheMap getCachedData() {
|
|
return this.b;
|
|
}
|
|
|
|
public TapjoyCachedAssetData getCachedDataForURL(String str) {
|
|
String a = a(str);
|
|
if (a != "") {
|
|
return this.b.get(a);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public String getPathOfCachedURL(String str) {
|
|
String a = a(str);
|
|
if (a == "" || !this.b.containsKey(a)) {
|
|
return str;
|
|
}
|
|
TapjoyCachedAssetData tapjoyCachedAssetData = this.b.get(a);
|
|
if (new File(tapjoyCachedAssetData.getLocalFilePath()).exists()) {
|
|
return tapjoyCachedAssetData.getLocalURL();
|
|
}
|
|
getInstance().removeAssetFromCache(str);
|
|
return str;
|
|
}
|
|
|
|
public boolean isURLCached(String str) {
|
|
return this.b.get(a(str)) != null;
|
|
}
|
|
|
|
public void printCacheInformation() {
|
|
TapjoyLog.d("TapjoyCache", "------------- Cache Data -------------");
|
|
TapjoyLog.d("TapjoyCache", "Number of files in cache: " + this.b.size());
|
|
TapjoyLog.d("TapjoyCache", "Cache Size: " + TapjoyUtil.fileOrDirectorySize(this.e));
|
|
TapjoyLog.d("TapjoyCache", "--------------------------------------");
|
|
}
|
|
|
|
public boolean removeAssetFromCache(String str) {
|
|
String a = a(str);
|
|
return (a == "" || this.b.remove((Object) a) == null) ? false : true;
|
|
}
|
|
|
|
public Future<Boolean> startCachingThread(URL url, String str, long j) {
|
|
if (url != null) {
|
|
return this.d.submit(new CacheAssetThread(url, str, j));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public boolean isURLDownloading(String str) {
|
|
String a;
|
|
return (this.c == null || (a = a(str)) == "" || !this.c.contains(a)) ? false : true;
|
|
}
|
|
}
|