- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
133 lines
5.5 KiB
Java
133 lines
5.5 KiB
Java
package com.facebook.appevents.suggestedevents;
|
|
|
|
import android.content.SharedPreferences;
|
|
import android.view.View;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.appevents.codeless.internal.ViewHierarchy;
|
|
import com.facebook.appevents.internal.ViewHierarchyConstants;
|
|
import com.facebook.internal.Utility;
|
|
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import kotlin.collections.MapsKt__MapsKt;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class PredictionHistoryManager {
|
|
private static final String CLICKED_PATH_STORE = "com.facebook.internal.SUGGESTED_EVENTS_HISTORY";
|
|
private static final String SUGGESTED_EVENTS_HISTORY = "SUGGESTED_EVENTS_HISTORY";
|
|
private static SharedPreferences shardPreferences;
|
|
public static final PredictionHistoryManager INSTANCE = new PredictionHistoryManager();
|
|
private static final Map<String, String> clickedViewPaths = new LinkedHashMap();
|
|
private static final AtomicBoolean initialized = new AtomicBoolean(false);
|
|
|
|
private PredictionHistoryManager() {
|
|
}
|
|
|
|
private final void initAndWait() {
|
|
String str = "";
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return;
|
|
}
|
|
try {
|
|
AtomicBoolean atomicBoolean = initialized;
|
|
if (atomicBoolean.get()) {
|
|
return;
|
|
}
|
|
SharedPreferences sharedPreferences = FacebookSdk.getApplicationContext().getSharedPreferences(CLICKED_PATH_STORE, 0);
|
|
Intrinsics.checkNotNullExpressionValue(sharedPreferences, "FacebookSdk.getApplicationContext()\n .getSharedPreferences(CLICKED_PATH_STORE, Context.MODE_PRIVATE)");
|
|
shardPreferences = sharedPreferences;
|
|
Map<String, String> map = clickedViewPaths;
|
|
Utility utility = Utility.INSTANCE;
|
|
SharedPreferences sharedPreferences2 = shardPreferences;
|
|
if (sharedPreferences2 != null) {
|
|
String string = sharedPreferences2.getString(SUGGESTED_EVENTS_HISTORY, "");
|
|
if (string != null) {
|
|
str = string;
|
|
}
|
|
map.putAll(Utility.jsonStrToMap(str));
|
|
atomicBoolean.set(true);
|
|
return;
|
|
}
|
|
Intrinsics.throwUninitializedPropertyAccessException("shardPreferences");
|
|
throw null;
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, this);
|
|
}
|
|
}
|
|
|
|
public static final void addPrediction(String pathID, String predictedEvent) {
|
|
Map map;
|
|
if (CrashShieldHandler.isObjectCrashing(PredictionHistoryManager.class)) {
|
|
return;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullParameter(pathID, "pathID");
|
|
Intrinsics.checkNotNullParameter(predictedEvent, "predictedEvent");
|
|
if (!initialized.get()) {
|
|
INSTANCE.initAndWait();
|
|
}
|
|
Map<String, String> map2 = clickedViewPaths;
|
|
map2.put(pathID, predictedEvent);
|
|
SharedPreferences sharedPreferences = shardPreferences;
|
|
if (sharedPreferences == null) {
|
|
Intrinsics.throwUninitializedPropertyAccessException("shardPreferences");
|
|
throw null;
|
|
}
|
|
SharedPreferences.Editor edit = sharedPreferences.edit();
|
|
Utility utility = Utility.INSTANCE;
|
|
map = MapsKt__MapsKt.toMap(map2);
|
|
edit.putString(SUGGESTED_EVENTS_HISTORY, Utility.mapToJsonStr(map)).apply();
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, PredictionHistoryManager.class);
|
|
}
|
|
}
|
|
|
|
public static final String getPathID(View view, String text) {
|
|
if (CrashShieldHandler.isObjectCrashing(PredictionHistoryManager.class)) {
|
|
return null;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
Intrinsics.checkNotNullParameter(text, "text");
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("text", text);
|
|
JSONArray jSONArray = new JSONArray();
|
|
while (view != null) {
|
|
jSONArray.put(view.getClass().getSimpleName());
|
|
view = ViewHierarchy.getParentOfView(view);
|
|
}
|
|
jSONObject.put(ViewHierarchyConstants.CLASS_NAME_KEY, jSONArray);
|
|
} catch (JSONException unused) {
|
|
}
|
|
Utility utility = Utility.INSTANCE;
|
|
return Utility.sha256hash(jSONObject.toString());
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, PredictionHistoryManager.class);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static final String queryEvent(String pathID) {
|
|
if (CrashShieldHandler.isObjectCrashing(PredictionHistoryManager.class)) {
|
|
return null;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullParameter(pathID, "pathID");
|
|
Map<String, String> map = clickedViewPaths;
|
|
if (map.containsKey(pathID)) {
|
|
return map.get(pathID);
|
|
}
|
|
return null;
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, PredictionHistoryManager.class);
|
|
return null;
|
|
}
|
|
}
|
|
}
|