124 lines
5.6 KiB
Java
124 lines
5.6 KiB
Java
package com.facebook.internal;
|
|
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
import com.facebook.AccessToken;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.GraphRequest;
|
|
import com.facebook.appevents.internal.AutomaticAnalyticsLogger;
|
|
import com.facebook.appevents.internal.Constants;
|
|
import com.facebook.internal.FetchedAppSettings;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class FetchedAppSettingsManager {
|
|
private static final String[] a = {"supports_implicit_sdk_logging", "gdpv4_nux_content", "gdpv4_nux_enabled", "gdpv4_chrome_custom_tabs_enabled", "android_dialog_configs", "android_sdk_error_categories", "app_events_session_timeout", "app_events_feature_bitmask", "seamless_login", "smart_login_bookmark_icon_url", "smart_login_menu_icon_url"};
|
|
private static Map<String, FetchedAppSettings> b = new ConcurrentHashMap();
|
|
private static AtomicBoolean c = new AtomicBoolean(false);
|
|
|
|
public static void b() {
|
|
final Context b2 = FacebookSdk.b();
|
|
final String c2 = FacebookSdk.c();
|
|
boolean compareAndSet = c.compareAndSet(false, true);
|
|
if (Utility.c(c2) || b.containsKey(c2) || !compareAndSet) {
|
|
return;
|
|
}
|
|
final String format = String.format("com.facebook.internal.APP_SETTINGS.%s", c2);
|
|
FacebookSdk.h().execute(new Runnable() { // from class: com.facebook.internal.FetchedAppSettingsManager.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
SharedPreferences sharedPreferences = b2.getSharedPreferences("com.facebook.internal.preferences.APP_SETTINGS", 0);
|
|
JSONObject jSONObject = null;
|
|
String string = sharedPreferences.getString(format, null);
|
|
if (!Utility.c(string)) {
|
|
try {
|
|
jSONObject = new JSONObject(string);
|
|
} catch (JSONException e) {
|
|
Utility.a("FacebookSDK", (Exception) e);
|
|
}
|
|
if (jSONObject != null) {
|
|
FetchedAppSettingsManager.b(c2, jSONObject);
|
|
}
|
|
}
|
|
JSONObject b3 = FetchedAppSettingsManager.b(c2);
|
|
if (b3 != null) {
|
|
FetchedAppSettingsManager.b(c2, b3);
|
|
sharedPreferences.edit().putString(format, b3.toString()).apply();
|
|
}
|
|
AutomaticAnalyticsLogger.a();
|
|
FetchedAppSettingsManager.c.set(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
public static FetchedAppSettings c(String str) {
|
|
if (str != null) {
|
|
return b.get(str);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static FetchedAppSettings a(String str, boolean z) {
|
|
if (!z && b.containsKey(str)) {
|
|
return b.get(str);
|
|
}
|
|
JSONObject b2 = b(str);
|
|
if (b2 == null) {
|
|
return null;
|
|
}
|
|
return b(str, b2);
|
|
}
|
|
|
|
private static Map<String, Map<String, FetchedAppSettings.DialogFeatureConfig>> a(JSONObject jSONObject) {
|
|
JSONArray optJSONArray;
|
|
HashMap hashMap = new HashMap();
|
|
if (jSONObject != null && (optJSONArray = jSONObject.optJSONArray("data")) != null) {
|
|
for (int i = 0; i < optJSONArray.length(); i++) {
|
|
FetchedAppSettings.DialogFeatureConfig a2 = FetchedAppSettings.DialogFeatureConfig.a(optJSONArray.optJSONObject(i));
|
|
if (a2 != null) {
|
|
String a3 = a2.a();
|
|
Map map = (Map) hashMap.get(a3);
|
|
if (map == null) {
|
|
map = new HashMap();
|
|
hashMap.put(a3, map);
|
|
}
|
|
map.put(a2.b(), a2);
|
|
}
|
|
}
|
|
}
|
|
return hashMap;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static FetchedAppSettings b(String str, JSONObject jSONObject) {
|
|
FacebookRequestErrorClassification a2;
|
|
JSONArray optJSONArray = jSONObject.optJSONArray("android_sdk_error_categories");
|
|
if (optJSONArray == null) {
|
|
a2 = FacebookRequestErrorClassification.a();
|
|
} else {
|
|
a2 = FacebookRequestErrorClassification.a(optJSONArray);
|
|
}
|
|
FetchedAppSettings fetchedAppSettings = new FetchedAppSettings(jSONObject.optBoolean("supports_implicit_sdk_logging", false), jSONObject.optString("gdpv4_nux_content", ""), jSONObject.optBoolean("gdpv4_nux_enabled", false), jSONObject.optBoolean("gdpv4_chrome_custom_tabs_enabled", false), jSONObject.optInt("app_events_session_timeout", Constants.a()), SmartLoginOption.parseOptions(jSONObject.optLong("seamless_login")), a(jSONObject.optJSONObject("android_dialog_configs")), (jSONObject.optInt("app_events_feature_bitmask", 0) & 8) != 0, a2, jSONObject.optString("smart_login_bookmark_icon_url"), jSONObject.optString("smart_login_menu_icon_url"));
|
|
b.put(str, fetchedAppSettings);
|
|
return fetchedAppSettings;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static JSONObject b(String str) {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("fields", TextUtils.join(",", a));
|
|
GraphRequest a2 = GraphRequest.a((AccessToken) null, str, (GraphRequest.Callback) null);
|
|
a2.a(true);
|
|
a2.a(bundle);
|
|
return a2.a().b();
|
|
}
|
|
}
|