Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,616 @@
package com.facebook.appevents.suggestedevents;
import android.util.Patterns;
import com.applovin.sdk.AppLovinEventTypes;
import com.facebook.appevents.internal.ViewHierarchyConstants;
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
import com.ironsource.v8;
import com.ironsource.zm;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import java.io.File;
import java.io.FileInputStream;
import java.util.Map;
import java.util.regex.Pattern;
import kotlin.TuplesKt;
import kotlin.collections.MapsKt__MapsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.Charsets;
import kotlin.text.StringsKt__StringsKt;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public final class FeatureExtractor {
public static final FeatureExtractor INSTANCE = new FeatureExtractor();
private static final int NUM_OF_FEATURES = 30;
private static final String REGEX_ADD_TO_CART_BUTTON_TEXT = "(?i)add to(\\s|\\Z)|update(\\s|\\Z)|cart";
private static final String REGEX_ADD_TO_CART_PAGE_TITLE = "(?i)add to(\\s|\\Z)|update(\\s|\\Z)|cart|shop|buy";
private static final String REGEX_CR_HAS_CONFIRM_PASSWORD_FIELD = "(?i)(confirm.*password)|(password.*(confirmation|confirm)|confirmation)";
private static final String REGEX_CR_HAS_LOG_IN_KEYWORDS = "(?i)(sign in)|login|signIn";
private static final String REGEX_CR_HAS_SIGN_ON_KEYWORDS = "(?i)(sign.*(up|now)|registration|register|(create|apply).*(profile|account)|open.*account|account.*(open|creation|application)|enroll|join.*now)";
private static final String REGEX_CR_PASSWORD_FIELD = "password";
private static Map<String, String> eventInfo;
private static boolean initialized;
private static Map<String, String> languageInfo;
private static JSONObject rules;
private static Map<String, String> textTypeInfo;
private FeatureExtractor() {
}
public static final boolean isInitialized() {
if (CrashShieldHandler.isObjectCrashing(FeatureExtractor.class)) {
return false;
}
try {
return initialized;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, FeatureExtractor.class);
return false;
}
}
public static final void initialize(File file) {
Map<String, String> mapOf;
Map<String, String> mapOf2;
Map<String, String> mapOf3;
if (CrashShieldHandler.isObjectCrashing(FeatureExtractor.class)) {
return;
}
try {
try {
rules = new JSONObject();
FileInputStream fileInputStream = new FileInputStream(file);
byte[] bArr = new byte[fileInputStream.available()];
fileInputStream.read(bArr);
fileInputStream.close();
rules = new JSONObject(new String(bArr, Charsets.UTF_8));
mapOf = MapsKt__MapsKt.mapOf(TuplesKt.to(ViewHierarchyConstants.ENGLISH, "1"), TuplesKt.to(ViewHierarchyConstants.GERMAN, "2"), TuplesKt.to(ViewHierarchyConstants.SPANISH, "3"), TuplesKt.to(ViewHierarchyConstants.JAPANESE, "4"));
languageInfo = mapOf;
mapOf2 = MapsKt__MapsKt.mapOf(TuplesKt.to(ViewHierarchyConstants.VIEW_CONTENT, "0"), TuplesKt.to(ViewHierarchyConstants.SEARCH, "1"), TuplesKt.to(ViewHierarchyConstants.ADD_TO_CART, "2"), TuplesKt.to(ViewHierarchyConstants.ADD_TO_WISHLIST, "3"), TuplesKt.to(ViewHierarchyConstants.INITIATE_CHECKOUT, "4"), TuplesKt.to(ViewHierarchyConstants.ADD_PAYMENT_INFO, CampaignEx.CLICKMODE_ON), TuplesKt.to(ViewHierarchyConstants.PURCHASE, "6"), TuplesKt.to(ViewHierarchyConstants.LEAD, zm.e), TuplesKt.to(ViewHierarchyConstants.COMPLETE_REGISTRATION, "8"));
eventInfo = mapOf2;
mapOf3 = MapsKt__MapsKt.mapOf(TuplesKt.to(ViewHierarchyConstants.BUTTON_TEXT, "1"), TuplesKt.to(ViewHierarchyConstants.PAGE_TITLE, "2"), TuplesKt.to(ViewHierarchyConstants.RESOLVED_DOCUMENT_LINK, "3"), TuplesKt.to(ViewHierarchyConstants.BUTTON_ID, "4"));
textTypeInfo = mapOf3;
initialized = true;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, FeatureExtractor.class);
}
} catch (Exception unused) {
}
}
public static final String getTextFeature(String buttonText, String activityName, String appName) {
if (CrashShieldHandler.isObjectCrashing(FeatureExtractor.class)) {
return null;
}
try {
Intrinsics.checkNotNullParameter(buttonText, "buttonText");
Intrinsics.checkNotNullParameter(activityName, "activityName");
Intrinsics.checkNotNullParameter(appName, "appName");
String str = appName + " | " + activityName + ", " + buttonText;
if (str == null) {
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
}
String lowerCase = str.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase()");
return lowerCase;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, FeatureExtractor.class);
return null;
}
}
public static final float[] getDenseFeatures(JSONObject viewHierarchy, String appName) {
String lowerCase;
JSONObject jSONObject;
String screenName;
JSONArray jSONArray;
FeatureExtractor featureExtractor;
JSONObject interactedNode;
if (CrashShieldHandler.isObjectCrashing(FeatureExtractor.class)) {
return null;
}
try {
Intrinsics.checkNotNullParameter(viewHierarchy, "viewHierarchy");
Intrinsics.checkNotNullParameter(appName, "appName");
if (!initialized) {
return null;
}
float[] fArr = new float[30];
for (int i = 0; i < 30; i++) {
fArr[i] = 0.0f;
}
try {
lowerCase = appName.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase()");
jSONObject = new JSONObject(viewHierarchy.optJSONObject("view").toString());
screenName = viewHierarchy.optString(ViewHierarchyConstants.SCREEN_NAME_KEY);
jSONArray = new JSONArray();
featureExtractor = INSTANCE;
featureExtractor.pruneTree(jSONObject, jSONArray);
featureExtractor.sum(fArr, featureExtractor.parseFeatures(jSONObject));
interactedNode = featureExtractor.getInteractedNode(jSONObject);
} catch (JSONException unused) {
}
if (interactedNode == null) {
return null;
}
Intrinsics.checkNotNullExpressionValue(screenName, "screenName");
String jSONObject2 = jSONObject.toString();
Intrinsics.checkNotNullExpressionValue(jSONObject2, "viewTree.toString()");
featureExtractor.sum(fArr, featureExtractor.nonparseFeatures(interactedNode, jSONArray, screenName, jSONObject2, lowerCase));
return fArr;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, FeatureExtractor.class);
return null;
}
}
private final float[] parseFeatures(JSONObject jSONObject) {
boolean contains$default;
boolean contains$default2;
boolean contains$default3;
if (CrashShieldHandler.isObjectCrashing(this)) {
return null;
}
try {
float[] fArr = new float[30];
int i = 0;
for (int i2 = 0; i2 < 30; i2++) {
fArr[i2] = 0.0f;
}
String optString = jSONObject.optString("text");
Intrinsics.checkNotNullExpressionValue(optString, "node.optString(TEXT_KEY)");
String lowerCase = optString.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase()");
String optString2 = jSONObject.optString(ViewHierarchyConstants.HINT_KEY);
Intrinsics.checkNotNullExpressionValue(optString2, "node.optString(HINT_KEY)");
String lowerCase2 = optString2.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase2, "(this as java.lang.String).toLowerCase()");
String optString3 = jSONObject.optString(ViewHierarchyConstants.CLASS_NAME_KEY);
Intrinsics.checkNotNullExpressionValue(optString3, "node.optString(CLASS_NAME_KEY)");
String lowerCase3 = optString3.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase3, "(this as java.lang.String).toLowerCase()");
int optInt = jSONObject.optInt(ViewHierarchyConstants.INPUT_TYPE_KEY, -1);
String[] strArr = {lowerCase, lowerCase2};
if (matchIndicators(new String[]{"$", "amount", "price", v8.h.l}, strArr)) {
fArr[0] = fArr[0] + 1.0f;
}
if (matchIndicators(new String[]{REGEX_CR_PASSWORD_FIELD, "pwd"}, strArr)) {
fArr[1] = fArr[1] + 1.0f;
}
if (matchIndicators(new String[]{"tel", "phone"}, strArr)) {
fArr[2] = fArr[2] + 1.0f;
}
if (matchIndicators(new String[]{AppLovinEventTypes.USER_EXECUTED_SEARCH}, strArr)) {
fArr[4] = fArr[4] + 1.0f;
}
if (optInt >= 0) {
fArr[5] = fArr[5] + 1.0f;
}
if (optInt == 3 || optInt == 2) {
fArr[6] = fArr[6] + 1.0f;
}
if (optInt == 32 || Patterns.EMAIL_ADDRESS.matcher(lowerCase).matches()) {
fArr[7] = fArr[7] + 1.0f;
}
contains$default = StringsKt__StringsKt.contains$default(lowerCase3, "checkbox", false, 2, null);
if (contains$default) {
fArr[8] = fArr[8] + 1.0f;
}
if (matchIndicators(new String[]{CampaignEx.JSON_NATIVE_VIDEO_COMPLETE, "confirm", "done", "submit"}, new String[]{lowerCase})) {
fArr[10] = fArr[10] + 1.0f;
}
contains$default2 = StringsKt__StringsKt.contains$default(lowerCase3, "radio", false, 2, null);
if (contains$default2) {
contains$default3 = StringsKt__StringsKt.contains$default(lowerCase3, "button", false, 2, null);
if (contains$default3) {
fArr[12] = fArr[12] + 1.0f;
}
}
try {
JSONArray optJSONArray = jSONObject.optJSONArray(ViewHierarchyConstants.CHILDREN_VIEW_KEY);
int length = optJSONArray.length();
if (length > 0) {
while (true) {
int i3 = i + 1;
JSONObject jSONObject2 = optJSONArray.getJSONObject(i);
Intrinsics.checkNotNullExpressionValue(jSONObject2, "childViews.getJSONObject(i)");
sum(fArr, parseFeatures(jSONObject2));
if (i3 >= length) {
break;
}
i = i3;
}
}
} catch (JSONException unused) {
}
return fArr;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
return null;
}
}
private final float[] nonparseFeatures(JSONObject jSONObject, JSONArray jSONArray, String str, String str2, String str3) {
boolean contains$default;
if (CrashShieldHandler.isObjectCrashing(this)) {
return null;
}
try {
float[] fArr = new float[30];
for (int i = 0; i < 30; i++) {
fArr[i] = 0.0f;
}
int length = jSONArray.length();
fArr[3] = length > 1 ? length - 1.0f : 0.0f;
try {
int length2 = jSONArray.length();
if (length2 > 0) {
int i2 = 0;
while (true) {
int i3 = i2 + 1;
JSONObject jSONObject2 = jSONArray.getJSONObject(i2);
Intrinsics.checkNotNullExpressionValue(jSONObject2, "siblings.getJSONObject(i)");
if (isButton(jSONObject2)) {
fArr[9] = fArr[9] + 1.0f;
}
if (i3 >= length2) {
break;
}
i2 = i3;
}
}
} catch (JSONException unused) {
}
fArr[13] = -1.0f;
fArr[14] = -1.0f;
String str4 = str + '|' + str3;
StringBuilder sb = new StringBuilder();
StringBuilder sb2 = new StringBuilder();
updateHintAndTextRecursively(jSONObject, sb2, sb);
String sb3 = sb.toString();
Intrinsics.checkNotNullExpressionValue(sb3, "hintSB.toString()");
String sb4 = sb2.toString();
Intrinsics.checkNotNullExpressionValue(sb4, "textSB.toString()");
fArr[15] = regexMatched(ViewHierarchyConstants.ENGLISH, ViewHierarchyConstants.COMPLETE_REGISTRATION, ViewHierarchyConstants.BUTTON_TEXT, sb4) ? 1.0f : 0.0f;
fArr[16] = regexMatched(ViewHierarchyConstants.ENGLISH, ViewHierarchyConstants.COMPLETE_REGISTRATION, ViewHierarchyConstants.PAGE_TITLE, str4) ? 1.0f : 0.0f;
fArr[17] = regexMatched(ViewHierarchyConstants.ENGLISH, ViewHierarchyConstants.COMPLETE_REGISTRATION, ViewHierarchyConstants.BUTTON_ID, sb3) ? 1.0f : 0.0f;
contains$default = StringsKt__StringsKt.contains$default(str2, REGEX_CR_PASSWORD_FIELD, false, 2, null);
fArr[18] = contains$default ? 1.0f : 0.0f;
fArr[19] = regexMatched(REGEX_CR_HAS_CONFIRM_PASSWORD_FIELD, str2) ? 1.0f : 0.0f;
fArr[20] = regexMatched(REGEX_CR_HAS_LOG_IN_KEYWORDS, str2) ? 1.0f : 0.0f;
fArr[21] = regexMatched(REGEX_CR_HAS_SIGN_ON_KEYWORDS, str2) ? 1.0f : 0.0f;
fArr[22] = regexMatched(ViewHierarchyConstants.ENGLISH, ViewHierarchyConstants.PURCHASE, ViewHierarchyConstants.BUTTON_TEXT, sb4) ? 1.0f : 0.0f;
fArr[24] = regexMatched(ViewHierarchyConstants.ENGLISH, ViewHierarchyConstants.PURCHASE, ViewHierarchyConstants.PAGE_TITLE, str4) ? 1.0f : 0.0f;
fArr[25] = regexMatched(REGEX_ADD_TO_CART_BUTTON_TEXT, sb4) ? 1.0f : 0.0f;
fArr[27] = regexMatched(REGEX_ADD_TO_CART_PAGE_TITLE, str4) ? 1.0f : 0.0f;
fArr[28] = regexMatched(ViewHierarchyConstants.ENGLISH, ViewHierarchyConstants.LEAD, ViewHierarchyConstants.BUTTON_TEXT, sb4) ? 1.0f : 0.0f;
fArr[29] = regexMatched(ViewHierarchyConstants.ENGLISH, ViewHierarchyConstants.LEAD, ViewHierarchyConstants.PAGE_TITLE, str4) ? 1.0f : 0.0f;
return fArr;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
return null;
}
}
/* JADX WARN: Removed duplicated region for block: B:16:0x005c */
/* JADX WARN: Removed duplicated region for block: B:18:0x005d A[Catch: all -> 0x0062, TryCatch #0 {all -> 0x0062, blocks: (B:6:0x0008, B:8:0x000d, B:18:0x005d, B:20:0x0043, B:23:0x004c, B:25:0x0050, B:26:0x0064, B:27:0x0069, B:28:0x0029, B:31:0x0032, B:33:0x0036, B:34:0x006a, B:35:0x006f, B:36:0x0017, B:38:0x001b, B:39:0x0070, B:40:0x0075, B:41:0x0076, B:42:0x007b), top: B:5:0x0008 }] */
/* JADX WARN: Removed duplicated region for block: B:25:0x0050 A[Catch: all -> 0x0062, TryCatch #0 {all -> 0x0062, blocks: (B:6:0x0008, B:8:0x000d, B:18:0x005d, B:20:0x0043, B:23:0x004c, B:25:0x0050, B:26:0x0064, B:27:0x0069, B:28:0x0029, B:31:0x0032, B:33:0x0036, B:34:0x006a, B:35:0x006f, B:36:0x0017, B:38:0x001b, B:39:0x0070, B:40:0x0075, B:41:0x0076, B:42:0x007b), top: B:5:0x0008 }] */
/* JADX WARN: Removed duplicated region for block: B:26:0x0064 A[Catch: all -> 0x0062, TryCatch #0 {all -> 0x0062, blocks: (B:6:0x0008, B:8:0x000d, B:18:0x005d, B:20:0x0043, B:23:0x004c, B:25:0x0050, B:26:0x0064, B:27:0x0069, B:28:0x0029, B:31:0x0032, B:33:0x0036, B:34:0x006a, B:35:0x006f, B:36:0x0017, B:38:0x001b, B:39:0x0070, B:40:0x0075, B:41:0x0076, B:42:0x007b), top: B:5:0x0008 }] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private final boolean regexMatched(java.lang.String r5, java.lang.String r6, java.lang.String r7, java.lang.String r8) {
/*
r4 = this;
boolean r0 = com.facebook.internal.instrument.crashshield.CrashShieldHandler.isObjectCrashing(r4)
r1 = 0
if (r0 == 0) goto L8
return r1
L8:
org.json.JSONObject r0 = com.facebook.appevents.suggestedevents.FeatureExtractor.rules // Catch: java.lang.Throwable -> L62
r2 = 0
if (r0 == 0) goto L76
java.lang.String r3 = "rulesForLanguage"
org.json.JSONObject r0 = r0.optJSONObject(r3) // Catch: java.lang.Throwable -> L62
if (r0 != 0) goto L17
r5 = r2
goto L25
L17:
java.util.Map<java.lang.String, java.lang.String> r3 = com.facebook.appevents.suggestedevents.FeatureExtractor.languageInfo // Catch: java.lang.Throwable -> L62
if (r3 == 0) goto L70
java.lang.Object r5 = r3.get(r5) // Catch: java.lang.Throwable -> L62
java.lang.String r5 = (java.lang.String) r5 // Catch: java.lang.Throwable -> L62
org.json.JSONObject r5 = r0.optJSONObject(r5) // Catch: java.lang.Throwable -> L62
L25:
if (r5 != 0) goto L29
L27:
r5 = r2
goto L40
L29:
java.lang.String r0 = "rulesForEvent"
org.json.JSONObject r5 = r5.optJSONObject(r0) // Catch: java.lang.Throwable -> L62
if (r5 != 0) goto L32
goto L27
L32:
java.util.Map<java.lang.String, java.lang.String> r0 = com.facebook.appevents.suggestedevents.FeatureExtractor.eventInfo // Catch: java.lang.Throwable -> L62
if (r0 == 0) goto L6a
java.lang.Object r6 = r0.get(r6) // Catch: java.lang.Throwable -> L62
java.lang.String r6 = (java.lang.String) r6 // Catch: java.lang.Throwable -> L62
org.json.JSONObject r5 = r5.optJSONObject(r6) // Catch: java.lang.Throwable -> L62
L40:
if (r5 != 0) goto L43
goto L5a
L43:
java.lang.String r6 = "positiveRules"
org.json.JSONObject r5 = r5.optJSONObject(r6) // Catch: java.lang.Throwable -> L62
if (r5 != 0) goto L4c
goto L5a
L4c:
java.util.Map<java.lang.String, java.lang.String> r6 = com.facebook.appevents.suggestedevents.FeatureExtractor.textTypeInfo // Catch: java.lang.Throwable -> L62
if (r6 == 0) goto L64
java.lang.Object r6 = r6.get(r7) // Catch: java.lang.Throwable -> L62
java.lang.String r6 = (java.lang.String) r6 // Catch: java.lang.Throwable -> L62
java.lang.String r2 = r5.optString(r6) // Catch: java.lang.Throwable -> L62
L5a:
if (r2 != 0) goto L5d
goto L61
L5d:
boolean r1 = r4.regexMatched(r2, r8) // Catch: java.lang.Throwable -> L62
L61:
return r1
L62:
r5 = move-exception
goto L7c
L64:
java.lang.String r5 = "textTypeInfo"
kotlin.jvm.internal.Intrinsics.throwUninitializedPropertyAccessException(r5) // Catch: java.lang.Throwable -> L62
throw r2 // Catch: java.lang.Throwable -> L62
L6a:
java.lang.String r5 = "eventInfo"
kotlin.jvm.internal.Intrinsics.throwUninitializedPropertyAccessException(r5) // Catch: java.lang.Throwable -> L62
throw r2 // Catch: java.lang.Throwable -> L62
L70:
java.lang.String r5 = "languageInfo"
kotlin.jvm.internal.Intrinsics.throwUninitializedPropertyAccessException(r5) // Catch: java.lang.Throwable -> L62
throw r2 // Catch: java.lang.Throwable -> L62
L76:
java.lang.String r5 = "rules"
kotlin.jvm.internal.Intrinsics.throwUninitializedPropertyAccessException(r5) // Catch: java.lang.Throwable -> L62
throw r2 // Catch: java.lang.Throwable -> L62
L7c:
com.facebook.internal.instrument.crashshield.CrashShieldHandler.handleThrowable(r5, r4)
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: com.facebook.appevents.suggestedevents.FeatureExtractor.regexMatched(java.lang.String, java.lang.String, java.lang.String, java.lang.String):boolean");
}
private final boolean regexMatched(String str, String str2) {
if (CrashShieldHandler.isObjectCrashing(this)) {
return false;
}
try {
return Pattern.compile(str).matcher(str2).find();
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
return false;
}
}
private final boolean matchIndicators(String[] strArr, String[] strArr2) {
boolean contains$default;
if (CrashShieldHandler.isObjectCrashing(this)) {
return false;
}
try {
int length = strArr.length;
int i = 0;
while (i < length) {
String str = strArr[i];
i++;
int length2 = strArr2.length;
int i2 = 0;
while (i2 < length2) {
String str2 = strArr2[i2];
i2++;
contains$default = StringsKt__StringsKt.contains$default(str2, str, false, 2, null);
if (contains$default) {
return true;
}
}
}
return false;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
return false;
}
}
private final boolean pruneTree(JSONObject jSONObject, JSONArray jSONArray) {
boolean z;
if (CrashShieldHandler.isObjectCrashing(this)) {
return false;
}
try {
if (jSONObject.optBoolean(ViewHierarchyConstants.IS_INTERACTED_KEY)) {
return true;
}
JSONArray optJSONArray = jSONObject.optJSONArray(ViewHierarchyConstants.CHILDREN_VIEW_KEY);
int length = optJSONArray.length();
if (length > 0) {
int i = 0;
while (true) {
int i2 = i + 1;
if (optJSONArray.getJSONObject(i).optBoolean(ViewHierarchyConstants.IS_INTERACTED_KEY)) {
z = true;
break;
}
if (i2 >= length) {
break;
}
i = i2;
}
}
z = false;
boolean z2 = z;
JSONArray jSONArray2 = new JSONArray();
if (z) {
int length2 = optJSONArray.length();
if (length2 > 0) {
int i3 = 0;
while (true) {
int i4 = i3 + 1;
jSONArray.put(optJSONArray.getJSONObject(i3));
if (i4 >= length2) {
break;
}
i3 = i4;
}
}
} else {
int length3 = optJSONArray.length();
if (length3 > 0) {
int i5 = 0;
while (true) {
int i6 = i5 + 1;
JSONObject child = optJSONArray.getJSONObject(i5);
Intrinsics.checkNotNullExpressionValue(child, "child");
if (pruneTree(child, jSONArray)) {
jSONArray2.put(child);
z2 = true;
}
if (i6 >= length3) {
break;
}
i5 = i6;
}
}
jSONObject.put(ViewHierarchyConstants.CHILDREN_VIEW_KEY, jSONArray2);
}
return z2;
} catch (JSONException unused) {
return false;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
return false;
}
}
private final void sum(float[] fArr, float[] fArr2) {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
int length = fArr.length - 1;
if (length < 0) {
return;
}
int i = 0;
while (true) {
int i2 = i + 1;
fArr[i] = fArr[i] + fArr2[i];
if (i2 > length) {
return;
} else {
i = i2;
}
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
private final boolean isButton(JSONObject jSONObject) {
if (CrashShieldHandler.isObjectCrashing(this)) {
return false;
}
try {
return ((jSONObject.optInt(ViewHierarchyConstants.CLASS_TYPE_BITMASK_KEY) & 1) << 5) > 0;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
return false;
}
}
private final void updateHintAndTextRecursively(JSONObject jSONObject, StringBuilder sb, StringBuilder sb2) {
int length;
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
String optString = jSONObject.optString("text", "");
Intrinsics.checkNotNullExpressionValue(optString, "view.optString(TEXT_KEY, \"\")");
String lowerCase = optString.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase()");
String optString2 = jSONObject.optString(ViewHierarchyConstants.HINT_KEY, "");
Intrinsics.checkNotNullExpressionValue(optString2, "view.optString(HINT_KEY, \"\")");
String lowerCase2 = optString2.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase2, "(this as java.lang.String).toLowerCase()");
if (lowerCase.length() > 0) {
sb.append(lowerCase);
sb.append(" ");
}
if (lowerCase2.length() > 0) {
sb2.append(lowerCase2);
sb2.append(" ");
}
JSONArray optJSONArray = jSONObject.optJSONArray(ViewHierarchyConstants.CHILDREN_VIEW_KEY);
if (optJSONArray == null || (length = optJSONArray.length()) <= 0) {
return;
}
int i = 0;
while (true) {
int i2 = i + 1;
try {
JSONObject currentChildView = optJSONArray.getJSONObject(i);
Intrinsics.checkNotNullExpressionValue(currentChildView, "currentChildView");
updateHintAndTextRecursively(currentChildView, sb, sb2);
} catch (JSONException unused) {
}
if (i2 >= length) {
return;
} else {
i = i2;
}
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
private final JSONObject getInteractedNode(JSONObject jSONObject) {
int length;
if (CrashShieldHandler.isObjectCrashing(this)) {
return null;
}
try {
} catch (JSONException unused) {
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
if (jSONObject.optBoolean(ViewHierarchyConstants.IS_INTERACTED_KEY)) {
return jSONObject;
}
JSONArray optJSONArray = jSONObject.optJSONArray(ViewHierarchyConstants.CHILDREN_VIEW_KEY);
if (optJSONArray != null && (length = optJSONArray.length()) > 0) {
int i = 0;
while (true) {
int i2 = i + 1;
JSONObject jSONObject2 = optJSONArray.getJSONObject(i);
Intrinsics.checkNotNullExpressionValue(jSONObject2, "children.getJSONObject(i)");
JSONObject interactedNode = getInteractedNode(jSONObject2);
if (interactedNode != null) {
return interactedNode;
}
if (i2 >= length) {
break;
}
i = i2;
}
}
return null;
}
}

View File

@@ -0,0 +1,132 @@
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;
}
}
}

View File

@@ -0,0 +1,160 @@
package com.facebook.appevents.suggestedevents;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RatingBar;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TimePicker;
import com.facebook.appevents.codeless.internal.ViewHierarchy;
import com.facebook.appevents.internal.ViewHierarchyConstants;
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public final class SuggestedEventViewHierarchy {
public static final SuggestedEventViewHierarchy INSTANCE = new SuggestedEventViewHierarchy();
private static final List<Class<? extends View>> blacklistedViews;
private SuggestedEventViewHierarchy() {
}
static {
List<Class<? extends View>> listOf;
listOf = CollectionsKt__CollectionsKt.listOf((Object[]) new Class[]{Switch.class, Spinner.class, DatePicker.class, TimePicker.class, RadioGroup.class, RatingBar.class, EditText.class, AdapterView.class});
blacklistedViews = listOf;
}
public static final JSONObject getDictionaryOfView(View view, View clickedView) {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventViewHierarchy.class)) {
return null;
}
try {
Intrinsics.checkNotNullParameter(view, "view");
Intrinsics.checkNotNullParameter(clickedView, "clickedView");
JSONObject jSONObject = new JSONObject();
if (view == clickedView) {
try {
jSONObject.put(ViewHierarchyConstants.IS_INTERACTED_KEY, true);
} catch (JSONException unused) {
}
}
updateBasicInfo(view, jSONObject);
JSONArray jSONArray = new JSONArray();
Iterator<View> it = ViewHierarchy.getChildrenOfView(view).iterator();
while (it.hasNext()) {
jSONArray.put(getDictionaryOfView(it.next(), clickedView));
}
jSONObject.put(ViewHierarchyConstants.CHILDREN_VIEW_KEY, jSONArray);
return jSONObject;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventViewHierarchy.class);
return null;
}
}
public static final void updateBasicInfo(View view, JSONObject json) {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventViewHierarchy.class)) {
return;
}
try {
Intrinsics.checkNotNullParameter(view, "view");
Intrinsics.checkNotNullParameter(json, "json");
try {
String textOfView = ViewHierarchy.getTextOfView(view);
String hintOfView = ViewHierarchy.getHintOfView(view);
json.put(ViewHierarchyConstants.CLASS_NAME_KEY, view.getClass().getSimpleName());
json.put(ViewHierarchyConstants.CLASS_TYPE_BITMASK_KEY, ViewHierarchy.getClassTypeBitmask(view));
if (textOfView.length() > 0) {
json.put("text", textOfView);
}
if (hintOfView.length() > 0) {
json.put(ViewHierarchyConstants.HINT_KEY, hintOfView);
}
if (view instanceof EditText) {
json.put(ViewHierarchyConstants.INPUT_TYPE_KEY, ((EditText) view).getInputType());
}
} catch (JSONException unused) {
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventViewHierarchy.class);
}
}
public static final List<View> getAllClickableViews(View view) {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventViewHierarchy.class)) {
return null;
}
try {
Intrinsics.checkNotNullParameter(view, "view");
ArrayList arrayList = new ArrayList();
Iterator<Class<? extends View>> it = blacklistedViews.iterator();
while (it.hasNext()) {
if (it.next().isInstance(view)) {
return arrayList;
}
}
if (view.isClickable()) {
arrayList.add(view);
}
Iterator<View> it2 = ViewHierarchy.getChildrenOfView(view).iterator();
while (it2.hasNext()) {
arrayList.addAll(getAllClickableViews(it2.next()));
}
return arrayList;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventViewHierarchy.class);
return null;
}
}
public static final String getTextOfViewRecursively(View hostView) {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventViewHierarchy.class)) {
return null;
}
try {
Intrinsics.checkNotNullParameter(hostView, "hostView");
String textOfView = ViewHierarchy.getTextOfView(hostView);
if (textOfView.length() > 0) {
return textOfView;
}
String join = TextUtils.join(" ", INSTANCE.getTextOfChildren(hostView));
Intrinsics.checkNotNullExpressionValue(join, "join(\" \", childrenText)");
return join;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventViewHierarchy.class);
return null;
}
}
private final List<String> getTextOfChildren(View view) {
if (CrashShieldHandler.isObjectCrashing(this)) {
return null;
}
try {
ArrayList arrayList = new ArrayList();
for (View view2 : ViewHierarchy.getChildrenOfView(view)) {
String textOfView = ViewHierarchy.getTextOfView(view2);
if (textOfView.length() > 0) {
arrayList.add(textOfView);
}
arrayList.addAll(getTextOfChildren(view2));
}
return arrayList;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
return null;
}
}
}

View File

@@ -0,0 +1,204 @@
package com.facebook.appevents.suggestedevents;
import android.app.Activity;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import com.facebook.FacebookSdk;
import com.facebook.appevents.internal.ActivityLifecycleTracker;
import com.facebook.appevents.ml.ModelManager;
import com.facebook.internal.FetchedAppSettings;
import com.facebook.internal.FetchedAppSettingsManager;
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
import java.io.File;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import kotlin.jvm.internal.Intrinsics;
import org.json.JSONArray;
import org.json.JSONObject;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes2.dex */
public final class SuggestedEventsManager {
private static final String ELIGIBLE_EVENTS_KEY = "eligible_for_prediction_events";
private static final String PRODUCTION_EVENTS_KEY = "production_events";
public static final SuggestedEventsManager INSTANCE = new SuggestedEventsManager();
private static final AtomicBoolean enabled = new AtomicBoolean(false);
private static final Set<String> productionEvents = new LinkedHashSet();
private static final Set<String> eligibleEvents = new LinkedHashSet();
private SuggestedEventsManager() {
}
public static final synchronized void enable() {
synchronized (SuggestedEventsManager.class) {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventsManager.class)) {
return;
}
try {
FacebookSdk.getExecutor().execute(new Runnable() { // from class: com.facebook.appevents.suggestedevents.SuggestedEventsManager$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
SuggestedEventsManager.m521enable$lambda0();
}
});
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventsManager.class);
}
}
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: enable$lambda-0, reason: not valid java name */
public static final void m521enable$lambda0() {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventsManager.class)) {
return;
}
try {
AtomicBoolean atomicBoolean = enabled;
if (atomicBoolean.get()) {
return;
}
atomicBoolean.set(true);
INSTANCE.initialize();
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventsManager.class);
}
}
private final void initialize() {
String suggestedEventsSetting;
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
FetchedAppSettingsManager fetchedAppSettingsManager = FetchedAppSettingsManager.INSTANCE;
FetchedAppSettings queryAppSettings = FetchedAppSettingsManager.queryAppSettings(FacebookSdk.getApplicationId(), false);
if (queryAppSettings == null || (suggestedEventsSetting = queryAppSettings.getSuggestedEventsSetting()) == null) {
return;
}
populateEventsFromRawJsonString$facebook_core_release(suggestedEventsSetting);
if (!(!productionEvents.isEmpty()) && !(!eligibleEvents.isEmpty())) {
return;
}
ModelManager modelManager = ModelManager.INSTANCE;
File ruleFile = ModelManager.getRuleFile(ModelManager.Task.MTML_APP_EVENT_PREDICTION);
if (ruleFile == null) {
return;
}
FeatureExtractor.initialize(ruleFile);
Activity currentActivity = ActivityLifecycleTracker.getCurrentActivity();
if (currentActivity != null) {
trackActivity(currentActivity);
}
} catch (Exception unused) {
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
@VisibleForTesting(otherwise = 2)
public final void populateEventsFromRawJsonString$facebook_core_release(String str) {
JSONArray jSONArray;
int length;
JSONArray jSONArray2;
int length2;
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
JSONObject jSONObject = new JSONObject(str);
int i = 0;
if (jSONObject.has(PRODUCTION_EVENTS_KEY) && (length2 = (jSONArray2 = jSONObject.getJSONArray(PRODUCTION_EVENTS_KEY)).length()) > 0) {
int i2 = 0;
while (true) {
int i3 = i2 + 1;
Set<String> set = productionEvents;
String string = jSONArray2.getString(i2);
Intrinsics.checkNotNullExpressionValue(string, "jsonArray.getString(i)");
set.add(string);
if (i3 >= length2) {
break;
} else {
i2 = i3;
}
}
}
if (!jSONObject.has(ELIGIBLE_EVENTS_KEY) || (length = (jSONArray = jSONObject.getJSONArray(ELIGIBLE_EVENTS_KEY)).length()) <= 0) {
return;
}
while (true) {
int i4 = i + 1;
Set<String> set2 = eligibleEvents;
String string2 = jSONArray.getString(i);
Intrinsics.checkNotNullExpressionValue(string2, "jsonArray.getString(i)");
set2.add(string2);
if (i4 >= length) {
return;
} else {
i = i4;
}
}
} catch (Exception unused) {
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
public static final void trackActivity(Activity activity) {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventsManager.class)) {
return;
}
try {
Intrinsics.checkNotNullParameter(activity, "activity");
try {
if (!enabled.get() || !FeatureExtractor.isInitialized() || (productionEvents.isEmpty() && eligibleEvents.isEmpty())) {
ViewObserver.Companion.stopTrackingActivity(activity);
return;
}
ViewObserver.Companion.startTrackingActivity(activity);
} catch (Exception unused) {
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventsManager.class);
}
}
public static final boolean isEnabled() {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventsManager.class)) {
return false;
}
try {
return enabled.get();
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventsManager.class);
return false;
}
}
public static final boolean isProductionEvents$facebook_core_release(String event) {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventsManager.class)) {
return false;
}
try {
Intrinsics.checkNotNullParameter(event, "event");
return productionEvents.contains(event);
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventsManager.class);
return false;
}
}
public static final boolean isEligibleEvents$facebook_core_release(String event) {
if (CrashShieldHandler.isObjectCrashing(SuggestedEventsManager.class)) {
return false;
}
try {
Intrinsics.checkNotNullParameter(event, "event");
return eligibleEvents.contains(event);
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, SuggestedEventsManager.class);
return false;
}
}
}

