368 lines
16 KiB
Java
368 lines
16 KiB
Java
package com.facebook;
|
|
|
|
import android.content.Context;
|
|
import android.content.pm.ApplicationInfo;
|
|
import android.content.pm.PackageManager;
|
|
import android.os.AsyncTask;
|
|
import android.support.v4.media.session.PlaybackStateCompat;
|
|
import com.facebook.appevents.AppEventsLogger;
|
|
import com.facebook.internal.BoltsMeasurementEventListener;
|
|
import com.facebook.internal.FetchedAppSettingsManager;
|
|
import com.facebook.internal.LockOnGetVariable;
|
|
import com.facebook.internal.NativeProtocol;
|
|
import com.facebook.internal.ServerProtocol;
|
|
import com.facebook.internal.Utility;
|
|
import com.facebook.internal.Validate;
|
|
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
|
import java.io.File;
|
|
import java.util.Arrays;
|
|
import java.util.HashSet;
|
|
import java.util.Locale;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.FutureTask;
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
import java.util.concurrent.ThreadFactory;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class FacebookSdk {
|
|
private static Executor b;
|
|
private static volatile String c;
|
|
private static volatile String d;
|
|
private static volatile String e;
|
|
private static volatile int f;
|
|
private static volatile Boolean g;
|
|
private static Context l;
|
|
private static Boolean q;
|
|
private static final HashSet<LoggingBehavior> a = new HashSet<>(Arrays.asList(LoggingBehavior.DEVELOPER_ERRORS));
|
|
private static volatile String h = "facebook.com";
|
|
private static AtomicLong i = new AtomicLong(PlaybackStateCompat.ACTION_PREPARE_FROM_SEARCH);
|
|
private static volatile boolean j = false;
|
|
private static boolean k = false;
|
|
private static int m = 64206;
|
|
private static final Object n = new Object();
|
|
private static final int o = R$style.com_facebook_activity_theme;
|
|
private static String p = ServerProtocol.a();
|
|
|
|
public interface InitializeCallback {
|
|
void a();
|
|
}
|
|
|
|
static {
|
|
new LinkedBlockingQueue(10);
|
|
new ThreadFactory() { // from class: com.facebook.FacebookSdk.1
|
|
private final AtomicInteger a = new AtomicInteger(0);
|
|
|
|
@Override // java.util.concurrent.ThreadFactory
|
|
public Thread newThread(Runnable runnable) {
|
|
return new Thread(runnable, "FacebookSdk #" + this.a.incrementAndGet());
|
|
}
|
|
};
|
|
q = false;
|
|
}
|
|
|
|
public static Context b() {
|
|
Validate.c();
|
|
return l;
|
|
}
|
|
|
|
@Deprecated
|
|
public static synchronized void c(Context context) {
|
|
synchronized (FacebookSdk.class) {
|
|
a(context, (InitializeCallback) null);
|
|
}
|
|
}
|
|
|
|
public static String d() {
|
|
Validate.c();
|
|
return d;
|
|
}
|
|
|
|
public static boolean e() {
|
|
Validate.c();
|
|
return g.booleanValue();
|
|
}
|
|
|
|
public static int f() {
|
|
Validate.c();
|
|
return m;
|
|
}
|
|
|
|
public static String g() {
|
|
Validate.c();
|
|
return e;
|
|
}
|
|
|
|
public static Executor h() {
|
|
synchronized (n) {
|
|
if (b == null) {
|
|
b = AsyncTask.THREAD_POOL_EXECUTOR;
|
|
}
|
|
}
|
|
return b;
|
|
}
|
|
|
|
public static String i() {
|
|
return h;
|
|
}
|
|
|
|
public static String j() {
|
|
return p;
|
|
}
|
|
|
|
public static long k() {
|
|
Validate.c();
|
|
return i.get();
|
|
}
|
|
|
|
public static String l() {
|
|
return "4.24.0";
|
|
}
|
|
|
|
public static int m() {
|
|
Validate.c();
|
|
return f;
|
|
}
|
|
|
|
public static boolean n() {
|
|
return j;
|
|
}
|
|
|
|
public static synchronized boolean o() {
|
|
boolean booleanValue;
|
|
synchronized (FacebookSdk.class) {
|
|
booleanValue = q.booleanValue();
|
|
}
|
|
return booleanValue;
|
|
}
|
|
|
|
public static boolean p() {
|
|
return k;
|
|
}
|
|
|
|
@Deprecated
|
|
public static synchronized void a(final Context context, final InitializeCallback initializeCallback) {
|
|
synchronized (FacebookSdk.class) {
|
|
if (q.booleanValue()) {
|
|
if (initializeCallback != null) {
|
|
initializeCallback.a();
|
|
}
|
|
return;
|
|
}
|
|
Validate.a(context, "applicationContext");
|
|
Validate.a(context, false);
|
|
Validate.b(context, false);
|
|
l = context.getApplicationContext();
|
|
b(l);
|
|
if (Utility.c(c)) {
|
|
throw new FacebookException("A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.");
|
|
}
|
|
q = true;
|
|
FetchedAppSettingsManager.b();
|
|
NativeProtocol.f();
|
|
BoltsMeasurementEventListener.a(l);
|
|
new LockOnGetVariable(new Callable<File>() { // from class: com.facebook.FacebookSdk.2
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // java.util.concurrent.Callable
|
|
public File call() throws Exception {
|
|
return FacebookSdk.l.getCacheDir();
|
|
}
|
|
});
|
|
h().execute(new FutureTask(new Callable<Void>() { // from class: com.facebook.FacebookSdk.3
|
|
@Override // java.util.concurrent.Callable
|
|
public Void call() throws Exception {
|
|
AccessTokenManager.d().c();
|
|
ProfileManager.c().b();
|
|
if (AccessToken.getCurrentAccessToken() != null && Profile.getCurrentProfile() == null) {
|
|
Profile.fetchProfileForCurrentAccessToken();
|
|
}
|
|
InitializeCallback initializeCallback2 = InitializeCallback.this;
|
|
if (initializeCallback2 != null) {
|
|
initializeCallback2.a();
|
|
}
|
|
AppEventsLogger.b(context.getApplicationContext()).a();
|
|
return null;
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
|
|
public static void b(Context context, final String str) {
|
|
final Context applicationContext = context.getApplicationContext();
|
|
h().execute(new Runnable() { // from class: com.facebook.FacebookSdk.4
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
FacebookSdk.a(applicationContext, str);
|
|
}
|
|
});
|
|
}
|
|
|
|
public static String c() {
|
|
Validate.c();
|
|
return c;
|
|
}
|
|
|
|
static void b(Context context) {
|
|
if (context == null) {
|
|
return;
|
|
}
|
|
try {
|
|
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PeripheralType.SERVO);
|
|
if (applicationInfo == null || applicationInfo.metaData == null) {
|
|
return;
|
|
}
|
|
if (c == null) {
|
|
Object obj = applicationInfo.metaData.get("com.facebook.sdk.ApplicationId");
|
|
if (obj instanceof String) {
|
|
String str = (String) obj;
|
|
if (str.toLowerCase(Locale.ROOT).startsWith("fb")) {
|
|
c = str.substring(2);
|
|
} else {
|
|
c = str;
|
|
}
|
|
} else if (obj instanceof Integer) {
|
|
throw new FacebookException("App Ids cannot be directly placed in the manifest.They must be prefixed by 'fb' or be placed in the string resource file.");
|
|
}
|
|
}
|
|
if (d == null) {
|
|
d = applicationInfo.metaData.getString("com.facebook.sdk.ApplicationName");
|
|
}
|
|
if (e == null) {
|
|
e = applicationInfo.metaData.getString("com.facebook.sdk.ClientToken");
|
|
}
|
|
if (f == 0) {
|
|
a(applicationInfo.metaData.getInt("com.facebook.sdk.WebDialogTheme"));
|
|
}
|
|
if (m == 64206) {
|
|
m = applicationInfo.metaData.getInt("com.facebook.sdk.CallbackOffset", 64206);
|
|
}
|
|
if (g == null) {
|
|
g = Boolean.valueOf(applicationInfo.metaData.getBoolean("com.facebook.sdk.AutoLogAppEventsEnabled", true));
|
|
}
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
}
|
|
}
|
|
|
|
public static boolean a(LoggingBehavior loggingBehavior) {
|
|
boolean z;
|
|
synchronized (a) {
|
|
z = n() && a.contains(loggingBehavior);
|
|
}
|
|
return z;
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:14:0x0068 A[Catch: Exception -> 0x00b9, TRY_ENTER, TryCatch #2 {Exception -> 0x00b9, blocks: (B:5:0x0005, B:7:0x003c, B:8:0x004a, B:20:0x005f, B:14:0x0068, B:17:0x007e, B:23:0x0084, B:25:0x0099, B:26:0x00a4, B:30:0x00a9, B:31:0x00b0, B:32:0x00b1, B:33:0x00b8), top: B:2:0x0001, inners: #1 }] */
|
|
/* JADX WARN: Removed duplicated region for block: B:17:0x007e A[Catch: Exception -> 0x00b9, TryCatch #2 {Exception -> 0x00b9, blocks: (B:5:0x0005, B:7:0x003c, B:8:0x004a, B:20:0x005f, B:14:0x0068, B:17:0x007e, B:23:0x0084, B:25:0x0099, B:26:0x00a4, B:30:0x00a9, B:31:0x00b0, B:32:0x00b1, B:33:0x00b8), top: B:2:0x0001, inners: #1 }] */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
static com.facebook.GraphResponse a(android.content.Context r14, java.lang.String r15) {
|
|
/*
|
|
r0 = 0
|
|
if (r14 == 0) goto Lb1
|
|
if (r15 == 0) goto Lb1
|
|
com.facebook.internal.AttributionIdentifiers r1 = com.facebook.internal.AttributionIdentifiers.d(r14) // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r2 = "com.facebook.sdk.attributionTracking"
|
|
r3 = 0
|
|
android.content.SharedPreferences r2 = r14.getSharedPreferences(r2, r3) // Catch: java.lang.Exception -> Lb9
|
|
java.lang.StringBuilder r4 = new java.lang.StringBuilder // Catch: java.lang.Exception -> Lb9
|
|
r4.<init>() // Catch: java.lang.Exception -> Lb9
|
|
r4.append(r15) // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r5 = "ping"
|
|
r4.append(r5) // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r4 = r4.toString() // Catch: java.lang.Exception -> Lb9
|
|
java.lang.StringBuilder r5 = new java.lang.StringBuilder // Catch: java.lang.Exception -> Lb9
|
|
r5.<init>() // Catch: java.lang.Exception -> Lb9
|
|
r5.append(r15) // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r6 = "json"
|
|
r5.append(r6) // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r5 = r5.toString() // Catch: java.lang.Exception -> Lb9
|
|
r6 = 0
|
|
long r8 = r2.getLong(r4, r6) // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r10 = r2.getString(r5, r0) // Catch: java.lang.Exception -> Lb9
|
|
com.facebook.internal.AppEventsLoggerUtility$GraphAPIActivityType r11 = com.facebook.internal.AppEventsLoggerUtility.GraphAPIActivityType.MOBILE_INSTALL_EVENT // Catch: org.json.JSONException -> La8 java.lang.Exception -> Lb9
|
|
java.lang.String r12 = com.facebook.appevents.AppEventsLogger.a(r14) // Catch: org.json.JSONException -> La8 java.lang.Exception -> Lb9
|
|
boolean r13 = a(r14) // Catch: org.json.JSONException -> La8 java.lang.Exception -> Lb9
|
|
org.json.JSONObject r14 = com.facebook.internal.AppEventsLoggerUtility.a(r11, r1, r12, r13, r14) // Catch: org.json.JSONException -> La8 java.lang.Exception -> Lb9
|
|
java.lang.String r1 = "%s/activities"
|
|
r11 = 1
|
|
java.lang.Object[] r12 = new java.lang.Object[r11] // Catch: java.lang.Exception -> Lb9
|
|
r12[r3] = r15 // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r15 = java.lang.String.format(r1, r12) // Catch: java.lang.Exception -> Lb9
|
|
com.facebook.GraphRequest r14 = com.facebook.GraphRequest.a(r0, r15, r14, r0) // Catch: java.lang.Exception -> Lb9
|
|
int r15 = (r8 > r6 ? 1 : (r8 == r6 ? 0 : -1))
|
|
if (r15 == 0) goto L84
|
|
if (r10 == 0) goto L65
|
|
org.json.JSONObject r15 = new org.json.JSONObject // Catch: org.json.JSONException -> L65 java.lang.Exception -> Lb9
|
|
r15.<init>(r10) // Catch: org.json.JSONException -> L65 java.lang.Exception -> Lb9
|
|
goto L66
|
|
L65:
|
|
r15 = r0
|
|
L66:
|
|
if (r15 != 0) goto L7e
|
|
java.lang.String r15 = "true"
|
|
com.facebook.GraphRequestBatch r1 = new com.facebook.GraphRequestBatch // Catch: java.lang.Exception -> Lb9
|
|
com.facebook.GraphRequest[] r2 = new com.facebook.GraphRequest[r11] // Catch: java.lang.Exception -> Lb9
|
|
r2[r3] = r14 // Catch: java.lang.Exception -> Lb9
|
|
r1.<init>(r2) // Catch: java.lang.Exception -> Lb9
|
|
java.util.List r14 = com.facebook.GraphResponse.a(r15, r0, r1) // Catch: java.lang.Exception -> Lb9
|
|
java.lang.Object r14 = r14.get(r3) // Catch: java.lang.Exception -> Lb9
|
|
com.facebook.GraphResponse r14 = (com.facebook.GraphResponse) r14 // Catch: java.lang.Exception -> Lb9
|
|
return r14
|
|
L7e:
|
|
com.facebook.GraphResponse r14 = new com.facebook.GraphResponse // Catch: java.lang.Exception -> Lb9
|
|
r14.<init>(r0, r0, r0, r15) // Catch: java.lang.Exception -> Lb9
|
|
return r14
|
|
L84:
|
|
com.facebook.GraphResponse r14 = r14.a() // Catch: java.lang.Exception -> Lb9
|
|
android.content.SharedPreferences$Editor r15 = r2.edit() // Catch: java.lang.Exception -> Lb9
|
|
long r1 = java.lang.System.currentTimeMillis() // Catch: java.lang.Exception -> Lb9
|
|
r15.putLong(r4, r1) // Catch: java.lang.Exception -> Lb9
|
|
org.json.JSONObject r1 = r14.b() // Catch: java.lang.Exception -> Lb9
|
|
if (r1 == 0) goto La4
|
|
org.json.JSONObject r1 = r14.b() // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r1 = r1.toString() // Catch: java.lang.Exception -> Lb9
|
|
r15.putString(r5, r1) // Catch: java.lang.Exception -> Lb9
|
|
La4:
|
|
r15.apply() // Catch: java.lang.Exception -> Lb9
|
|
return r14
|
|
La8:
|
|
r14 = move-exception
|
|
com.facebook.FacebookException r15 = new com.facebook.FacebookException // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r1 = "An error occurred while publishing install."
|
|
r15.<init>(r1, r14) // Catch: java.lang.Exception -> Lb9
|
|
throw r15 // Catch: java.lang.Exception -> Lb9
|
|
Lb1:
|
|
java.lang.IllegalArgumentException r14 = new java.lang.IllegalArgumentException // Catch: java.lang.Exception -> Lb9
|
|
java.lang.String r15 = "Both context and applicationId must be non-null"
|
|
r14.<init>(r15) // Catch: java.lang.Exception -> Lb9
|
|
throw r14 // Catch: java.lang.Exception -> Lb9
|
|
Lb9:
|
|
r14 = move-exception
|
|
java.lang.String r15 = "Facebook-publish"
|
|
com.facebook.internal.Utility.a(r15, r14)
|
|
com.facebook.GraphResponse r15 = new com.facebook.GraphResponse
|
|
com.facebook.FacebookRequestError r1 = new com.facebook.FacebookRequestError
|
|
r1.<init>(r0, r14)
|
|
r15.<init>(r0, r0, r1)
|
|
return r15
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.facebook.FacebookSdk.a(android.content.Context, java.lang.String):com.facebook.GraphResponse");
|
|
}
|
|
|
|
public static boolean a(Context context) {
|
|
Validate.c();
|
|
return context.getSharedPreferences("com.facebook.sdk.appEventPreferences", 0).getBoolean("limitEventUsage", false);
|
|
}
|
|
|
|
public static void a(int i2) {
|
|
if (i2 == 0) {
|
|
i2 = o;
|
|
}
|
|
f = i2;
|
|
}
|
|
}
|