513 lines
19 KiB
Java
513 lines
19 KiB
Java
package com.facebook.internal;
|
|
|
|
import android.content.ContentResolver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.pm.ProviderInfo;
|
|
import android.content.pm.ResolveInfo;
|
|
import android.database.Cursor;
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import com.baidu.cloud.media.player.BDCloudMediaPlayer;
|
|
import com.facebook.FacebookException;
|
|
import com.facebook.FacebookOperationCanceledException;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.login.DefaultAudience;
|
|
import com.unity3d.ads.metadata.MediationMetaData;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.TreeSet;
|
|
import java.util.UUID;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class NativeProtocol {
|
|
private static final String a = "com.facebook.internal.NativeProtocol";
|
|
private static List<NativeAppInfo> b = d();
|
|
private static Map<String, List<NativeAppInfo>> c = c();
|
|
private static AtomicBoolean d = new AtomicBoolean(false);
|
|
private static final List<Integer> e = Arrays.asList(20160327, 20141218, 20141107, 20141028, 20141001, 20140701, 20140324, 20140204, 20131107, 20130618, 20130502, 20121101);
|
|
|
|
private static class FBLiteAppInfo extends NativeAppInfo {
|
|
private FBLiteAppInfo() {
|
|
super();
|
|
}
|
|
|
|
@Override // com.facebook.internal.NativeProtocol.NativeAppInfo
|
|
protected String b() {
|
|
return "com.facebook.lite.platform.LoginGDPDialogActivity";
|
|
}
|
|
|
|
@Override // com.facebook.internal.NativeProtocol.NativeAppInfo
|
|
protected String c() {
|
|
return "com.facebook.lite";
|
|
}
|
|
}
|
|
|
|
private static class KatanaAppInfo extends NativeAppInfo {
|
|
private KatanaAppInfo() {
|
|
super();
|
|
}
|
|
|
|
@Override // com.facebook.internal.NativeProtocol.NativeAppInfo
|
|
protected String b() {
|
|
return "com.facebook.katana.ProxyAuth";
|
|
}
|
|
|
|
@Override // com.facebook.internal.NativeProtocol.NativeAppInfo
|
|
protected String c() {
|
|
return "com.facebook.katana";
|
|
}
|
|
}
|
|
|
|
private static class MessengerAppInfo extends NativeAppInfo {
|
|
private MessengerAppInfo() {
|
|
super();
|
|
}
|
|
|
|
@Override // com.facebook.internal.NativeProtocol.NativeAppInfo
|
|
protected String b() {
|
|
return null;
|
|
}
|
|
|
|
@Override // com.facebook.internal.NativeProtocol.NativeAppInfo
|
|
protected String c() {
|
|
return "com.facebook.orca";
|
|
}
|
|
}
|
|
|
|
private static abstract class NativeAppInfo {
|
|
private TreeSet<Integer> a;
|
|
|
|
private NativeAppInfo() {
|
|
}
|
|
|
|
protected abstract String b();
|
|
|
|
protected abstract String c();
|
|
|
|
public TreeSet<Integer> a() {
|
|
if (this.a == null) {
|
|
a(false);
|
|
}
|
|
return this.a;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* JADX WARN: Code restructure failed: missing block: B:12:0x0005, code lost:
|
|
|
|
if (r0.a == null) goto L6;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
public synchronized void a(boolean r1) {
|
|
/*
|
|
r0 = this;
|
|
monitor-enter(r0)
|
|
if (r1 != 0) goto L7
|
|
java.util.TreeSet<java.lang.Integer> r1 = r0.a // Catch: java.lang.Throwable -> Lf
|
|
if (r1 != 0) goto Ld
|
|
L7:
|
|
java.util.TreeSet r1 = com.facebook.internal.NativeProtocol.a(r0) // Catch: java.lang.Throwable -> Lf
|
|
r0.a = r1 // Catch: java.lang.Throwable -> Lf
|
|
Ld:
|
|
monitor-exit(r0)
|
|
return
|
|
Lf:
|
|
r1 = move-exception
|
|
monitor-exit(r0)
|
|
throw r1
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.facebook.internal.NativeProtocol.NativeAppInfo.a(boolean):void");
|
|
}
|
|
}
|
|
|
|
public static class ProtocolVersionQueryResult {
|
|
private NativeAppInfo a;
|
|
private int b;
|
|
|
|
private ProtocolVersionQueryResult() {
|
|
}
|
|
|
|
public static ProtocolVersionQueryResult a(NativeAppInfo nativeAppInfo, int i) {
|
|
ProtocolVersionQueryResult protocolVersionQueryResult = new ProtocolVersionQueryResult();
|
|
protocolVersionQueryResult.a = nativeAppInfo;
|
|
protocolVersionQueryResult.b = i;
|
|
return protocolVersionQueryResult;
|
|
}
|
|
|
|
public static ProtocolVersionQueryResult b() {
|
|
ProtocolVersionQueryResult protocolVersionQueryResult = new ProtocolVersionQueryResult();
|
|
protocolVersionQueryResult.b = -1;
|
|
return protocolVersionQueryResult;
|
|
}
|
|
|
|
public int a() {
|
|
return this.b;
|
|
}
|
|
}
|
|
|
|
private static class WakizashiAppInfo extends NativeAppInfo {
|
|
private WakizashiAppInfo() {
|
|
super();
|
|
}
|
|
|
|
@Override // com.facebook.internal.NativeProtocol.NativeAppInfo
|
|
protected String b() {
|
|
return "com.facebook.katana.ProxyAuth";
|
|
}
|
|
|
|
@Override // com.facebook.internal.NativeProtocol.NativeAppInfo
|
|
protected String c() {
|
|
return "com.facebook.wakizashi";
|
|
}
|
|
}
|
|
|
|
private static Map<String, List<NativeAppInfo>> c() {
|
|
HashMap hashMap = new HashMap();
|
|
ArrayList arrayList = new ArrayList();
|
|
arrayList.add(new MessengerAppInfo());
|
|
hashMap.put("com.facebook.platform.action.request.OGACTIONPUBLISH_DIALOG", b);
|
|
hashMap.put("com.facebook.platform.action.request.FEED_DIALOG", b);
|
|
hashMap.put("com.facebook.platform.action.request.LIKE_DIALOG", b);
|
|
hashMap.put("com.facebook.platform.action.request.APPINVITES_DIALOG", b);
|
|
hashMap.put("com.facebook.platform.action.request.MESSAGE_DIALOG", arrayList);
|
|
hashMap.put("com.facebook.platform.action.request.OGMESSAGEPUBLISH_DIALOG", arrayList);
|
|
return hashMap;
|
|
}
|
|
|
|
private static List<NativeAppInfo> d() {
|
|
ArrayList arrayList = new ArrayList();
|
|
arrayList.add(new KatanaAppInfo());
|
|
arrayList.add(new WakizashiAppInfo());
|
|
return arrayList;
|
|
}
|
|
|
|
public static final int e() {
|
|
return e.get(0).intValue();
|
|
}
|
|
|
|
public static Bundle f(Intent intent) {
|
|
int e2 = e(intent);
|
|
Bundle extras = intent.getExtras();
|
|
return (!b(e2) || extras == null) ? extras : extras.getBundle("com.facebook.platform.protocol.RESULT_ARGS");
|
|
}
|
|
|
|
public static boolean g(Intent intent) {
|
|
Bundle a2 = a(intent);
|
|
return a2 != null ? a2.containsKey(BDCloudMediaPlayer.OnNativeInvokeListener.ARG_ERROR) : intent.hasExtra("com.facebook.platform.status.ERROR_TYPE");
|
|
}
|
|
|
|
static Intent b(Context context, Intent intent, NativeAppInfo nativeAppInfo) {
|
|
ResolveInfo resolveService;
|
|
if (intent == null || (resolveService = context.getPackageManager().resolveService(intent, 0)) == null || !FacebookSignatureValidator.a(context, resolveService.serviceInfo.packageName)) {
|
|
return null;
|
|
}
|
|
return intent;
|
|
}
|
|
|
|
public static int e(Intent intent) {
|
|
return intent.getIntExtra("com.facebook.platform.protocol.PROTOCOL_VERSION", 0);
|
|
}
|
|
|
|
static Intent a(Context context, Intent intent, NativeAppInfo nativeAppInfo) {
|
|
ResolveInfo resolveActivity;
|
|
if (intent == null || (resolveActivity = context.getPackageManager().resolveActivity(intent, 0)) == null || !FacebookSignatureValidator.a(context, resolveActivity.activityInfo.packageName)) {
|
|
return null;
|
|
}
|
|
return intent;
|
|
}
|
|
|
|
public static Intent b(Context context, String str, Collection<String> collection, String str2, boolean z, boolean z2, DefaultAudience defaultAudience, String str3) {
|
|
for (NativeAppInfo nativeAppInfo : b) {
|
|
Intent a2 = a(context, a(nativeAppInfo, str, collection, str2, z, z2, defaultAudience, str3), nativeAppInfo);
|
|
if (a2 != null) {
|
|
return a2;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static Bundle d(Intent intent) {
|
|
if (!b(e(intent))) {
|
|
return intent.getExtras();
|
|
}
|
|
return intent.getBundleExtra("com.facebook.platform.protocol.METHOD_ARGS");
|
|
}
|
|
|
|
public static Intent a(Context context, String str, Collection<String> collection, String str2, boolean z, boolean z2, DefaultAudience defaultAudience, String str3) {
|
|
FBLiteAppInfo fBLiteAppInfo = new FBLiteAppInfo();
|
|
return a(context, a(fBLiteAppInfo, str, collection, str2, z, z2, defaultAudience, str3), fBLiteAppInfo);
|
|
}
|
|
|
|
public static void f() {
|
|
if (d.compareAndSet(false, true)) {
|
|
FacebookSdk.h().execute(new Runnable() { // from class: com.facebook.internal.NativeProtocol.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
try {
|
|
Iterator it = NativeProtocol.b.iterator();
|
|
while (it.hasNext()) {
|
|
((NativeAppInfo) it.next()).a(true);
|
|
}
|
|
} finally {
|
|
NativeProtocol.d.set(false);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public static boolean b(int i) {
|
|
return e.contains(Integer.valueOf(i)) && i >= 20140701;
|
|
}
|
|
|
|
private static Intent a(NativeAppInfo nativeAppInfo, String str, Collection<String> collection, String str2, boolean z, boolean z2, DefaultAudience defaultAudience, String str3) {
|
|
String b2 = nativeAppInfo.b();
|
|
if (b2 == null) {
|
|
return null;
|
|
}
|
|
Intent putExtra = new Intent().setClassName(nativeAppInfo.c(), b2).putExtra("client_id", str);
|
|
putExtra.putExtra("facebook_sdk_version", FacebookSdk.l());
|
|
if (!Utility.a(collection)) {
|
|
putExtra.putExtra("scope", TextUtils.join(",", collection));
|
|
}
|
|
if (!Utility.c(str2)) {
|
|
putExtra.putExtra("e2e", str2);
|
|
}
|
|
putExtra.putExtra("state", str3);
|
|
putExtra.putExtra("response_type", "token,signed_request");
|
|
putExtra.putExtra("return_scopes", "true");
|
|
if (z2) {
|
|
putExtra.putExtra("default_audience", defaultAudience.getNativeProtocolAudience());
|
|
}
|
|
putExtra.putExtra("legacy_override", FacebookSdk.j());
|
|
putExtra.putExtra("auth_type", "rerequest");
|
|
return putExtra;
|
|
}
|
|
|
|
public static UUID b(Intent intent) {
|
|
String stringExtra;
|
|
if (intent == null) {
|
|
return null;
|
|
}
|
|
if (b(e(intent))) {
|
|
Bundle bundleExtra = intent.getBundleExtra("com.facebook.platform.protocol.BRIDGE_ARGS");
|
|
stringExtra = bundleExtra != null ? bundleExtra.getString("action_id") : null;
|
|
} else {
|
|
stringExtra = intent.getStringExtra("com.facebook.platform.protocol.CALL_ID");
|
|
}
|
|
if (stringExtra == null) {
|
|
return null;
|
|
}
|
|
try {
|
|
return UUID.fromString(stringExtra);
|
|
} catch (IllegalArgumentException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Bundle c(Intent intent) {
|
|
if (!g(intent)) {
|
|
return null;
|
|
}
|
|
Bundle a2 = a(intent);
|
|
if (a2 != null) {
|
|
return a2.getBundle(BDCloudMediaPlayer.OnNativeInvokeListener.ARG_ERROR);
|
|
}
|
|
return intent.getExtras();
|
|
}
|
|
|
|
private static Uri b(NativeAppInfo nativeAppInfo) {
|
|
return Uri.parse("content://" + nativeAppInfo.c() + ".provider.PlatformProvider/versions");
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static TreeSet<Integer> c(NativeAppInfo nativeAppInfo) {
|
|
ProviderInfo providerInfo;
|
|
TreeSet<Integer> treeSet = new TreeSet<>();
|
|
ContentResolver contentResolver = FacebookSdk.b().getContentResolver();
|
|
String[] strArr = {MediationMetaData.KEY_VERSION};
|
|
Uri b2 = b(nativeAppInfo);
|
|
Cursor cursor = null;
|
|
try {
|
|
try {
|
|
providerInfo = FacebookSdk.b().getPackageManager().resolveContentProvider(nativeAppInfo.c() + ".provider.PlatformProvider", 0);
|
|
} catch (RuntimeException e2) {
|
|
Log.e(a, "Failed to query content resolver.", e2);
|
|
providerInfo = null;
|
|
}
|
|
if (providerInfo != null) {
|
|
try {
|
|
cursor = contentResolver.query(b2, strArr, null, null, null);
|
|
} catch (NullPointerException | SecurityException unused) {
|
|
Log.e(a, "Failed to query content resolver.");
|
|
}
|
|
if (cursor != null) {
|
|
while (cursor.moveToNext()) {
|
|
treeSet.add(Integer.valueOf(cursor.getInt(cursor.getColumnIndex(MediationMetaData.KEY_VERSION))));
|
|
}
|
|
}
|
|
}
|
|
return treeSet;
|
|
} finally {
|
|
if (cursor != null) {
|
|
cursor.close();
|
|
}
|
|
}
|
|
}
|
|
|
|
public static Intent a(Context context, String str, String str2, ProtocolVersionQueryResult protocolVersionQueryResult, Bundle bundle) {
|
|
NativeAppInfo nativeAppInfo;
|
|
Intent a2;
|
|
if (protocolVersionQueryResult == null || (nativeAppInfo = protocolVersionQueryResult.a) == null || (a2 = a(context, new Intent().setAction("com.facebook.platform.PLATFORM_ACTIVITY").setPackage(nativeAppInfo.c()).addCategory("android.intent.category.DEFAULT"), nativeAppInfo)) == null) {
|
|
return null;
|
|
}
|
|
a(a2, str, str2, protocolVersionQueryResult.b, bundle);
|
|
return a2;
|
|
}
|
|
|
|
public static void a(Intent intent, String str, String str2, int i, Bundle bundle) {
|
|
String c2 = FacebookSdk.c();
|
|
String d2 = FacebookSdk.d();
|
|
intent.putExtra("com.facebook.platform.protocol.PROTOCOL_VERSION", i).putExtra("com.facebook.platform.protocol.PROTOCOL_ACTION", str2).putExtra("com.facebook.platform.extra.APPLICATION_ID", c2);
|
|
if (b(i)) {
|
|
Bundle bundle2 = new Bundle();
|
|
bundle2.putString("action_id", str);
|
|
Utility.a(bundle2, "app_name", d2);
|
|
intent.putExtra("com.facebook.platform.protocol.BRIDGE_ARGS", bundle2);
|
|
if (bundle == null) {
|
|
bundle = new Bundle();
|
|
}
|
|
intent.putExtra("com.facebook.platform.protocol.METHOD_ARGS", bundle);
|
|
return;
|
|
}
|
|
intent.putExtra("com.facebook.platform.protocol.CALL_ID", str);
|
|
if (!Utility.c(d2)) {
|
|
intent.putExtra("com.facebook.platform.extra.APPLICATION_NAME", d2);
|
|
}
|
|
intent.putExtras(bundle);
|
|
}
|
|
|
|
public static Intent a(Intent intent, Bundle bundle, FacebookException facebookException) {
|
|
UUID b2 = b(intent);
|
|
if (b2 == null) {
|
|
return null;
|
|
}
|
|
Intent intent2 = new Intent();
|
|
intent2.putExtra("com.facebook.platform.protocol.PROTOCOL_VERSION", e(intent));
|
|
Bundle bundle2 = new Bundle();
|
|
bundle2.putString("action_id", b2.toString());
|
|
if (facebookException != null) {
|
|
bundle2.putBundle(BDCloudMediaPlayer.OnNativeInvokeListener.ARG_ERROR, a(facebookException));
|
|
}
|
|
intent2.putExtra("com.facebook.platform.protocol.BRIDGE_ARGS", bundle2);
|
|
if (bundle != null) {
|
|
intent2.putExtra("com.facebook.platform.protocol.RESULT_ARGS", bundle);
|
|
}
|
|
return intent2;
|
|
}
|
|
|
|
public static Intent a(Context context) {
|
|
for (NativeAppInfo nativeAppInfo : b) {
|
|
Intent b2 = b(context, new Intent("com.facebook.platform.PLATFORM_SERVICE").setPackage(nativeAppInfo.c()).addCategory("android.intent.category.DEFAULT"), nativeAppInfo);
|
|
if (b2 != null) {
|
|
return b2;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static Bundle a(Intent intent) {
|
|
if (b(e(intent))) {
|
|
return intent.getBundleExtra("com.facebook.platform.protocol.BRIDGE_ARGS");
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static FacebookException a(Bundle bundle) {
|
|
if (bundle == null) {
|
|
return null;
|
|
}
|
|
String string = bundle.getString("error_type");
|
|
if (string == null) {
|
|
string = bundle.getString("com.facebook.platform.status.ERROR_TYPE");
|
|
}
|
|
String string2 = bundle.getString("error_description");
|
|
if (string2 == null) {
|
|
string2 = bundle.getString("com.facebook.platform.status.ERROR_DESCRIPTION");
|
|
}
|
|
if (string != null && string.equalsIgnoreCase("UserCanceled")) {
|
|
return new FacebookOperationCanceledException(string2);
|
|
}
|
|
return new FacebookException(string2);
|
|
}
|
|
|
|
public static Bundle a(FacebookException facebookException) {
|
|
if (facebookException == null) {
|
|
return null;
|
|
}
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("error_description", facebookException.toString());
|
|
if (facebookException instanceof FacebookOperationCanceledException) {
|
|
bundle.putString("error_type", "UserCanceled");
|
|
}
|
|
return bundle;
|
|
}
|
|
|
|
public static int a(int i) {
|
|
return a(b, new int[]{i}).a();
|
|
}
|
|
|
|
public static ProtocolVersionQueryResult a(String str, int[] iArr) {
|
|
return a(c.get(str), iArr);
|
|
}
|
|
|
|
private static ProtocolVersionQueryResult a(List<NativeAppInfo> list, int[] iArr) {
|
|
f();
|
|
if (list == null) {
|
|
return ProtocolVersionQueryResult.b();
|
|
}
|
|
for (NativeAppInfo nativeAppInfo : list) {
|
|
int a2 = a(nativeAppInfo.a(), e(), iArr);
|
|
if (a2 != -1) {
|
|
return ProtocolVersionQueryResult.a(nativeAppInfo, a2);
|
|
}
|
|
}
|
|
return ProtocolVersionQueryResult.b();
|
|
}
|
|
|
|
public static int a(TreeSet<Integer> treeSet, int i, int[] iArr) {
|
|
int length = iArr.length - 1;
|
|
Iterator<Integer> descendingIterator = treeSet.descendingIterator();
|
|
int i2 = length;
|
|
int i3 = -1;
|
|
while (descendingIterator.hasNext()) {
|
|
int intValue = descendingIterator.next().intValue();
|
|
i3 = Math.max(i3, intValue);
|
|
while (i2 >= 0 && iArr[i2] > intValue) {
|
|
i2--;
|
|
}
|
|
if (i2 < 0) {
|
|
return -1;
|
|
}
|
|
if (iArr[i2] == intValue) {
|
|
if (i2 % 2 == 0) {
|
|
return Math.min(i3, i);
|
|
}
|
|
return -1;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
}
|