Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,182 @@
package com.facebook.appevents.internal;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.appevents.internal.SourceApplicationInfo;
import com.facebook.internal.FetchedAppSettings;
import com.facebook.internal.FetchedAppSettingsManager;
import com.facebook.internal.Utility;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
/* loaded from: classes.dex */
public class ActivityLifecycleTracker {
private static final String a = "com.facebook.appevents.internal.ActivityLifecycleTracker";
private static volatile ScheduledFuture c;
private static volatile SessionInfo e;
private static String g;
private static long h;
private static final ScheduledExecutorService b = Executors.newSingleThreadScheduledExecutor();
private static AtomicInteger d = new AtomicInteger(0);
private static AtomicBoolean f = new AtomicBoolean(false);
private static void g() {
if (c != null) {
c.cancel(false);
}
c = null;
}
public static UUID h() {
if (e != null) {
return e.c();
}
return null;
}
/* JADX INFO: Access modifiers changed from: private */
public static int i() {
FetchedAppSettings c2 = FetchedAppSettingsManager.c(FacebookSdk.c());
return c2 == null ? Constants.a() : c2.e();
}
public static void b(Activity activity) {
final long currentTimeMillis = System.currentTimeMillis();
final Context applicationContext = activity.getApplicationContext();
final String b2 = Utility.b(activity);
final SourceApplicationInfo a2 = SourceApplicationInfo.Factory.a(activity);
b.execute(new Runnable() { // from class: com.facebook.appevents.internal.ActivityLifecycleTracker.2
@Override // java.lang.Runnable
public void run() {
if (ActivityLifecycleTracker.e == null) {
SessionInfo j = SessionInfo.j();
if (j != null) {
SessionLogger.a(applicationContext, b2, j, ActivityLifecycleTracker.g);
}
SessionInfo unused = ActivityLifecycleTracker.e = new SessionInfo(Long.valueOf(currentTimeMillis), null);
ActivityLifecycleTracker.e.a(a2);
SessionLogger.a(applicationContext, b2, a2, ActivityLifecycleTracker.g);
}
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public static void c(Activity activity) {
if (d.decrementAndGet() < 0) {
d.set(0);
Log.w(a, "Unexpected activity pause without a matching activity resume. Logging data may be incorrect. Make sure you call activateApp from your Application's onCreate method");
}
g();
final long currentTimeMillis = System.currentTimeMillis();
final Context applicationContext = activity.getApplicationContext();
final String b2 = Utility.b(activity);
b.execute(new Runnable() { // from class: com.facebook.appevents.internal.ActivityLifecycleTracker.4
@Override // java.lang.Runnable
public void run() {
if (ActivityLifecycleTracker.e == null) {
SessionInfo unused = ActivityLifecycleTracker.e = new SessionInfo(Long.valueOf(currentTimeMillis), null);
}
ActivityLifecycleTracker.e.a(Long.valueOf(currentTimeMillis));
if (ActivityLifecycleTracker.d.get() <= 0) {
ScheduledFuture unused2 = ActivityLifecycleTracker.c = ActivityLifecycleTracker.b.schedule(new Runnable() { // from class: com.facebook.appevents.internal.ActivityLifecycleTracker.4.1
@Override // java.lang.Runnable
public void run() {
if (ActivityLifecycleTracker.d.get() <= 0) {
AnonymousClass4 anonymousClass4 = AnonymousClass4.this;
SessionLogger.a(applicationContext, b2, ActivityLifecycleTracker.e, ActivityLifecycleTracker.g);
SessionInfo.i();
SessionInfo unused3 = ActivityLifecycleTracker.e = null;
}
ScheduledFuture unused4 = ActivityLifecycleTracker.c = null;
}
}, ActivityLifecycleTracker.i(), TimeUnit.SECONDS);
}
long j = ActivityLifecycleTracker.h;
AutomaticAnalyticsLogger.a(b2, j > 0 ? (currentTimeMillis - j) / 1000 : 0L);
ActivityLifecycleTracker.e.h();
}
});
}
public static void d(Activity activity) {
d.incrementAndGet();
g();
final long currentTimeMillis = System.currentTimeMillis();
h = currentTimeMillis;
final Context applicationContext = activity.getApplicationContext();
final String b2 = Utility.b(activity);
b.execute(new Runnable() { // from class: com.facebook.appevents.internal.ActivityLifecycleTracker.3
@Override // java.lang.Runnable
public void run() {
if (ActivityLifecycleTracker.e == null) {
SessionInfo unused = ActivityLifecycleTracker.e = new SessionInfo(Long.valueOf(currentTimeMillis), null);
SessionLogger.a(applicationContext, b2, (SourceApplicationInfo) null, ActivityLifecycleTracker.g);
} else if (ActivityLifecycleTracker.e.d() != null) {
long longValue = currentTimeMillis - ActivityLifecycleTracker.e.d().longValue();
if (longValue > ActivityLifecycleTracker.i() * 1000) {
SessionLogger.a(applicationContext, b2, ActivityLifecycleTracker.e, ActivityLifecycleTracker.g);
SessionLogger.a(applicationContext, b2, (SourceApplicationInfo) null, ActivityLifecycleTracker.g);
SessionInfo unused2 = ActivityLifecycleTracker.e = new SessionInfo(Long.valueOf(currentTimeMillis), null);
} else if (longValue > 1000) {
ActivityLifecycleTracker.e.g();
}
}
ActivityLifecycleTracker.e.a(Long.valueOf(currentTimeMillis));
ActivityLifecycleTracker.e.h();
}
});
}
public static void a(Application application, String str) {
if (f.compareAndSet(false, true)) {
g = str;
application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() { // from class: com.facebook.appevents.internal.ActivityLifecycleTracker.1
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityCreated(Activity activity, Bundle bundle) {
AppEventUtility.a();
ActivityLifecycleTracker.b(activity);
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityDestroyed(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityPaused(Activity activity) {
AppEventUtility.a();
ActivityLifecycleTracker.c(activity);
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityResumed(Activity activity) {
AppEventUtility.a();
ActivityLifecycleTracker.d(activity);
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStarted(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStopped(Activity activity) {
AppEventsLogger.g();
}
});
}
}
}

View File

@@ -0,0 +1,10 @@
package com.facebook.appevents.internal;
/* loaded from: classes.dex */
public class AppEventUtility {
public static void a() {
}
public static void b() {
}
}

View File

@@ -0,0 +1,44 @@
package com.facebook.appevents.internal;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.internal.FetchedAppSettings;
import com.facebook.internal.FetchedAppSettingsManager;
import com.facebook.internal.Validate;
/* loaded from: classes.dex */
public class AutomaticAnalyticsLogger {
private static final String a = "com.facebook.appevents.internal.AutomaticAnalyticsLogger";
public static void a() {
Context b = FacebookSdk.b();
String c = FacebookSdk.c();
boolean e = FacebookSdk.e();
Validate.a(b, "context");
if (e) {
if (b instanceof Application) {
AppEventsLogger.a((Application) b, c);
} else {
Log.w(a, "Automatic logging of basic events will not happen, because FacebookSdk.getApplicationContext() returns object that is not instance of android.app.Application. Make sure you call FacebookSdk.sdkInitialize() from Application class and pass application context.");
}
}
}
public static void a(String str, long j) {
Context b = FacebookSdk.b();
String c = FacebookSdk.c();
Validate.a(b, "context");
FetchedAppSettings a2 = FetchedAppSettingsManager.a(c, false);
if (a2 == null || !a2.a() || j <= 0) {
return;
}
AppEventsLogger b2 = AppEventsLogger.b(b);
Bundle bundle = new Bundle(1);
bundle.putCharSequence("fb_aa_time_spent_view_name", str);
b2.a("fb_aa_time_spent_on_view", j, bundle);
}
}

View File

@@ -0,0 +1,8 @@
package com.facebook.appevents.internal;
/* loaded from: classes.dex */
public class Constants {
public static int a() {
return 60;
}
}

View File

@@ -0,0 +1,11 @@
package com.facebook.appevents.internal;
import com.facebook.AccessToken;
import com.facebook.appevents.AppEventsLogger;
/* loaded from: classes.dex */
class InternalAppEventsLogger extends AppEventsLogger {
InternalAppEventsLogger(String str, String str2, AccessToken accessToken) {
super(str, str2, accessToken);
}
}

View File

@@ -0,0 +1,109 @@
package com.facebook.appevents.internal;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.facebook.FacebookSdk;
import java.util.UUID;
/* loaded from: classes.dex */
class SessionInfo {
private Long a;
private Long b;
private int c;
private Long d;
private SourceApplicationInfo e;
private UUID f;
public SessionInfo(Long l, Long l2) {
this(l, l2, UUID.randomUUID());
}
public static void i() {
SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(FacebookSdk.b()).edit();
edit.remove("com.facebook.appevents.SessionInfo.sessionStartTime");
edit.remove("com.facebook.appevents.SessionInfo.sessionEndTime");
edit.remove("com.facebook.appevents.SessionInfo.interruptionCount");
edit.remove("com.facebook.appevents.SessionInfo.sessionId");
edit.apply();
SourceApplicationInfo.b();
}
public static SessionInfo j() {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(FacebookSdk.b());
long j = defaultSharedPreferences.getLong("com.facebook.appevents.SessionInfo.sessionStartTime", 0L);
long j2 = defaultSharedPreferences.getLong("com.facebook.appevents.SessionInfo.sessionEndTime", 0L);
String string = defaultSharedPreferences.getString("com.facebook.appevents.SessionInfo.sessionId", null);
if (j == 0 || j2 == 0 || string == null) {
return null;
}
SessionInfo sessionInfo = new SessionInfo(Long.valueOf(j), Long.valueOf(j2));
sessionInfo.c = defaultSharedPreferences.getInt("com.facebook.appevents.SessionInfo.interruptionCount", 0);
sessionInfo.e = SourceApplicationInfo.c();
sessionInfo.d = Long.valueOf(System.currentTimeMillis());
sessionInfo.f = UUID.fromString(string);
return sessionInfo;
}
public void a(Long l) {
this.b = l;
}
public int b() {
return this.c;
}
public UUID c() {
return this.f;
}
public Long d() {
return this.b;
}
public long e() {
Long l;
if (this.a == null || (l = this.b) == null) {
return 0L;
}
return l.longValue() - this.a.longValue();
}
public SourceApplicationInfo f() {
return this.e;
}
public void g() {
this.c++;
}
public void h() {
SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(FacebookSdk.b()).edit();
edit.putLong("com.facebook.appevents.SessionInfo.sessionStartTime", this.a.longValue());
edit.putLong("com.facebook.appevents.SessionInfo.sessionEndTime", this.b.longValue());
edit.putInt("com.facebook.appevents.SessionInfo.interruptionCount", this.c);
edit.putString("com.facebook.appevents.SessionInfo.sessionId", this.f.toString());
edit.apply();
SourceApplicationInfo sourceApplicationInfo = this.e;
if (sourceApplicationInfo != null) {
sourceApplicationInfo.a();
}
}
public SessionInfo(Long l, Long l2, UUID uuid) {
this.a = l;
this.b = l2;
this.f = uuid;
}
public long a() {
Long l = this.d;
if (l == null) {
return 0L;
}
return l.longValue();
}
public void a(SourceApplicationInfo sourceApplicationInfo) {
this.e = sourceApplicationInfo;
}
}

View File

@@ -0,0 +1,61 @@
package com.facebook.appevents.internal;
import android.content.Context;
import android.os.Bundle;
import com.facebook.LoggingBehavior;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.internal.Logger;
import java.util.Locale;
/* loaded from: classes.dex */
class SessionLogger {
private static final String a = "com.facebook.appevents.internal.SessionLogger";
private static final long[] b = {300000, 900000, 1800000, 3600000, 21600000, 43200000, 86400000, 172800000, 259200000, 604800000, 1209600000, 1814400000, 2419200000L, 5184000000L, 7776000000L, 10368000000L, 12960000000L, 15552000000L, 31536000000L};
public static void a(Context context, String str, SourceApplicationInfo sourceApplicationInfo, String str2) {
String sourceApplicationInfo2 = sourceApplicationInfo != null ? sourceApplicationInfo.toString() : "Unclassified";
Bundle bundle = new Bundle();
bundle.putString("fb_mobile_launch_source", sourceApplicationInfo2);
InternalAppEventsLogger internalAppEventsLogger = new InternalAppEventsLogger(str, str2, null);
internalAppEventsLogger.a("fb_mobile_activate_app", bundle);
if (AppEventsLogger.c() != AppEventsLogger.FlushBehavior.EXPLICIT_ONLY) {
internalAppEventsLogger.a();
}
}
public static void a(Context context, String str, SessionInfo sessionInfo, String str2) {
Long valueOf = Long.valueOf(sessionInfo.a() - sessionInfo.d().longValue());
if (valueOf.longValue() < 0) {
a();
valueOf = 0L;
}
Long valueOf2 = Long.valueOf(sessionInfo.e());
if (valueOf2.longValue() < 0) {
a();
valueOf2 = 0L;
}
Bundle bundle = new Bundle();
bundle.putInt("fb_mobile_app_interruptions", sessionInfo.b());
bundle.putString("fb_mobile_time_between_sessions", String.format(Locale.ROOT, "session_quanta_%d", Integer.valueOf(a(valueOf.longValue()))));
SourceApplicationInfo f = sessionInfo.f();
bundle.putString("fb_mobile_launch_source", f != null ? f.toString() : "Unclassified");
bundle.putLong("_logTime", sessionInfo.d().longValue() / 1000);
new InternalAppEventsLogger(str, str2, null).a("fb_mobile_deactivate_app", valueOf2.longValue() / 1000, bundle);
}
private static void a() {
Logger.a(LoggingBehavior.APP_EVENTS, a, "Clock skew detected");
}
private static int a(long j) {
int i = 0;
while (true) {
long[] jArr = b;
if (i >= jArr.length || jArr[i] >= j) {
break;
}
i++;
}
return i;
}
}

View File

@@ -0,0 +1,79 @@
package com.facebook.appevents.internal;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import bolts.AppLinks;
import com.facebook.FacebookSdk;
/* loaded from: classes.dex */
class SourceApplicationInfo {
private String a;
private boolean b;
public static class Factory {
public static SourceApplicationInfo a(Activity activity) {
ComponentName callingActivity = activity.getCallingActivity();
if (callingActivity == null) {
return null;
}
String packageName = callingActivity.getPackageName();
if (packageName.equals(activity.getPackageName())) {
return null;
}
Intent intent = activity.getIntent();
boolean z = false;
if (intent != null && !intent.getBooleanExtra("_fbSourceApplicationHasBeenSet", false)) {
intent.putExtra("_fbSourceApplicationHasBeenSet", true);
Bundle a = AppLinks.a(intent);
if (a != null) {
Bundle bundle = a.getBundle("referer_app_link");
if (bundle != null) {
packageName = bundle.getString("package");
}
z = true;
}
}
intent.putExtra("_fbSourceApplicationHasBeenSet", true);
return new SourceApplicationInfo(packageName, z);
}
}
public static void b() {
SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(FacebookSdk.b()).edit();
edit.remove("com.facebook.appevents.SourceApplicationInfo.callingApplicationPackage");
edit.remove("com.facebook.appevents.SourceApplicationInfo.openedByApplink");
edit.apply();
}
public static SourceApplicationInfo c() {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(FacebookSdk.b());
if (defaultSharedPreferences.contains("com.facebook.appevents.SourceApplicationInfo.callingApplicationPackage")) {
return new SourceApplicationInfo(defaultSharedPreferences.getString("com.facebook.appevents.SourceApplicationInfo.callingApplicationPackage", null), defaultSharedPreferences.getBoolean("com.facebook.appevents.SourceApplicationInfo.openedByApplink", false));
}
return null;
}
public void a() {
SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(FacebookSdk.b()).edit();
edit.putString("com.facebook.appevents.SourceApplicationInfo.callingApplicationPackage", this.a);
edit.putBoolean("com.facebook.appevents.SourceApplicationInfo.openedByApplink", this.b);
edit.apply();
}
public String toString() {
String str = this.b ? "Applink" : "Unclassified";
if (this.a == null) {
return str;
}
return str + "(" + this.a + ")";
}
private SourceApplicationInfo(String str, boolean z) {
this.a = str;
this.b = z;
}
}