View File

@@ -0,0 +1,233 @@
package com.facebook.appevents.suggestedevents;
import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.ViewTreeObserver;
import com.facebook.appevents.codeless.internal.SensitiveUserDataUtils;
import com.facebook.appevents.internal.AppEventUtility;
import com.facebook.appevents.suggestedevents.ViewOnClickListener;
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes2.dex */
public final class ViewObserver implements ViewTreeObserver.OnGlobalLayoutListener {
private static final int MAX_TEXT_LENGTH = 300;
private final WeakReference<Activity> activityWeakReference;
private final AtomicBoolean isTracking;
private final Handler uiThreadHandler;
public static final Companion Companion = new Companion(null);
private static final Map<Integer, ViewObserver> observers = new HashMap();
public /* synthetic */ ViewObserver(Activity activity, DefaultConstructorMarker defaultConstructorMarker) {
this(activity);
}
public static final void startTrackingActivity(Activity activity) {
if (CrashShieldHandler.isObjectCrashing(ViewObserver.class)) {
return;
}
try {
Companion.startTrackingActivity(activity);
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ViewObserver.class);
}
}
public static final void stopTrackingActivity(Activity activity) {
if (CrashShieldHandler.isObjectCrashing(ViewObserver.class)) {
return;
}
try {
Companion.stopTrackingActivity(activity);
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ViewObserver.class);
}
}
private ViewObserver(Activity activity) {
this.activityWeakReference = new WeakReference<>(activity);
this.uiThreadHandler = new Handler(Looper.getMainLooper());
this.isTracking = new AtomicBoolean(false);
}
public static final /* synthetic */ Map access$getObservers$cp() {
if (CrashShieldHandler.isObjectCrashing(ViewObserver.class)) {
return null;
}
try {
return observers;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ViewObserver.class);
return null;
}
}
public static final /* synthetic */ void access$startTracking(ViewObserver viewObserver) {
if (CrashShieldHandler.isObjectCrashing(ViewObserver.class)) {
return;
}
try {
viewObserver.startTracking();
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ViewObserver.class);
}
}
public static final /* synthetic */ void access$stopTracking(ViewObserver viewObserver) {
if (CrashShieldHandler.isObjectCrashing(ViewObserver.class)) {
return;
}
try {
viewObserver.stopTracking();
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ViewObserver.class);
}
}
private final void startTracking() {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
if (this.isTracking.getAndSet(true)) {
return;
}
AppEventUtility appEventUtility = AppEventUtility.INSTANCE;
View rootView = AppEventUtility.getRootView(this.activityWeakReference.get());
if (rootView == null) {
return;
}
ViewTreeObserver viewTreeObserver = rootView.getViewTreeObserver();
if (viewTreeObserver.isAlive()) {
viewTreeObserver.addOnGlobalLayoutListener(this);
process();
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
private final void stopTracking() {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
if (this.isTracking.getAndSet(false)) {
AppEventUtility appEventUtility = AppEventUtility.INSTANCE;
View rootView = AppEventUtility.getRootView(this.activityWeakReference.get());
if (rootView == null) {
return;
}
ViewTreeObserver viewTreeObserver = rootView.getViewTreeObserver();
if (viewTreeObserver.isAlive()) {
viewTreeObserver.removeOnGlobalLayoutListener(this);
}
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
@Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
public void onGlobalLayout() {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
process();
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
private final void process() {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
Runnable runnable = new Runnable() { // from class: com.facebook.appevents.suggestedevents.ViewObserver$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
ViewObserver.m522process$lambda0(ViewObserver.this);
}
};
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
runnable.run();
} else {
this.uiThreadHandler.post(runnable);
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: process$lambda-0, reason: not valid java name */
public static final void m522process$lambda0(ViewObserver this$0) {
if (CrashShieldHandler.isObjectCrashing(ViewObserver.class)) {
return;
}
try {
Intrinsics.checkNotNullParameter(this$0, "this$0");
try {
AppEventUtility appEventUtility = AppEventUtility.INSTANCE;
View rootView = AppEventUtility.getRootView(this$0.activityWeakReference.get());
Activity activity = this$0.activityWeakReference.get();
if (rootView != null && activity != null) {
for (View view : SuggestedEventViewHierarchy.getAllClickableViews(rootView)) {
if (!SensitiveUserDataUtils.isSensitiveUserData(view)) {
String textOfViewRecursively = SuggestedEventViewHierarchy.getTextOfViewRecursively(view);
if (textOfViewRecursively.length() > 0 && textOfViewRecursively.length() <= 300) {
ViewOnClickListener.Companion companion = ViewOnClickListener.Companion;
String localClassName = activity.getLocalClassName();
Intrinsics.checkNotNullExpressionValue(localClassName, "activity.localClassName");
companion.attachListener$facebook_core_release(view, rootView, localClassName);
}
}
}
}
} catch (Exception unused) {
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ViewObserver.class);
}
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final void startTrackingActivity(Activity activity) {
Intrinsics.checkNotNullParameter(activity, "activity");
int hashCode = activity.hashCode();
Map access$getObservers$cp = ViewObserver.access$getObservers$cp();
Integer valueOf = Integer.valueOf(hashCode);
Object obj = access$getObservers$cp.get(valueOf);
if (obj == null) {
obj = new ViewObserver(activity, null);
access$getObservers$cp.put(valueOf, obj);
}
ViewObserver.access$startTracking((ViewObserver) obj);
}
public final void stopTrackingActivity(Activity activity) {
Intrinsics.checkNotNullParameter(activity, "activity");
ViewObserver viewObserver = (ViewObserver) ViewObserver.access$getObservers$cp().remove(Integer.valueOf(activity.hashCode()));
if (viewObserver == null) {
return;
}
ViewObserver.access$stopTracking(viewObserver);
}
}
}

View File

@@ -0,0 +1,283 @@
package com.facebook.appevents.suggestedevents;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.RestrictTo;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.appevents.InternalAppEventsLogger;
import com.facebook.appevents.codeless.internal.ViewHierarchy;
import com.facebook.appevents.internal.ViewHierarchyConstants;
import com.facebook.appevents.ml.ModelManager;
import com.facebook.appevents.suggestedevents.ViewOnClickListener;
import com.facebook.internal.Utility;
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
import com.tapjoy.TJAdUnitConstants;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.StringsKt__StringsJVMKt;
import org.json.JSONException;
import org.json.JSONObject;
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes2.dex */
public final class ViewOnClickListener implements View.OnClickListener {
private static final String API_ENDPOINT = "%s/suggested_events";
public static final String OTHER_EVENT = "other";
private final String activityName;
private final View.OnClickListener baseListener;
private final WeakReference<View> hostViewWeakReference;
private final WeakReference<View> rootViewWeakReference;
public static final Companion Companion = new Companion(null);
private static final Set<Integer> viewsAttachedListener = new HashSet();
public /* synthetic */ ViewOnClickListener(View view, View view2, String str, DefaultConstructorMarker defaultConstructorMarker) {
this(view, view2, str);
}
public static final void attachListener$facebook_core_release(View view, View view2, String str) {
if (CrashShieldHandler.isObjectCrashing(ViewOnClickListener.class)) {
return;
}
try {
Companion.attachListener$facebook_core_release(view, view2, str);
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ViewOnClickListener.class);
}
}
private ViewOnClickListener(View view, View view2, String str) {
String replace$default;
this.baseListener = ViewHierarchy.getExistingOnClickListener(view);
this.rootViewWeakReference = new WeakReference<>(view2);
this.hostViewWeakReference = new WeakReference<>(view);
if (str == null) {
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
}
String lowerCase = str.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase()");
replace$default = StringsKt__StringsJVMKt.replace$default(lowerCase, "activity", "", false, 4, (Object) null);
this.activityName = replace$default;
}
public static final /* synthetic */ Set access$getViewsAttachedListener$cp() {
if (CrashShieldHandler.isObjectCrashing(ViewOnClickListener.class)) {
return null;
}
try {
return viewsAttachedListener;
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ViewOnClickListener.class);
return null;
}
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
Intrinsics.checkNotNullParameter(view, "view");
View.OnClickListener onClickListener = this.baseListener;
if (onClickListener != null) {
onClickListener.onClick(view);
}
process();
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
} catch (Throwable th2) {
CrashShieldHandler.handleThrowable(th2, this);
}
} catch (Throwable th3) {
CrashShieldHandler.handleThrowable(th3, this);
}
}
private final void process() {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
View view = this.rootViewWeakReference.get();
View view2 = this.hostViewWeakReference.get();
if (view == null || view2 == null) {
return;
}
try {
String textOfViewRecursively = SuggestedEventViewHierarchy.getTextOfViewRecursively(view2);
String pathID = PredictionHistoryManager.getPathID(view2, textOfViewRecursively);
if (pathID == null || Companion.queryHistoryAndProcess(pathID, textOfViewRecursively)) {
return;
}
JSONObject jSONObject = new JSONObject();
jSONObject.put("view", SuggestedEventViewHierarchy.getDictionaryOfView(view, view2));
jSONObject.put(ViewHierarchyConstants.SCREEN_NAME_KEY, this.activityName);
predictAndProcess(pathID, textOfViewRecursively, jSONObject);
} catch (Exception unused) {
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
private final void predictAndProcess(final String str, final String str2, final JSONObject jSONObject) {
if (CrashShieldHandler.isObjectCrashing(this)) {
return;
}
try {
Utility utility = Utility.INSTANCE;
Utility.runOnNonUiThread(new Runnable() { // from class: com.facebook.appevents.suggestedevents.ViewOnClickListener$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
ViewOnClickListener.m523predictAndProcess$lambda0(jSONObject, str2, this, str);
}
});
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, this);
}
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: predictAndProcess$lambda-0, reason: not valid java name */
public static final void m523predictAndProcess$lambda0(JSONObject viewData, String buttonText, ViewOnClickListener this$0, String pathID) {
if (CrashShieldHandler.isObjectCrashing(ViewOnClickListener.class)) {
return;
}
try {
Intrinsics.checkNotNullParameter(viewData, "$viewData");
Intrinsics.checkNotNullParameter(buttonText, "$buttonText");
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(pathID, "$pathID");
try {
Utility utility = Utility.INSTANCE;
String appName = Utility.getAppName(FacebookSdk.getApplicationContext());
if (appName == null) {
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
}
String lowerCase = appName.toLowerCase();
Intrinsics.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase()");
float[] denseFeatures = FeatureExtractor.getDenseFeatures(viewData, lowerCase);
String textFeature = FeatureExtractor.getTextFeature(buttonText, this$0.activityName, lowerCase);
if (denseFeatures == null) {
return;
}
ModelManager modelManager = ModelManager.INSTANCE;
String[] predict = ModelManager.predict(ModelManager.Task.MTML_APP_EVENT_PREDICTION, new float[][]{denseFeatures}, new String[]{textFeature});
if (predict == null) {
return;
}
String str = predict[0];
PredictionHistoryManager.addPrediction(pathID, str);
if (Intrinsics.areEqual(str, "other")) {
return;
}
Companion.processPredictedResult(str, buttonText, denseFeatures);
} catch (Exception unused) {
}
} catch (Throwable th) {
CrashShieldHandler.handleThrowable(th, ViewOnClickListener.class);
}
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final void attachListener$facebook_core_release(View hostView, View rootView, String activityName) {
Intrinsics.checkNotNullParameter(hostView, "hostView");
Intrinsics.checkNotNullParameter(rootView, "rootView");
Intrinsics.checkNotNullParameter(activityName, "activityName");
int hashCode = hostView.hashCode();
if (ViewOnClickListener.access$getViewsAttachedListener$cp().contains(Integer.valueOf(hashCode))) {
return;
}
ViewHierarchy viewHierarchy = ViewHierarchy.INSTANCE;
ViewHierarchy.setOnClickListener(hostView, new ViewOnClickListener(hostView, rootView, activityName, null));
ViewOnClickListener.access$getViewsAttachedListener$cp().add(Integer.valueOf(hashCode));
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean queryHistoryAndProcess(String str, final String str2) {
final String queryEvent = PredictionHistoryManager.queryEvent(str);
if (queryEvent == null) {
return false;
}
if (Intrinsics.areEqual(queryEvent, "other")) {
return true;
}
Utility utility = Utility.INSTANCE;
Utility.runOnNonUiThread(new Runnable() { // from class: com.facebook.appevents.suggestedevents.ViewOnClickListener$Companion$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
ViewOnClickListener.Companion.m524queryHistoryAndProcess$lambda0(queryEvent, str2);
}
});
return true;
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: queryHistoryAndProcess$lambda-0, reason: not valid java name */
public static final void m524queryHistoryAndProcess$lambda0(String queriedEvent, String buttonText) {
Intrinsics.checkNotNullParameter(queriedEvent, "$queriedEvent");
Intrinsics.checkNotNullParameter(buttonText, "$buttonText");
ViewOnClickListener.Companion.processPredictedResult(queriedEvent, buttonText, new float[0]);
}
/* JADX INFO: Access modifiers changed from: private */
public final void processPredictedResult(String str, String str2, float[] fArr) {
if (SuggestedEventsManager.isProductionEvents$facebook_core_release(str)) {
new InternalAppEventsLogger(FacebookSdk.getApplicationContext()).logEventFromSE(str, str2);
} else if (SuggestedEventsManager.isEligibleEvents$facebook_core_release(str)) {
sendPredictedResult(str, str2, fArr);
}
}
private final void sendPredictedResult(String str, String str2, float[] fArr) {
Bundle bundle = new Bundle();
try {
bundle.putString(TJAdUnitConstants.PARAM_PLACEMENT_NAME, str);
JSONObject jSONObject = new JSONObject();
StringBuilder sb = new StringBuilder();
int length = fArr.length;
int i = 0;
while (i < length) {
float f = fArr[i];
i++;
sb.append(f);
sb.append(",");
}
jSONObject.put("dense", sb.toString());
jSONObject.put("button_text", str2);
bundle.putString("metadata", jSONObject.toString());
GraphRequest.Companion companion = GraphRequest.Companion;
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format(Locale.US, ViewOnClickListener.API_ENDPOINT, Arrays.copyOf(new Object[]{FacebookSdk.getApplicationId()}, 1));
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(locale, format, *args)");
GraphRequest newPostRequest = companion.newPostRequest(null, format, null, null);
newPostRequest.setParameters(bundle);
newPostRequest.executeAndWait();
} catch (JSONException unused) {
}
}
}
}