805 lines
26 KiB
Java
805 lines
26 KiB
Java
package com.facebook.internal;
|
|
|
|
import android.content.Context;
|
|
import android.content.pm.PackageInfo;
|
|
import android.content.pm.PackageManager;
|
|
import android.database.Cursor;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Environment;
|
|
import android.os.Parcel;
|
|
import android.os.StatFs;
|
|
import android.telephony.TelephonyManager;
|
|
import android.util.DisplayMetrics;
|
|
import android.util.Log;
|
|
import android.view.Display;
|
|
import android.view.WindowManager;
|
|
import android.webkit.CookieManager;
|
|
import android.webkit.CookieSyncManager;
|
|
import com.facebook.AccessToken;
|
|
import com.facebook.FacebookException;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.GraphRequest;
|
|
import com.facebook.GraphResponse;
|
|
import com.facebook.HttpMethod;
|
|
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
|
import com.ubt.jimu.diy.model.CategoryModel;
|
|
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
|
import java.io.BufferedInputStream;
|
|
import java.io.Closeable;
|
|
import java.io.File;
|
|
import java.io.FilenameFilter;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.io.OutputStream;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import java.math.BigInteger;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URLConnection;
|
|
import java.net.URLDecoder;
|
|
import java.security.MessageDigest;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
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.Random;
|
|
import java.util.Set;
|
|
import java.util.TimeZone;
|
|
import java.util.regex.Pattern;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONTokener;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class Utility {
|
|
private static int a = 0;
|
|
private static long b = -1;
|
|
private static long c = -1;
|
|
private static long d = -1;
|
|
private static String e = "";
|
|
private static String f = "";
|
|
private static String g = "NoCarrier";
|
|
|
|
public interface GraphMeRequestWithCacheCallback {
|
|
void a(FacebookException facebookException);
|
|
|
|
void a(JSONObject jSONObject);
|
|
}
|
|
|
|
public interface Mapper<T, K> {
|
|
K apply(T t);
|
|
}
|
|
|
|
public static class PermissionsPair {
|
|
List<String> a;
|
|
List<String> b;
|
|
|
|
public PermissionsPair(List<String> list, List<String> list2) {
|
|
this.a = list;
|
|
this.b = list2;
|
|
}
|
|
|
|
public List<String> a() {
|
|
return this.b;
|
|
}
|
|
|
|
public List<String> b() {
|
|
return this.a;
|
|
}
|
|
}
|
|
|
|
public static <T> boolean a(Collection<T> collection) {
|
|
return collection == null || collection.size() == 0;
|
|
}
|
|
|
|
public static <T> Collection<T> b(T... tArr) {
|
|
return Collections.unmodifiableCollection(Arrays.asList(tArr));
|
|
}
|
|
|
|
public static boolean c(String str) {
|
|
return str == null || str.length() == 0;
|
|
}
|
|
|
|
public static Bundle d(String str) {
|
|
Bundle bundle = new Bundle();
|
|
if (!c(str)) {
|
|
for (String str2 : str.split("&")) {
|
|
String[] split = str2.split("=");
|
|
try {
|
|
if (split.length == 2) {
|
|
bundle.putString(URLDecoder.decode(split[0], "UTF-8"), URLDecoder.decode(split[1], "UTF-8"));
|
|
} else if (split.length == 1) {
|
|
bundle.putString(URLDecoder.decode(split[0], "UTF-8"), "");
|
|
}
|
|
} catch (UnsupportedEncodingException e2) {
|
|
a("FacebookSDK", (Exception) e2);
|
|
}
|
|
}
|
|
}
|
|
return bundle;
|
|
}
|
|
|
|
public static boolean e(Uri uri) {
|
|
return uri != null && ("http".equalsIgnoreCase(uri.getScheme()) || "https".equalsIgnoreCase(uri.getScheme()) || "fbstaging".equalsIgnoreCase(uri.getScheme()));
|
|
}
|
|
|
|
public static String a(byte[] bArr) {
|
|
return a("SHA-1", bArr);
|
|
}
|
|
|
|
public static List<String> b(JSONArray jSONArray) throws JSONException {
|
|
ArrayList arrayList = new ArrayList();
|
|
for (int i = 0; i < jSONArray.length(); i++) {
|
|
arrayList.add(jSONArray.getString(i));
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public static String c(Context context) {
|
|
Validate.a(context, "context");
|
|
FacebookSdk.c(context);
|
|
return FacebookSdk.c();
|
|
}
|
|
|
|
private static String a(String str, byte[] bArr) {
|
|
try {
|
|
return a(MessageDigest.getInstance(str), bArr);
|
|
} catch (NoSuchAlgorithmException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static void e(Context context) {
|
|
if (b == -1 || System.currentTimeMillis() - b >= 1800000) {
|
|
b = System.currentTimeMillis();
|
|
d();
|
|
d(context);
|
|
e();
|
|
b();
|
|
}
|
|
}
|
|
|
|
private static String a(MessageDigest messageDigest, byte[] bArr) {
|
|
messageDigest.update(bArr);
|
|
byte[] digest = messageDigest.digest();
|
|
StringBuilder sb = new StringBuilder();
|
|
for (byte b2 : digest) {
|
|
sb.append(Integer.toHexString((b2 >> 4) & 15));
|
|
sb.append(Integer.toHexString((b2 >> 0) & 15));
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public static String b(Context context) {
|
|
return context == null ? "null" : context == context.getApplicationContext() ? CategoryModel.unknown : context.getClass().getSimpleName();
|
|
}
|
|
|
|
public static boolean c(Uri uri) {
|
|
return uri != null && "content".equalsIgnoreCase(uri.getScheme());
|
|
}
|
|
|
|
private static int c() {
|
|
int i = a;
|
|
if (i > 0) {
|
|
return i;
|
|
}
|
|
try {
|
|
File[] listFiles = new File("/sys/devices/system/cpu/").listFiles(new FilenameFilter() { // from class: com.facebook.internal.Utility.2
|
|
@Override // java.io.FilenameFilter
|
|
public boolean accept(File file, String str) {
|
|
return Pattern.matches("cpu[0-9]+", str);
|
|
}
|
|
});
|
|
if (listFiles != null) {
|
|
a = listFiles.length;
|
|
}
|
|
} catch (Exception unused) {
|
|
}
|
|
if (a <= 0) {
|
|
a = Math.max(Runtime.getRuntime().availableProcessors(), 1);
|
|
}
|
|
return a;
|
|
}
|
|
|
|
public static String b(Uri uri) {
|
|
if (uri == null) {
|
|
return null;
|
|
}
|
|
return uri.toString();
|
|
}
|
|
|
|
private static GraphRequest b(String str) {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("fields", "id,name,first_name,middle_name,last_name,link");
|
|
bundle.putString(AccessToken.ACCESS_TOKEN_KEY, str);
|
|
return new GraphRequest(null, "me", bundle, HttpMethod.GET, null);
|
|
}
|
|
|
|
private static void e() {
|
|
try {
|
|
if (a()) {
|
|
StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
|
|
c = statFs.getBlockCount() * statFs.getBlockSize();
|
|
}
|
|
c = a(c);
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
|
|
public static Uri a(String str, String str2, Bundle bundle) {
|
|
Uri.Builder builder = new Uri.Builder();
|
|
builder.scheme("https");
|
|
builder.authority(str);
|
|
builder.path(str2);
|
|
if (bundle != null) {
|
|
for (String str3 : bundle.keySet()) {
|
|
Object obj = bundle.get(str3);
|
|
if (obj instanceof String) {
|
|
builder.appendQueryParameter(str3, (String) obj);
|
|
}
|
|
}
|
|
}
|
|
return builder.build();
|
|
}
|
|
|
|
private static void b() {
|
|
try {
|
|
if (a()) {
|
|
StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
|
|
d = statFs.getAvailableBlocks() * statFs.getBlockSize();
|
|
}
|
|
d = a(d);
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
|
|
public static boolean d(Uri uri) {
|
|
return uri != null && "file".equalsIgnoreCase(uri.getScheme());
|
|
}
|
|
|
|
private static void d() {
|
|
try {
|
|
TimeZone timeZone = TimeZone.getDefault();
|
|
e = timeZone.getDisplayName(timeZone.inDaylightTime(new Date()), 0);
|
|
f = timeZone.getID();
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
|
|
public static void a(Bundle bundle, String str, String str2) {
|
|
if (c(str2)) {
|
|
return;
|
|
}
|
|
bundle.putString(str, str2);
|
|
}
|
|
|
|
private static void d(Context context) {
|
|
if (g.equals("NoCarrier")) {
|
|
try {
|
|
g = ((TelephonyManager) context.getSystemService("phone")).getNetworkOperatorName();
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void a(Bundle bundle, String str, Uri uri) {
|
|
if (uri != null) {
|
|
a(bundle, str, uri.toString());
|
|
}
|
|
}
|
|
|
|
public static boolean a(Bundle bundle, String str, Object obj) {
|
|
if (obj == null) {
|
|
bundle.remove(str);
|
|
return true;
|
|
}
|
|
if (obj instanceof Boolean) {
|
|
bundle.putBoolean(str, ((Boolean) obj).booleanValue());
|
|
return true;
|
|
}
|
|
if (obj instanceof boolean[]) {
|
|
bundle.putBooleanArray(str, (boolean[]) obj);
|
|
return true;
|
|
}
|
|
if (obj instanceof Double) {
|
|
bundle.putDouble(str, ((Double) obj).doubleValue());
|
|
return true;
|
|
}
|
|
if (obj instanceof double[]) {
|
|
bundle.putDoubleArray(str, (double[]) obj);
|
|
return true;
|
|
}
|
|
if (obj instanceof Integer) {
|
|
bundle.putInt(str, ((Integer) obj).intValue());
|
|
return true;
|
|
}
|
|
if (obj instanceof int[]) {
|
|
bundle.putIntArray(str, (int[]) obj);
|
|
return true;
|
|
}
|
|
if (obj instanceof Long) {
|
|
bundle.putLong(str, ((Long) obj).longValue());
|
|
return true;
|
|
}
|
|
if (obj instanceof long[]) {
|
|
bundle.putLongArray(str, (long[]) obj);
|
|
return true;
|
|
}
|
|
if (obj instanceof String) {
|
|
bundle.putString(str, (String) obj);
|
|
return true;
|
|
}
|
|
if (obj instanceof JSONArray) {
|
|
bundle.putString(str, obj.toString());
|
|
return true;
|
|
}
|
|
if (!(obj instanceof JSONObject)) {
|
|
return false;
|
|
}
|
|
bundle.putString(str, obj.toString());
|
|
return true;
|
|
}
|
|
|
|
public static void a(Closeable closeable) {
|
|
if (closeable != null) {
|
|
try {
|
|
closeable.close();
|
|
} catch (IOException unused) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void a(URLConnection uRLConnection) {
|
|
if (uRLConnection == null || !(uRLConnection instanceof HttpURLConnection)) {
|
|
return;
|
|
}
|
|
((HttpURLConnection) uRLConnection).disconnect();
|
|
}
|
|
|
|
public static Object a(JSONObject jSONObject, String str, String str2) throws JSONException {
|
|
Object opt = jSONObject.opt(str);
|
|
if (opt != null && (opt instanceof String)) {
|
|
opt = new JSONTokener((String) opt).nextValue();
|
|
}
|
|
if (opt == null || (opt instanceof JSONObject) || (opt instanceof JSONArray)) {
|
|
return opt;
|
|
}
|
|
if (str2 != null) {
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
jSONObject2.putOpt(str2, opt);
|
|
return jSONObject2;
|
|
}
|
|
throw new FacebookException("Got an unexpected non-JSON object.");
|
|
}
|
|
|
|
public static String a(InputStream inputStream) throws IOException {
|
|
BufferedInputStream bufferedInputStream;
|
|
Throwable th;
|
|
InputStreamReader inputStreamReader;
|
|
try {
|
|
bufferedInputStream = new BufferedInputStream(inputStream);
|
|
try {
|
|
inputStreamReader = new InputStreamReader(bufferedInputStream);
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
inputStreamReader = null;
|
|
}
|
|
try {
|
|
StringBuilder sb = new StringBuilder();
|
|
char[] cArr = new char[2048];
|
|
while (true) {
|
|
int read = inputStreamReader.read(cArr);
|
|
if (read != -1) {
|
|
sb.append(cArr, 0, read);
|
|
} else {
|
|
String sb2 = sb.toString();
|
|
a((Closeable) bufferedInputStream);
|
|
a(inputStreamReader);
|
|
return sb2;
|
|
}
|
|
}
|
|
} catch (Throwable th3) {
|
|
th = th3;
|
|
a((Closeable) bufferedInputStream);
|
|
a(inputStreamReader);
|
|
throw th;
|
|
}
|
|
} catch (Throwable th4) {
|
|
bufferedInputStream = null;
|
|
th = th4;
|
|
inputStreamReader = null;
|
|
}
|
|
}
|
|
|
|
public static int a(InputStream inputStream, OutputStream outputStream) throws IOException {
|
|
BufferedInputStream bufferedInputStream;
|
|
try {
|
|
bufferedInputStream = new BufferedInputStream(inputStream);
|
|
} catch (Throwable th) {
|
|
th = th;
|
|
bufferedInputStream = null;
|
|
}
|
|
try {
|
|
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
|
|
int i = 0;
|
|
while (true) {
|
|
int read = bufferedInputStream.read(bArr);
|
|
if (read == -1) {
|
|
break;
|
|
}
|
|
outputStream.write(bArr, 0, read);
|
|
i += read;
|
|
}
|
|
bufferedInputStream.close();
|
|
if (inputStream != null) {
|
|
inputStream.close();
|
|
}
|
|
return i;
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
if (bufferedInputStream != null) {
|
|
bufferedInputStream.close();
|
|
}
|
|
if (inputStream != null) {
|
|
inputStream.close();
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
private static void a(Context context, String str) {
|
|
CookieSyncManager.createInstance(context).sync();
|
|
CookieManager cookieManager = CookieManager.getInstance();
|
|
String cookie = cookieManager.getCookie(str);
|
|
if (cookie == null) {
|
|
return;
|
|
}
|
|
for (String str2 : cookie.split(";")) {
|
|
String[] split = str2.split("=");
|
|
if (split.length > 0) {
|
|
cookieManager.setCookie(str, split[0].trim() + "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;");
|
|
}
|
|
}
|
|
cookieManager.removeExpiredCookie();
|
|
}
|
|
|
|
public static void a(Context context) {
|
|
a(context, "facebook.com");
|
|
a(context, ".facebook.com");
|
|
a(context, "https://facebook.com");
|
|
a(context, "https://.facebook.com");
|
|
}
|
|
|
|
public static void a(String str, Exception exc) {
|
|
if (!FacebookSdk.n() || str == null || exc == null) {
|
|
return;
|
|
}
|
|
Log.d(str, exc.getClass().getSimpleName() + ": " + exc.getMessage());
|
|
}
|
|
|
|
public static void a(String str, String str2) {
|
|
if (!FacebookSdk.n() || str == null || str2 == null) {
|
|
return;
|
|
}
|
|
Log.d(str, str2);
|
|
}
|
|
|
|
public static void a(String str, String str2, Throwable th) {
|
|
if (!FacebookSdk.n() || c(str)) {
|
|
return;
|
|
}
|
|
Log.d(str, str2, th);
|
|
}
|
|
|
|
public static <T> boolean a(T t, T t2) {
|
|
if (t == null) {
|
|
return t2 == null;
|
|
}
|
|
return t.equals(t2);
|
|
}
|
|
|
|
public static void a(File file) {
|
|
File[] listFiles;
|
|
if (file.exists()) {
|
|
if (file.isDirectory() && (listFiles = file.listFiles()) != null) {
|
|
for (File file2 : listFiles) {
|
|
a(file2);
|
|
}
|
|
}
|
|
file.delete();
|
|
}
|
|
}
|
|
|
|
public static <T> List<T> a(T... tArr) {
|
|
ArrayList arrayList = new ArrayList();
|
|
for (T t : tArr) {
|
|
if (t != null) {
|
|
arrayList.add(t);
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public static Set<String> a(JSONArray jSONArray) throws JSONException {
|
|
HashSet hashSet = new HashSet();
|
|
for (int i = 0; i < jSONArray.length(); i++) {
|
|
hashSet.add(jSONArray.getString(i));
|
|
}
|
|
return hashSet;
|
|
}
|
|
|
|
public static void a(JSONObject jSONObject, AttributionIdentifiers attributionIdentifiers, String str, boolean z) throws JSONException {
|
|
if (attributionIdentifiers != null && attributionIdentifiers.c() != null) {
|
|
jSONObject.put("attribution", attributionIdentifiers.c());
|
|
}
|
|
if (attributionIdentifiers != null && attributionIdentifiers.a() != null) {
|
|
jSONObject.put("advertiser_id", attributionIdentifiers.a());
|
|
jSONObject.put("advertiser_tracking_enabled", !attributionIdentifiers.d());
|
|
}
|
|
if (attributionIdentifiers != null && attributionIdentifiers.b() != null) {
|
|
jSONObject.put("installer_package", attributionIdentifiers.b());
|
|
}
|
|
jSONObject.put("anon_id", str);
|
|
jSONObject.put("application_tracking_enabled", !z);
|
|
}
|
|
|
|
public static void a(JSONObject jSONObject, Context context) throws JSONException {
|
|
String str;
|
|
Locale locale;
|
|
int i;
|
|
int i2;
|
|
WindowManager windowManager;
|
|
JSONArray jSONArray = new JSONArray();
|
|
jSONArray.put("a2");
|
|
e(context);
|
|
String packageName = context.getPackageName();
|
|
int i3 = -1;
|
|
try {
|
|
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(packageName, 0);
|
|
i3 = packageInfo.versionCode;
|
|
str = packageInfo.versionName;
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
str = "";
|
|
}
|
|
jSONArray.put(packageName);
|
|
jSONArray.put(i3);
|
|
jSONArray.put(str);
|
|
jSONArray.put(Build.VERSION.RELEASE);
|
|
jSONArray.put(Build.MODEL);
|
|
try {
|
|
locale = context.getResources().getConfiguration().locale;
|
|
} catch (Exception unused2) {
|
|
locale = Locale.getDefault();
|
|
}
|
|
jSONArray.put(locale.getLanguage() + "_" + locale.getCountry());
|
|
jSONArray.put(e);
|
|
jSONArray.put(g);
|
|
double d2 = 0.0d;
|
|
try {
|
|
windowManager = (WindowManager) context.getSystemService("window");
|
|
} catch (Exception unused3) {
|
|
}
|
|
if (windowManager != null) {
|
|
Display defaultDisplay = windowManager.getDefaultDisplay();
|
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
defaultDisplay.getMetrics(displayMetrics);
|
|
i = displayMetrics.widthPixels;
|
|
try {
|
|
i2 = displayMetrics.heightPixels;
|
|
try {
|
|
d2 = displayMetrics.density;
|
|
} catch (Exception unused4) {
|
|
}
|
|
} catch (Exception unused5) {
|
|
}
|
|
jSONArray.put(i);
|
|
jSONArray.put(i2);
|
|
jSONArray.put(String.format("%.2f", Double.valueOf(d2)));
|
|
jSONArray.put(c());
|
|
jSONArray.put(c);
|
|
jSONArray.put(d);
|
|
jSONArray.put(f);
|
|
jSONObject.put("extinfo", jSONArray.toString());
|
|
}
|
|
i = 0;
|
|
i2 = 0;
|
|
jSONArray.put(i);
|
|
jSONArray.put(i2);
|
|
jSONArray.put(String.format("%.2f", Double.valueOf(d2)));
|
|
jSONArray.put(c());
|
|
jSONArray.put(c);
|
|
jSONArray.put(d);
|
|
jSONArray.put(f);
|
|
jSONObject.put("extinfo", jSONArray.toString());
|
|
}
|
|
|
|
public static Method a(Class<?> cls, String str, Class<?>... clsArr) {
|
|
try {
|
|
return cls.getMethod(str, clsArr);
|
|
} catch (NoSuchMethodException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Method a(String str, String str2, Class<?>... clsArr) {
|
|
try {
|
|
return a(Class.forName(str), str2, clsArr);
|
|
} catch (ClassNotFoundException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Object a(Object obj, Method method, Object... objArr) {
|
|
try {
|
|
return method.invoke(obj, objArr);
|
|
} catch (IllegalAccessException | InvocationTargetException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static <T, K> List<K> a(List<T> list, Mapper<T, K> mapper) {
|
|
if (list == null) {
|
|
return null;
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator<T> it = list.iterator();
|
|
while (it.hasNext()) {
|
|
K apply = mapper.apply(it.next());
|
|
if (apply != null) {
|
|
arrayList.add(apply);
|
|
}
|
|
}
|
|
if (arrayList.size() == 0) {
|
|
return null;
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public static long a(Uri uri) {
|
|
Cursor cursor = null;
|
|
try {
|
|
cursor = FacebookSdk.b().getContentResolver().query(uri, null, null, null, null);
|
|
int columnIndex = cursor.getColumnIndex("_size");
|
|
cursor.moveToFirst();
|
|
return cursor.getLong(columnIndex);
|
|
} finally {
|
|
if (cursor != null) {
|
|
cursor.close();
|
|
}
|
|
}
|
|
}
|
|
|
|
public static Date a(Bundle bundle, String str, Date date) {
|
|
long parseLong;
|
|
if (bundle == null) {
|
|
return null;
|
|
}
|
|
Object obj = bundle.get(str);
|
|
if (obj instanceof Long) {
|
|
parseLong = ((Long) obj).longValue();
|
|
} else {
|
|
if (!(obj instanceof String)) {
|
|
return null;
|
|
}
|
|
try {
|
|
parseLong = Long.parseLong((String) obj);
|
|
} catch (NumberFormatException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
if (parseLong == 0) {
|
|
return new Date(Long.MAX_VALUE);
|
|
}
|
|
return new Date(date.getTime() + (parseLong * 1000));
|
|
}
|
|
|
|
public static void a(Parcel parcel, Map<String, String> map) {
|
|
if (map == null) {
|
|
parcel.writeInt(-1);
|
|
return;
|
|
}
|
|
parcel.writeInt(map.size());
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
parcel.writeString(entry.getKey());
|
|
parcel.writeString(entry.getValue());
|
|
}
|
|
}
|
|
|
|
public static Map<String, String> a(Parcel parcel) {
|
|
int readInt = parcel.readInt();
|
|
if (readInt < 0) {
|
|
return null;
|
|
}
|
|
HashMap hashMap = new HashMap();
|
|
for (int i = 0; i < readInt; i++) {
|
|
hashMap.put(parcel.readString(), parcel.readString());
|
|
}
|
|
return hashMap;
|
|
}
|
|
|
|
public static boolean a(AccessToken accessToken) {
|
|
if (accessToken != null) {
|
|
return accessToken.equals(AccessToken.getCurrentAccessToken());
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static void a(final String str, final GraphMeRequestWithCacheCallback graphMeRequestWithCacheCallback) {
|
|
JSONObject a2 = ProfileInformationCache.a(str);
|
|
if (a2 != null) {
|
|
graphMeRequestWithCacheCallback.a(a2);
|
|
return;
|
|
}
|
|
GraphRequest.Callback callback = new GraphRequest.Callback() { // from class: com.facebook.internal.Utility.1
|
|
@Override // com.facebook.GraphRequest.Callback
|
|
public void a(GraphResponse graphResponse) {
|
|
if (graphResponse.a() != null) {
|
|
GraphMeRequestWithCacheCallback.this.a(graphResponse.a().getException());
|
|
} else {
|
|
ProfileInformationCache.a(str, graphResponse.b());
|
|
GraphMeRequestWithCacheCallback.this.a(graphResponse.b());
|
|
}
|
|
}
|
|
};
|
|
GraphRequest b2 = b(str);
|
|
b2.a(callback);
|
|
b2.b();
|
|
}
|
|
|
|
public static JSONObject a(String str) {
|
|
JSONObject a2 = ProfileInformationCache.a(str);
|
|
if (a2 != null) {
|
|
return a2;
|
|
}
|
|
GraphResponse a3 = b(str).a();
|
|
if (a3.a() != null) {
|
|
return null;
|
|
}
|
|
return a3.b();
|
|
}
|
|
|
|
private static boolean a() {
|
|
return "mounted".equals(Environment.getExternalStorageState());
|
|
}
|
|
|
|
private static long a(double d2) {
|
|
return Math.round(d2 / 1.073741824E9d);
|
|
}
|
|
|
|
public static PermissionsPair a(JSONObject jSONObject) throws JSONException {
|
|
String optString;
|
|
JSONArray jSONArray = jSONObject.getJSONObject("permissions").getJSONArray("data");
|
|
ArrayList arrayList = new ArrayList(jSONArray.length());
|
|
ArrayList arrayList2 = new ArrayList(jSONArray.length());
|
|
for (int i = 0; i < jSONArray.length(); i++) {
|
|
JSONObject optJSONObject = jSONArray.optJSONObject(i);
|
|
String optString2 = optJSONObject.optString("permission");
|
|
if (optString2 != null && !optString2.equals("installed") && (optString = optJSONObject.optString(FileDownloadModel.STATUS)) != null) {
|
|
if (optString.equals("granted")) {
|
|
arrayList.add(optString2);
|
|
} else if (optString.equals("declined")) {
|
|
arrayList2.add(optString2);
|
|
}
|
|
}
|
|
}
|
|
return new PermissionsPair(arrayList, arrayList2);
|
|
}
|
|
|
|
public static String a(int i) {
|
|
return new BigInteger(i * 5, new Random()).toString(32);
|
|
}
|
|
}
|