正在查看: CallApp v2.226 应用的 FacebookHelper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: CallApp v2.226 应用的 FacebookHelper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.callapp.contacts.api.helper.facebook;
import a1.d0;
import ae.a;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Pair;
import com.amazon.device.ads.l;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.LazyHeaders;
import com.bytedance.sdk.component.pglcrypt.PglCryptUtils;
import com.callapp.common.model.json.JSONAddress;
import com.callapp.common.model.json.JSONCategory;
import com.callapp.common.model.json.JSONFBCategorizedType;
import com.callapp.common.model.json.JSONFBEntity;
import com.callapp.common.model.json.JSONFBLocation;
import com.callapp.common.model.json.JSONFBType;
import com.callapp.common.model.json.JSONFBUserOrPage;
import com.callapp.common.model.json.JSONSocialNetworkID;
import com.callapp.common.model.json.JSONWebsite;
import com.callapp.common.util.Lists;
import com.callapp.common.util.RegexUtils;
import com.callapp.common.util.UrlUtils;
import com.callapp.contacts.CallAppApplication;
import com.callapp.contacts.R;
import com.callapp.contacts.activity.setup.navigation.OnBoardingNavigationActivity;
import com.callapp.contacts.api.helper.common.RemoteAccountHelper;
import com.callapp.contacts.api.helper.placessearch.PlacesSearchLoadingEvents;
import com.callapp.contacts.loader.social.QuotaReachedException;
import com.callapp.contacts.loader.social.UserNotFoundException;
import com.callapp.contacts.manager.CallAppRemoteConfigManager;
import com.callapp.contacts.manager.FeedbackManager;
import com.callapp.contacts.manager.UserProfileManager;
import com.callapp.contacts.manager.analytics.AnalyticsManager;
import com.callapp.contacts.manager.cache.CacheManager;
import com.callapp.contacts.manager.preferences.Prefs;
import com.callapp.contacts.manager.task.OutcomeListener;
import com.callapp.contacts.manager.task.Task;
import com.callapp.contacts.model.Constants;
import com.callapp.contacts.model.Friend;
import com.callapp.contacts.model.PersonData;
import com.callapp.contacts.model.UploadedPhoto;
import com.callapp.contacts.model.UsageCounter;
import com.callapp.contacts.model.UsageCounterDataManager;
import com.callapp.contacts.model.contact.ContactData;
import com.callapp.contacts.model.contact.DataSource;
import com.callapp.contacts.model.contact.ExtendedPlaceData;
import com.callapp.contacts.model.contact.FacebookPlaceData;
import com.callapp.contacts.model.contact.social.FacebookDataUtils;
import com.callapp.contacts.util.Activities;
import com.callapp.contacts.util.CLog;
import com.callapp.contacts.util.UpdateUserProfileUtil;
import com.callapp.contacts.util.http.HttpRequest;
import com.callapp.contacts.util.http.HttpRequestParams;
import com.callapp.contacts.util.http.HttpUtils;
import com.callapp.contacts.util.serializer.string.ClassParserHttpResponseHandler;
import com.callapp.contacts.util.serializer.string.Parser;
import com.callapp.contacts.util.serializer.string.Serializer;
import com.callapp.framework.phone.Phone;
import com.callapp.framework.util.CollectionUtils;
import com.callapp.framework.util.StringUtils;
import com.facebook.AccessToken;
import com.facebook.AuthenticationToken;
import com.facebook.FacebookException;
import com.facebook.GraphRequest;
import com.facebook.Profile;
import com.facebook.a0;
import com.facebook.f0;
import com.facebook.h;
import com.facebook.internal.c;
import com.facebook.login.v;
import com.facebook.m;
import com.facebook.o;
import com.facebook.s;
import com.facebook.t;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import kotlin.jvm.internal.Intrinsics;
import org.json.JSONArray;
import org.json.JSONObject;
public class FacebookHelper extends RemoteAccountHelper implements o {
public static FacebookHelper d;
public static final ArrayList e = Lists.a(4, 9, 17, 18, 341, 613);
public static final ArrayList f = Lists.a(21, 100);
public static final ArrayList g = Lists.a("public_profile", "user_posts", "user_friends", "user_link", "user_birthday", "user_likes", "user_photos", "user_videos", "email");
public final c c;
class AnonymousClass5 extends RemoteAccountHelper.SocialCallable<ProfileImageUrl> {
public final String a;
public AnonymousClass5(String str) {
this.a = str;
}
@Override
public final java.lang.Object a() {
throw new UnsupportedOperationException("Method not decompiled: com.callapp.contacts.api.helper.facebook.FacebookHelper.AnonymousClass5.a():java.lang.Object");
}
@Override
public String getCacheKey() {
return "fb_big_image_url_" + this.a;
}
@Override
public int getCacheTtl() {
return R.integer.facebook_user_cache_ttl_minutes;
}
}
public static class ProfileImageUrl {
public String a;
public String b;
public ProfileImageUrl(int i) {
this();
}
private ProfileImageUrl() {
}
}
private FacebookHelper() {
if (!CallAppApplication.get().isUnitTestMode()) {
String[] strArr = new String[0];
s sVar = s.a;
if (!a.b(s.class)) {
try {
s.m(strArr);
} catch (Throwable th) {
a.a(s.class, th);
}
}
if (Prefs.q.get().booleanValue()) {
s.j = true;
}
}
int i = m.a;
this.c = new c();
}
public static JsonNode I(FacebookHelper facebookHelper, List list) {
facebookHelper.getClass();
if (!CallAppRemoteConfigManager.get().b("facebookPagesSearchEnabled")) {
return null;
}
StringBuilder sb2 = new StringBuilder();
sb2.append(HttpUtils.getCallappServerPrefix() + "fps?v=1&myp=" + UrlUtils.a(Prefs.a1.get()));
sb2.append("&tk=");
sb2.append(Prefs.e1.get());
sb2.append("&cvc=");
sb2.append(CallAppApplication.get().getVersionCode());
String sb3 = sb2.toString();
JSONArray jSONArray = new JSONArray();
Iterator it = list.iterator();
while (it.hasNext()) {
jSONArray.put((String) it.next());
}
ClassParserHttpResponseHandler classParserHttpResponseHandler = new ClassParserHttpResponseHandler(JsonNode.class);
HttpRequestParams.HttpRequestParamsBuilder httpRequestParamsBuilder = new HttpRequestParams.HttpRequestParamsBuilder(sb3);
httpRequestParamsBuilder.d = classParserHttpResponseHandler;
HttpUtils.m(httpRequestParamsBuilder.a(), jSONArray.toString());
return (JsonNode) classParserHttpResponseHandler.getResult();
}
public static List J(FacebookHelper facebookHelper, JSONObject jSONObject) {
facebookHelper.getClass();
String optString = jSONObject.optString("data");
Object obj = null;
if (!StringUtils.x(optString)) {
return null;
}
CollectionType constructCollectionType = Serializer.getJSONObjectMapper().getTypeFactory().constructCollectionType(ArrayList.class, JSONFBUserOrPage.class);
if (optString != null) {
try {
obj = Serializer.getJSONObjectMapper().readValue(optString, constructCollectionType);
} catch (IOException | LinkageError e2) {
CLog.b(Parser.class, e2);
}
}
return (List) obj;
}
public static JSONFBUserOrPage K(FacebookHelper facebookHelper, String str) {
facebookHelper.getClass();
if (StringUtils.x(str)) {
return (JSONFBUserOrPage) Parser.c(str, JSONFBUserOrPage.class);
}
return null;
}
public static Date L(String str, Date date) {
try {
Date h = StringUtils.h(str);
if (h == null) {
return null;
}
if (date != null) {
if (!date.before(h)) {
return null;
}
}
return h;
} catch (ParseException unused) {
return null;
}
}
public static void U() {
CacheManager.get().f(List.class, "fb_myFriends_sorted");
CacheManager.get().f(JSONFBUserOrPage.class, "fb_user_me_true");
UserProfileManager.get().c(1);
}
public static boolean V(Context context, String str, Runnable runnable) {
if (!HttpUtils.a()) {
FeedbackManager.j(context);
return false;
}
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("fb://page/" + str));
if (Activities.l(intent)) {
intent.addFlags(Activities.getIntentFlagForNewDocument());
Activities.J(context, intent);
return true;
}
Activities.v(context, "https://facebook.com/" + str, runnable);
return true;
}
public static FacebookHelper get() {
synchronized (FacebookHelper.class) {
try {
if (d == null) {
d = new FacebookHelper();
}
} catch (Throwable th) {
throw th;
}
}
return d;
}
private String getAuthorizationHeaderValue() {
StringBuilder sb2 = new StringBuilder("Bearer ");
sb2.append(isLoggedIn() ? AccessToken.getCurrentAccessToken().getToken() : CallAppRemoteConfigManager.get().d("facebookAccessToken"));
return sb2.toString();
}
@Override
public final void C(ContactData contactData, JSONSocialNetworkID jSONSocialNetworkID) {
contactData.getDeviceData().setFacebookId(jSONSocialNetworkID);
contactData.updateFacebookId();
}
public final String M(String str) {
JsonNode jsonNode;
JsonNode jsonNode2;
JsonNode jsonNode3;
String m = com.mobilefuse.sdk.assetsmanager.a.m("https://graph.facebook.com/", str, "/picture?width=600");
try {
if (!HttpUtils.b()) {
return null;
}
ClassParserHttpResponseHandler classParserHttpResponseHandler = new ClassParserHttpResponseHandler(JsonNode.class);
HashMap hashMap = new HashMap();
hashMap.put("Authorization", getAuthorizationHeaderValue());
HttpRequestParams.HttpRequestParamsBuilder httpRequestParamsBuilder = new HttpRequestParams.HttpRequestParamsBuilder(m + "&redirect=false");
httpRequestParamsBuilder.d = classParserHttpResponseHandler;
httpRequestParamsBuilder.b = hashMap;
HttpUtils.g(httpRequestParamsBuilder.a());
JsonNode jsonNode4 = (JsonNode) classParserHttpResponseHandler.getResult();
if (jsonNode4 == null || (jsonNode = jsonNode4.get("data")) == null || (jsonNode2 = jsonNode.get("is_silhouette")) == null || jsonNode2.asBoolean() || (jsonNode3 = jsonNode.get("url")) == null) {
return null;
}
if (StringUtils.x(jsonNode3.asText())) {
return m;
}
return null;
} catch (IllegalStateException e2) {
CLog.b(FacebookHelper.class, e2);
return null;
}
}
public final ArrayList N(final String str) {
return (ArrayList) H(new RemoteAccountHelper.SocialCallable<ArrayList>(this) {
@Override
public final Object a() {
JSONObject optJSONObject;
JSONObject jSONObject = new GraphRequest(AccessToken.getCurrentAccessToken(), d0.s(new StringBuilder(), str, "/photos"), l.f("fields", "images,created_time"), a0.GET, (t) null, (String) null).c().c;
ArrayList arrayList = null;
if (jSONObject != null) {
try {
JSONArray optJSONArray = jSONObject.optJSONArray("data");
if (optJSONArray != null) {
ArrayList arrayList2 = new ArrayList();
for (int i = 0; i < optJSONArray.length(); i++) {
try {
UploadedPhoto uploadedPhoto = new UploadedPhoto();
JSONObject jSONObject2 = (JSONObject) optJSONArray.opt(i);
if (jSONObject2 != null) {
String optString = jSONObject2.optString("created_time");
if (StringUtils.x(optString)) {
uploadedPhoto.setCreatedTime(StringUtils.h(optString));
JSONArray optJSONArray2 = jSONObject2.optJSONArray("images");
if (optJSONArray2 != null && (optJSONObject = optJSONArray2.optJSONObject(0)) != null) {
String optString2 = optJSONObject.optString("source");
if (StringUtils.x(optString2)) {
uploadedPhoto.setUrl(optString2.trim().replaceAll(" ", "%20"));
arrayList2.add(uploadedPhoto);
}
}
}
}
} catch (ParseException e2) {
e = e2;
arrayList = arrayList2;
CLog.b(FacebookHelper.class, e);
return arrayList;
}
}
return arrayList2;
}
} catch (ParseException e3) {
e = e3;
}
}
return arrayList;
}
@Override
public String getCacheKey() {
return "fb_profile_uploaded_pictures_urls_" + str;
}
@Override
public int getCacheTtl() {
return R.integer.facebook_user_cache_ttl_minutes;
}
}, ArrayList.class, true, false, true);
}
public final String O(final String str) {
String str2 = (String) H(new RemoteAccountHelper.SocialCallable<String>() {
@Override
public final Object a() {
Date date;
String str3;
boolean z;
boolean z2;
boolean z3;
JSONObject optJSONObject;
JSONArray optJSONArray;
Date date2;
boolean z4;
JSONArray optJSONArray2;
Date date3;
UsageCounter usageCounter = UsageCounter.facebookRequests;
int integer = CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_in_minutes);
int integer2 = CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_request_limit);
FacebookHelper facebookHelper = FacebookHelper.d;
FacebookHelper.this.s(usageCounter, integer, integer2, true);
Bundle bundle = new Bundle();
bundle.putString("fields", "message,attachments{unshimmed_url},updated_time");
bundle.putInt("limit", 10);
AccessToken currentAccessToken = AccessToken.getCurrentAccessToken();
StringBuilder sb2 = new StringBuilder();
String str4 = str;
JSONObject jSONObject = new GraphRequest(currentAccessToken, d0.s(sb2, str4, "/feed"), bundle, a0.GET, (t) null, (String) null).c().c;
Date date4 = null;
if (jSONObject != null) {
JSONArray optJSONArray3 = jSONObject.optJSONArray("data");
if (optJSONArray3 != null) {
int i = 0;
while (true) {
if (i >= optJSONArray3.length()) {
break;
}
JSONObject optJSONObject2 = optJSONArray3.optJSONObject(i);
if (optJSONObject2 != null) {
str3 = optJSONObject2.optString(PglCryptUtils.KEY_MESSAGE);
if (StringUtils.x(str3)) {
String optString = optJSONObject2.optString("updated_time");
if (StringUtils.x(optString)) {
date = FacebookHelper.L(optString, null);
if (date != null) {
z = true;
}
}
} else {
continue;
}
}
i++;
}
}
z = true;
date = null;
str3 = null;
} else {
date = null;
str3 = null;
z = false;
}
if (z) {
z2 = true;
} else {
Bundle bundle2 = new Bundle();
bundle2.putString("fields", "id,description,updated_time,created_time");
bundle2.putInt("limit", 10);
z2 = true;
JSONObject jSONObject2 = new GraphRequest(AccessToken.getCurrentAccessToken(), d0.o(str4, "/videos/uploaded"), bundle2, a0.GET, (t) null, (String) null).c().c;
if (jSONObject2 != null) {
JSONArray optJSONArray4 = jSONObject2.optJSONArray("data");
if (optJSONArray4 != null) {
int i2 = 0;
while (i2 < optJSONArray4.length()) {
JSONObject optJSONObject3 = optJSONArray4.optJSONObject(i2);
if (optJSONObject3 != null) {
?? optString2 = optJSONObject3.optString("description");
if (StringUtils.x(optString2)) {
String optString3 = optJSONObject3.optString("created_time");
if (StringUtils.x(optString3)) {
date2 = null;
Date L = FacebookHelper.L(optString3, null);
if (L != null) {
date2 = optString2;
date4 = L;
z4 = true;
}
date4 = date2;
z4 = true;
}
}
date3 = null;
} else {
date3 = date4;
}
i2++;
date4 = date3;
}
}
date2 = date4;
date4 = date2;
z4 = true;
} else {
date2 = null;
z4 = false;
}
if (!z4) {
bundle2.clear();
bundle2.putString("fields", "name,created_time");
bundle2.putInt("limit", 10);
JSONObject jSONObject3 = new GraphRequest(AccessToken.getCurrentAccessToken(), d0.o(str4, "/photos/uploaded"), bundle2, a0.GET, (t) null, (String) null).c().c;
if (jSONObject3 != null && (optJSONArray2 = jSONObject3.optJSONArray("data")) != null) {
int i3 = 0;
while (true) {
if (i3 >= optJSONArray2.length()) {
break;
}
JSONObject optJSONObject4 = optJSONArray2.optJSONObject(i3);
if (optJSONObject4 != null) {
?? optString4 = optJSONObject4.optString("name");
if (StringUtils.x(optString4)) {
String optString5 = optJSONObject4.optString("created_time");
if (StringUtils.x(optString5)) {
Date L2 = FacebookHelper.L(optString5, date4);
if (L2 != null) {
date4 = L2;
date2 = optString4;
}
}
} else {
continue;
}
}
i3++;
}
}
}
Pair create = Pair.create(date2, date4);
if (create != null) {
str3 = (String) create.first;
date = (Date) create.second;
if (date != null && StringUtils.x(str3)) {
z = true;
}
}
}
if (z || jSONObject == null || !jSONObject.has("data")) {
z3 = z;
} else {
JSONArray optJSONArray5 = jSONObject.optJSONArray("data");
if (optJSONArray5 != null) {
boolean z5 = false;
for (int i4 = 0; i4 < optJSONArray5.length() && !z5; i4++) {
JSONObject optJSONObject5 = optJSONArray5.optJSONObject(i4);
if (optJSONObject5 != null && optJSONObject5.has("attachments") && (optJSONObject = optJSONObject5.optJSONObject("attachments")) != null && optJSONObject.has("data") && (optJSONArray = optJSONObject.optJSONArray("data")) != null) {
int i5 = 0;
while (true) {
if (i5 >= optJSONArray.length()) {
break;
}
JSONObject optJSONObject6 = optJSONArray.optJSONObject(i5);
if (optJSONObject6 != null && optJSONObject6.has("unshimmed_url")) {
String optString6 = optJSONObject6.optString("unshimmed_url");
if (StringUtils.x(optString6) && optJSONObject5.has("updated_time")) {
String optString7 = optJSONObject5.optString("updated_time");
if (StringUtils.x(optString7)) {
if (FacebookHelper.L(optString7, date) != null) {
str3 = optString6;
}
z5 = z2;
}
}
}
i5++;
}
}
}
}
z3 = z2;
}
return (StringUtils.t(str3) && z3) ? "" : str3;
}
@Override
public String getCacheKey() {
return "fb_user_self_wall_post_" + str;
}
@Override
public int getCacheTtl() {
return R.integer.facebook_status_cache_ttl_minutes;
}
}, String.class, true, false, true);
if (StringUtils.t(str2)) {
return null;
}
return str2;
}
public final String P(String str) {
ProfileImageUrl profileImageUrl = (ProfileImageUrl) H(new AnonymousClass5(str), ProfileImageUrl.class, false, false, true);
if (profileImageUrl != null) {
return profileImageUrl.a;
}
return null;
}
public final ArrayList Q(final String str) {
return (ArrayList) H(new RemoteAccountHelper.SocialCallable<ArrayList>() {
@Override
public final Object a() {
JSONArray optJSONArray;
JSONArray optJSONArray2;
JSONArray optJSONArray3;
JSONObject optJSONObject;
ArrayList arrayList = new ArrayList();
Bundle f2 = l.f("fields", "id,name,created_time");
AccessToken currentAccessToken = AccessToken.getCurrentAccessToken();
StringBuilder sb2 = new StringBuilder();
String str2 = str;
JSONObject jSONObject = new GraphRequest(currentAccessToken, d0.s(sb2, str2, "/albums"), f2, a0.GET, (t) null, (String) null).c().c;
if (jSONObject != null && (optJSONArray = jSONObject.optJSONArray("data")) != null) {
int i = 0;
while (true) {
if (i >= optJSONArray.length()) {
break;
}
JSONObject optJSONObject2 = optJSONArray.optJSONObject(i);
if (optJSONObject2 == null || !StringUtils.k(optJSONObject2.optString("name"), "Profile Pictures")) {
i++;
} else {
String optString = optJSONObject2.optString("id");
if (StringUtils.x(optString)) {
f2.clear();
f2.putString("fields", "images");
JSONObject jSONObject2 = new GraphRequest(AccessToken.getCurrentAccessToken(), d0.o(optString, "/photos"), f2, a0.GET, (t) null, (String) null).c().c;
if (jSONObject2 != null && (optJSONArray2 = jSONObject2.optJSONArray("data")) != null) {
for (int i2 = 0; i2 < optJSONArray2.length(); i2++) {
JSONObject optJSONObject3 = optJSONArray2.optJSONObject(i2);
if (optJSONObject3 != null && (optJSONArray3 = optJSONObject3.optJSONArray("images")) != null && (optJSONObject = optJSONArray3.optJSONObject(0)) != null) {
arrayList.add(optJSONObject.optString("source").trim().replaceAll(" ", "%20"));
}
}
}
}
}
}
}
if (!CollectionUtils.f(arrayList)) {
return arrayList;
}
String P = FacebookHelper.this.P(str2);
if (!StringUtils.x(P)) {
return null;
}
arrayList.add(P);
return arrayList;
}
@Override
public String getCacheKey() {
return "fb_profile_pics_urls_" + str;
}
@Override
public int getCacheTtl() {
return R.integer.facebook_user_cache_ttl_minutes;
}
}, ArrayList.class, true, false, true);
}
public final List R(final String str) {
if (StringUtils.t(str)) {
return null;
}
return (List) H(new RemoteAccountHelper.SocialCallable<List>() {
@Override
public final Object a() {
UsageCounter usageCounter = UsageCounter.facebookRequests;
int integer = CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_in_minutes);
int integer2 = CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_request_limit);
FacebookHelper facebookHelper = FacebookHelper.d;
FacebookHelper.this.s(usageCounter, integer, integer2, true);
List list = Collections.EMPTY_LIST;
Bundle bundle = new Bundle();
bundle.putString("fields", "category,name,id,created_time");
bundle.putInt("limit", 10);
JSONObject jSONObject = new GraphRequest(AccessToken.getCurrentAccessToken(), d0.s(new StringBuilder(), str, "/likes"), bundle, a0.GET, (t) null, (String) null).c().c;
if (jSONObject != null) {
ArrayList arrayList = new ArrayList();
JSONArray optJSONArray = jSONObject.optJSONArray("data");
if (optJSONArray != null) {
for (int i = 0; i < optJSONArray.length(); i++) {
JSONObject optJSONObject = optJSONArray.optJSONObject(i);
if (optJSONObject != null) {
JSONFBCategorizedType jSONFBCategorizedType = new JSONFBCategorizedType();
String optString = optJSONObject.optString("category");
if (StringUtils.x(optString)) {
jSONFBCategorizedType.setCategory(optString);
}
String optString2 = optJSONObject.optString("id");
if (StringUtils.x(optString2)) {
jSONFBCategorizedType.setId(optString2);
}
String optString3 = optJSONObject.optString("name");
if (StringUtils.x(optString3)) {
jSONFBCategorizedType.setName(optString3);
}
arrayList.add(jSONFBCategorizedType);
}
}
}
if (CollectionUtils.h(arrayList)) {
return arrayList;
}
}
return list;
}
@Override
public String getCacheKey() {
return "fb_userlikes_" + str;
}
@Override
public int getCacheTtl() {
return R.integer.facebook_likes_cache_ttl_minutes;
}
}, List.class, true, false, true);
}
public final JSONFBUserOrPage S(final String str, boolean z) {
return (JSONFBUserOrPage) H(new RemoteAccountHelper.SocialCallable<JSONFBUserOrPage>() {
@Override
public final Object a() {
String str2;
FacebookHelper facebookHelper = FacebookHelper.this;
if (!facebookHelper.isLoggedIn()) {
return null;
}
UsageCounter usageCounter = UsageCounter.facebookRequests;
facebookHelper.s(usageCounter, CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_in_minutes), CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_request_limit), true);
Bundle bundle = new Bundle();
String str3 = str;
if (!StringUtils.y(str3, true)) {
bundle.putString("fields", "id,birthday,email,first_name,last_name,link,location,locale,name,timezone,updated_time,verified");
JSONFBUserOrPage K = FacebookHelper.K(facebookHelper, new GraphRequest(AccessToken.getCurrentAccessToken(), str, bundle, a0.GET, (t) null, (String) null).c().b);
if (K != null) {
K.setFqlType("user");
}
return K;
}
bundle.putString("fields", "metadata{type}");
bundle.putInt("metadata", 1);
AccessToken currentAccessToken = AccessToken.getCurrentAccessToken();
a0 a0Var = a0.GET;
JSONObject jSONObject = new GraphRequest(currentAccessToken, str, bundle, a0Var, (t) null, (String) null).c().c;
if (jSONObject == null) {
JsonNode I = FacebookHelper.I(facebookHelper, Collections.singletonList(str3));
if (I == null || I.size() <= 0) {
return null;
}
JSONFBUserOrPage jSONFBUserOrPage = (JSONFBUserOrPage) Parser.a(I.get(0));
if (jSONFBUserOrPage != null) {
jSONFBUserOrPage.setFqlType("page");
}
return jSONFBUserOrPage;
}
JSONObject optJSONObject = jSONObject.optJSONObject("metadata");
String optString = optJSONObject != null ? optJSONObject.optString("type") : null;
if (!StringUtils.x(optString)) {
return null;
}
facebookHelper.s(usageCounter, CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_in_minutes), CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_request_limit), true);
bundle.clear();
if (StringUtils.m(optString, "placeinformation")) {
str2 = "fields";
bundle.putString(str2, "page");
String str4 = new GraphRequest(AccessToken.getCurrentAccessToken(), str, bundle, a0Var, (t) null, (String) null).c().b;
bundle.clear();
JSONFBUserOrPage K2 = FacebookHelper.K(facebookHelper, str4);
if (K2 != null && K2.getPage() != null && StringUtils.x(K2.getPage().getId())) {
str3 = K2.getPage().getId();
optString = "facebookPlaceData";
}
} else {
str2 = "fields";
}
String str5 = str3;
bundle.putString(str2, "id,birthday,email,first_name,last_name,link,location,locale,name,timezone,updated_time,verified");
JSONFBUserOrPage K3 = FacebookHelper.K(facebookHelper, new GraphRequest(AccessToken.getCurrentAccessToken(), str5, bundle, a0Var, (t) null, (String) null).c().b);
if (K3 != null) {
K3.setFqlType(optString);
}
return K3;
}
@Override
public String getCacheKey() {
return "fb_user_" + str + "_" + FacebookHelper.this.isLoggedIn();
}
@Override
public int getCacheTtl() {
return R.integer.facebook_user_cache_ttl_minutes;
}
}, JSONFBUserOrPage.class, false, z, true);
}
public final boolean T(Context context, String str, Runnable runnable) {
String str2;
String str3;
boolean z = false;
if (!StringUtils.x(str)) {
return false;
}
if (isNativeAppInstalled()) {
String[] split = str.split("/");
if (split.length > 0) {
str2 = split[split.length - 1];
z = StringUtils.y(str2, true);
} else {
str2 = "";
}
if (z) {
str3 = "fb://profile/" + str2;
} else {
str3 = "fb://facewebmodal/f?href=" + UrlUtils.a(str);
}
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str3));
if (Activities.l(intent)) {
intent.addFlags(Activities.getIntentFlagForNewDocument());
Activities.J(context, intent);
} else {
Activities.v(context, str, runnable);
}
} else {
Activities.v(context, str, runnable);
}
return true;
}
public final void W(final Context context, final String str, final Runnable runnable, final OutcomeListener outcomeListener) {
if (HttpUtils.a()) {
new Task() {
@Override
public final void doTask() {
throw new UnsupportedOperationException("Method not decompiled: com.callapp.contacts.api.helper.facebook.FacebookHelper.AnonymousClass3.doTask():void");
}
}.execute();
} else {
FeedbackManager.j(context);
RemoteAccountHelper.B(outcomeListener, false);
}
}
public final void X(final Context context, final String str, final Runnable runnable, final OutcomeListener outcomeListener, String str2) {
if (!StringUtils.x(str2)) {
W(context, str, runnable, outcomeListener);
return;
}
if (StringUtils.m(str2, "user")) {
W(context, str, runnable, outcomeListener);
return;
}
if (StringUtils.m(str2, "page")) {
boolean V = V(context, str, runnable);
if (outcomeListener != null) {
outcomeListener.d(V);
return;
}
return;
}
if (StringUtils.m(str2, "placeinformation") || StringUtils.m(str2, "facebookPlaceData")) {
new Task() {
@Override
public final void doTask() {
JSONFBUserOrPage S = FacebookHelper.this.S(str, false);
OutcomeListener outcomeListener2 = outcomeListener;
if (S == null) {
if (outcomeListener2 != null) {
outcomeListener2.d(false);
}
} else {
boolean V2 = FacebookHelper.V(context, S.getId(), runnable);
if (outcomeListener2 != null) {
outcomeListener2.d(V2);
}
}
}
}.execute();
}
}
public final void Y(final String str, PlacesSearchLoadingEvents placesSearchLoadingEvents) {
ArrayList arrayList = null;
if (StringUtils.t(str)) {
placesSearchLoadingEvents.a(null);
return;
}
ArrayList arrayList2 = (ArrayList) H(new RemoteAccountHelper.SocialCallable<ArrayList>() {
@Override
public final Object a() {
Bundle f2 = l.f("fields", "id");
f2.putString("q", str);
f2.putInt("limit", (int) CallAppRemoteConfigManager.get().c("facebookPagesSearchMaxPerQuery"));
JSONObject jSONObject = new GraphRequest(AccessToken.getCurrentAccessToken(), "/pages/search", f2, a0.GET, (t) null, (String) null).c().c;
if (jSONObject == null) {
return null;
}
FacebookHelper facebookHelper = FacebookHelper.this;
List J = FacebookHelper.J(facebookHelper, jSONObject);
if (!CollectionUtils.h(J)) {
return null;
}
ArrayList arrayList3 = new ArrayList();
Iterator it = J.iterator();
while (it.hasNext()) {
arrayList3.add(((JSONFBUserOrPage) it.next()).getId());
}
JsonNode I = FacebookHelper.I(facebookHelper, arrayList3);
if (I == null) {
return null;
}
ArrayList arrayList4 = new ArrayList();
for (int i = 0; i < I.size(); i++) {
JSONFBUserOrPage jSONFBUserOrPage = (JSONFBUserOrPage) Parser.a(I.get(i));
if (jSONFBUserOrPage != null) {
FacebookPlaceData facebookPlaceData = new FacebookPlaceData();
facebookPlaceData.setKey(new Phone(jSONFBUserOrPage.getPhone()).c());
facebookPlaceData.setFacebookId(new JSONSocialNetworkID(jSONFBUserOrPage.getId(), true));
facebookPlaceData.setPhotoUrl(facebookHelper.P(jSONFBUserOrPage.getId()));
facebookPlaceData.setFullName(jSONFBUserOrPage.getName());
facebookPlaceData.setLink(jSONFBUserOrPage.getLink());
JSONFBLocation locationObject = jSONFBUserOrPage.getLocationObject();
if (locationObject != null) {
JSONAddress jSONAddress = new JSONAddress();
jSONAddress.setStreet(locationObject.getStreet());
jSONAddress.setCity(locationObject.getCity());
jSONAddress.setState(locationObject.getState());
jSONAddress.setCountry(locationObject.getCountry());
jSONAddress.setPostalCode(locationObject.getZip());
facebookPlaceData.setAddress(jSONAddress);
}
facebookPlaceData.setDescription(jSONFBUserOrPage.getDescription());
facebookPlaceData.setAvgRating(jSONFBUserOrPage.getAvgRating());
facebookPlaceData.setPriceRange(jSONFBUserOrPage.getTranslatedPriceRange());
HashSet hashSet = new HashSet();
if (StringUtils.x(jSONFBUserOrPage.getCategory()) && !"Local business".equalsIgnoreCase(jSONFBUserOrPage.getCategory())) {
hashSet.add(new JSONCategory(jSONFBUserOrPage.getCategory(), ""));
}
if (CollectionUtils.h(jSONFBUserOrPage.getCategoriesList())) {
for (JSONFBType jSONFBType : jSONFBUserOrPage.getCategoriesList()) {
if (StringUtils.x(jSONFBType.getName()) && !"Local business".equalsIgnoreCase(jSONFBType.getName())) {
hashSet.add(new JSONCategory(jSONFBType.getName(), ""));
}
}
}
if (CollectionUtils.h(hashSet)) {
facebookPlaceData.setCategories(new HashSet(hashSet));
}
if (StringUtils.x(jSONFBUserOrPage.getWebsite())) {
facebookPlaceData.setWebsite(new JSONWebsite(jSONFBUserOrPage.getWebsite()));
}
facebookPlaceData.setOpeningHours(jSONFBUserOrPage.getOpeningHours());
arrayList4.add(facebookPlaceData);
}
}
return arrayList4;
}
@Override
public String getCacheKey() {
return "fb_places_search" + str;
}
@Override
public int getCacheTtl() {
return R.integer.week_in_minutes;
}
}, ArrayList.class, true, false, true);
if (CollectionUtils.h(arrayList2)) {
arrayList = new ArrayList();
Iterator it = arrayList2.iterator();
while (it.hasNext()) {
ExtendedPlaceData extendedPlaceData = (ExtendedPlaceData) it.next();
arrayList.add(Pair.create(extendedPlaceData.isOpenNow(), extendedPlaceData));
}
}
placesSearchLoadingEvents.a(arrayList);
}
@Override
public final void a(String str) {
}
@Override
public final HttpRequest b(HttpRequest httpRequest) {
JSONFBUserOrPage loggedInUser = getLoggedInUser();
if (loggedInUser != null) {
if (httpRequest == null) {
httpRequest = UpdateUserProfileUtil.b();
}
UpdateUserProfileUtil.a(httpRequest, new Pair("fbid", loggedInUser.getId()));
}
return httpRequest;
}
@Override
public final void f() {
try {
v a = v.a();
AccessToken.Companion.getClass();
h.f.a().d((AccessToken) null, true);
AuthenticationToken.Companion.getClass();
AuthenticationToken.b.a((AuthenticationToken) null);
Profile.Companion.getClass();
f0.d.a().a((Profile) null, true);
SharedPreferences.Editor edit = a.c.edit();
edit.putBoolean("express_login_allowed", false);
edit.apply();
} catch (FacebookException e2) {
CLog.b(FacebookHelper.class, e2);
} finally {
U();
}
}
@Override
public final void g(final Activity activity) {
if (!isNativeAppInstalled()) {
AnalyticsManager.get().o(Constants.REGISTRATION, "Saw facebook login screen and doesn't have facebook");
}
if (isLoggedIn()) {
onComplete();
} else {
activity.runOnUiThread(new Runnable() {
@Override
public final void run() {
FacebookHelper facebookHelper = FacebookHelper.this;
Activity activity2 = activity;
try {
ArrayList arrayList = FacebookHelper.g;
if (activity2 instanceof OnBoardingNavigationActivity) {
arrayList.remove("user_posts");
}
v a = v.a();
c cVar = facebookHelper.c;
if (cVar == null) {
throw new FacebookException("Unexpected CallbackManager, please use the provided Factory.");
}
int requestCode = c.b.Login.toRequestCode();
com.facebook.login.t tVar = new com.facebook.login.t(a, facebookHelper);
Intrinsics.checkNotNullParameter(tVar, "callback");
cVar.a.put(Integer.valueOf(requestCode), tVar);
v.a().c(activity2, arrayList);
} catch (FacebookException e2) {
facebookHelper.onError(e2.getMessage());
CLog.b(FacebookHelper.class, e2);
}
}
});
}
}
@Override
public int getApiConstantNetworkId() {
return 1;
}
@Override
public String getCurrentUserId() {
JSONFBUserOrPage loggedInUser = getLoggedInUser();
if (loggedInUser != null) {
return loggedInUser.getId();
}
return null;
}
@Override
public DataSource getDataSource() {
return DataSource.facebook;
}
public List<JSONFBEntity> getFriends() {
return (List) H(new RemoteAccountHelper.SocialCallable<List>(this) {
@Override
public final Object a() {
JSONArray optJSONArray;
JSONObject optJSONObject;
JSONObject optJSONObject2;
Bundle bundle = new Bundle();
bundle.putString("fields", "id,name,picture,birthday,link");
bundle.putInt("limit", 5000);
JSONObject jSONObject = new GraphRequest(AccessToken.getCurrentAccessToken(), "me/friends", bundle, a0.GET, (t) null, (String) null).c().c;
ArrayList arrayList = null;
if (jSONObject != null && (optJSONArray = jSONObject.optJSONArray("data")) != null) {
ArrayList arrayList2 = new ArrayList(optJSONArray.length());
for (int i = 0; i < optJSONArray.length(); i++) {
JSONObject optJSONObject3 = optJSONArray.optJSONObject(i);
if (optJSONObject3 != null) {
String optString = optJSONObject3.optString("id");
String optString2 = optJSONObject3.optString("name");
String optString3 = (!optJSONObject3.has("picture") || (optJSONObject = optJSONObject3.optJSONObject("picture")) == null || !optJSONObject.has("data") || (optJSONObject2 = optJSONObject.optJSONObject("data")) == null || !optJSONObject2.has("url") || optJSONObject2.optBoolean("is_silhouette", false)) ? null : optJSONObject2.optString("url");
String optString4 = optJSONObject3.optString("birthday");
arrayList2.add(new JSONFBEntity(optString, optString2, optString4 != null ? FacebookDataUtils.getFacebookBirthDate(optString4) : null, optJSONObject3.optString("link"), optString3));
}
}
arrayList = arrayList2;
}
return (arrayList == null || CollectionUtils.f(arrayList)) ? Collections.EMPTY_LIST : arrayList;
}
@Override
public String getCacheKey() {
return "fb_myFriends_sorted";
}
@Override
public int getCacheTtl() {
return R.integer.facebook_friends_cache_ttl_minutes;
}
@Override
public int getRefreshInterval() {
return R.integer.facebook_friends_cache_refresh_minutes;
}
}, List.class, true, false, true);
}
@Override
public long getFriendsCount() {
if (CollectionUtils.h(getFriends())) {
return r0.size();
}
return 0L;
}
public List<PersonData> getFriendsListAsPersonData() {
List<JSONFBEntity> friends = getFriends();
if (!CollectionUtils.h(friends)) {
return Collections.EMPTY_LIST;
}
ArrayList arrayList = new ArrayList(friends.size());
Iterator<JSONFBEntity> it = friends.iterator();
while (it.hasNext()) {
arrayList.add(new PersonData(it.next()));
}
return arrayList;
}
public JSONFBUserOrPage getLoggedInUser() {
return S("me", false);
}
@Override
public String getName() {
return Activities.getString(R.string.facebook);
}
@Override
public String getUserName() {
String str;
JSONFBUserOrPage loggedInUser = getLoggedInUser();
if (loggedInUser == null) {
return null;
}
if (StringUtils.x(loggedInUser.getUsername())) {
return loggedInUser.getUsername();
}
if (StringUtils.x(loggedInUser.getFirstName())) {
str = "" + loggedInUser.getFirstName();
} else {
str = "";
}
if (StringUtils.x(loggedInUser.getLastName())) {
StringBuilder y = d0.y(str);
y.append(StringUtils.t(str) ? "" : " ");
y.append(loggedInUser.getLastName());
str = y.toString();
}
if (StringUtils.x(str)) {
return str;
}
return null;
}
@Override
public final GlideUrl h(String str) {
return StringUtils.x(str) ? new GlideUrl(str, new LazyHeaders.Builder().addHeader("Authorization", getAuthorizationHeaderValue()).build()) : new GlideUrl(str);
}
@Override
public final boolean i() {
return false;
}
@Override
public boolean isLoggedIn() {
AccessToken currentAccessToken = AccessToken.getCurrentAccessToken();
return (currentAccessToken == null || currentAccessToken.isExpired()) ? false : true;
}
@Override
public boolean isNativeAppInstalled() {
return Activities.l(new Intent("android.intent.action.VIEW", Uri.parse("fb://profile/1000")));
}
@Override
public final JSONSocialNetworkID j(ContactData contactData) {
return contactData.getFacebookId();
}
@Override
public final Map k(boolean z, boolean z2) {
List<JSONFBEntity> friends = getFriends();
if (!CollectionUtils.h(friends)) {
return Collections.EMPTY_MAP;
}
HashMap hashMap = new HashMap(friends.size());
for (JSONFBEntity jSONFBEntity : friends) {
String name = jSONFBEntity.getName();
if (z && StringUtils.x(name)) {
name = name.toLowerCase();
}
hashMap.put(jSONFBEntity.getId(), new Friend(jSONFBEntity.getId(), name, null));
}
return hashMap;
}
@Override
public final String m(String str) {
if (!StringUtils.t(str) && str.contains("facebook.com")) {
Matcher matcher = RegexUtils.c("(?:http:\\/\\/)?(?:www.)?facebook.com\\/(?:(?:\\w)*#!\\/)?(?:pages\\/)?(?:[?\\w\\-]*\\/)?(?:profile.php\\?id=(?=\\d.*))?([\\w\\-\\.]*)?").matcher(str);
if (matcher.find()) {
String group = matcher.group(1);
if (StringUtils.x(group) && StringUtils.y(group, true)) {
return group;
}
}
}
return null;
}
@Override
public final String n(String str) {
return P(str);
}
@Override
public final List o(String str) {
return null;
}
@Override
public final String q(String str) {
ProfileImageUrl profileImageUrl = (ProfileImageUrl) H(new AnonymousClass5(str), ProfileImageUrl.class, false, false, true);
if (profileImageUrl == null || !StringUtils.x(profileImageUrl.a)) {
return null;
}
return com.mobilefuse.sdk.assetsmanager.a.m("https://graph.facebook.com/", profileImageUrl.b, "/picture?type=normal");
}
@Override
public final String r(String str) {
JSONFBUserOrPage S = S(str, true);
if (S != null) {
return S.getName();
}
return null;
}
@Override
public final Object t(RemoteAccountHelper.SocialCallable socialCallable, boolean z) {
try {
return socialCallable.a();
} catch (FacebookException e2) {
CLog.b(FacebookHelper.class, e2);
String message = e2.getMessage();
if (!StringUtils.x(message)) {
return null;
}
Iterator it = e.iterator();
while (it.hasNext()) {
Integer num = (Integer) it.next();
num.getClass();
Locale locale = Locale.US;
if (message.contains("(code " + num + ")")) {
throw new QuotaReachedException((Throwable) e2);
}
}
if (!z) {
return null;
}
Iterator it2 = f.iterator();
while (it2.hasNext()) {
Integer num2 = (Integer) it2.next();
num2.getClass();
Locale locale2 = Locale.US;
if (message.contains("(#" + num2 + ")")) {
throw new UserNotFoundException(e2);
}
}
return null;
}
}
@Override
public final boolean u(String str) {
return false;
}
@Override
public final boolean v(String str) {
return true;
}
@Override
public final void y(Context context, String str, Runnable runnable, OutcomeListener outcomeListener) {
String[] C = StringUtils.C(str, "#@@#");
if (CollectionUtils.j(C) && C.length == 2) {
X(context, C[0], runnable, outcomeListener, C[1]);
} else {
W(context, C[0], runnable, outcomeListener);
}
}
@Override
public final List z(final String str) {
JSONFBEntity jSONFBEntity = StringUtils.t(str) ? null : (JSONFBEntity) H(new RemoteAccountHelper.SocialCallable<JSONFBEntity>() {
@Override
public final Object a() {
UsageCounter usageCounter = UsageCounter.facebookRequests;
int integer = CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_in_minutes);
int integer2 = CallAppApplication.get().getResources().getInteger(R.integer.facebook_search_period_request_limit);
FacebookHelper facebookHelper = FacebookHelper.d;
FacebookHelper facebookHelper2 = FacebookHelper.this;
facebookHelper2.s(usageCounter, integer, integer2, false);
String str2 = str;
JSONFBEntity jSONFBEntity2 = null;
if (!StringUtils.y(str2.replace("+", "").replace(" ", ""), true)) {
return null;
}
String i = RegexUtils.i(new Phone(str2).d());
Bundle bundle = new Bundle();
bundle.putString("fields", "id");
bundle.putString("q", i);
bundle.putInt("limit", 10);
JSONObject jSONObject = new GraphRequest(AccessToken.getCurrentAccessToken(), "/pages/search", bundle, a0.GET, (t) null, (String) null).c().c;
if (jSONObject != null) {
List J = FacebookHelper.J(facebookHelper2, jSONObject);
if (CollectionUtils.h(J)) {
ArrayList arrayList = new ArrayList();
Iterator it = J.iterator();
while (it.hasNext()) {
arrayList.add(((JSONFBUserOrPage) it.next()).getId());
}
JsonNode I = FacebookHelper.I(facebookHelper2, arrayList);
if (I != null) {
int i2 = 0;
while (true) {
if (i2 >= I.size()) {
break;
}
JSONFBUserOrPage jSONFBUserOrPage = (JSONFBUserOrPage) Parser.a(I.get(i2));
if (jSONFBUserOrPage != null) {
String phone = jSONFBUserOrPage.getPhone();
if (StringUtils.x(phone) && StringUtils.k(new Phone(str2).d(), new Phone(phone).d())) {
jSONFBEntity2 = new JSONFBEntity();
jSONFBEntity2.setPhone(phone);
jSONFBEntity2.setId(jSONFBUserOrPage.getId());
jSONFBEntity2.setName(jSONFBUserOrPage.getName());
jSONFBEntity2.setLink(jSONFBUserOrPage.getLink());
jSONFBEntity2.setProfileImageUrl("https://graph.facebook.com/" + jSONFBUserOrPage.getId() + "/picture?type=normal");
break;
}
}
i2++;
}
}
}
}
if (!facebookHelper2.a) {
FeedbackManager.get().b("searched " + facebookHelper2.getName(), 17, 0);
}
UsageCounterDataManager.incrementCounter(UsageCounter.facebookRequests, 1);
return jSONFBEntity2;
}
@Override
public String getCacheKey() {
return "fb_search_" + str;
}
@Override
public int getCacheTtl() {
return R.integer.facebook_search_cache_ttl_minutes;
}
}, JSONFBEntity.class, true, false, true);
if (jSONFBEntity == null) {
return null;
}
ArrayList arrayList = new ArrayList();
arrayList.add(new PersonData(jSONFBEntity));
return arrayList;
}
}