jimu-decompiled/sources/com/facebook/internal/Validate.java
2025-05-13 19:24:51 +02:00

172 lines
6.5 KiB
Java

package com.facebook.internal;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.util.Log;
import com.facebook.CustomTabActivity;
import com.facebook.FacebookSdk;
import com.facebook.FacebookSdkNotInitializedException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class Validate {
private static final String a = "com.facebook.internal.Validate";
public static void a(Object obj, String str) {
if (obj != null) {
return;
}
throw new NullPointerException("Argument '" + str + "' cannot be null");
}
public static <T> void b(Collection<T> collection, String str) {
if (collection.isEmpty()) {
throw new IllegalArgumentException("Container '" + str + "' cannot be empty");
}
}
public static <T> void c(Collection<T> collection, String str) {
a((Collection) collection, str);
b(collection, str);
}
public static void d(Context context) {
b(context, true);
}
public static <T> void a(Collection<T> collection, String str) {
a((Object) collection, str);
Iterator<T> it = collection.iterator();
while (it.hasNext()) {
if (it.next() == null) {
throw new NullPointerException("Container '" + str + "' cannot contain null values");
}
}
}
public static String b() {
String g = FacebookSdk.g();
if (g != null) {
return g;
}
throw new IllegalStateException("No Client Token found, please set the Client Token.");
}
public static void c() {
if (!FacebookSdk.o()) {
throw new FacebookSdkNotInitializedException("The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.");
}
}
public static void a(String str, String str2) {
if (Utility.c(str)) {
throw new IllegalArgumentException("Argument '" + str2 + "' cannot be null or empty");
}
}
public static void b(Context context, boolean z) {
a(context, "context");
if (context.checkCallingOrSelfPermission("android.permission.INTERNET") == -1) {
if (!z) {
Log.w(a, "No internet permissions granted for the app, please add <uses-permission android:name=\"android.permission.INTERNET\" /> to your AndroidManifest.xml.");
return;
}
throw new IllegalStateException("No internet permissions granted for the app, please add <uses-permission android:name=\"android.permission.INTERNET\" /> to your AndroidManifest.xml.");
}
}
public static void c(Context context) {
a(context, true);
}
public static String a() {
String c = FacebookSdk.c();
if (c != null) {
return c;
}
throw new IllegalStateException("No App ID found, please set the App ID.");
}
/* JADX WARN: Removed duplicated region for block: B:14:0x002b A[ORIG_RETURN, RETURN] */
/* JADX WARN: Removed duplicated region for block: B:7:0x001b */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public static void a(android.content.Context r3, boolean r4) {
/*
java.lang.String r0 = "context"
a(r3, r0)
android.content.pm.PackageManager r0 = r3.getPackageManager()
if (r0 == 0) goto L18
android.content.ComponentName r1 = new android.content.ComponentName
java.lang.Class<com.facebook.FacebookActivity> r2 = com.facebook.FacebookActivity.class
r1.<init>(r3, r2)
r3 = 1
android.content.pm.ActivityInfo r3 = r0.getActivityInfo(r1, r3) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L18
goto L19
L18:
r3 = 0
L19:
if (r3 != 0) goto L2b
java.lang.String r3 = "FacebookActivity is not declared in the AndroidManifest.xml, please add com.facebook.FacebookActivity to your AndroidManifest.xml file. See https://developers.facebook.com/docs/android/getting-started for more info."
if (r4 != 0) goto L25
java.lang.String r4 = com.facebook.internal.Validate.a
android.util.Log.w(r4, r3)
goto L2b
L25:
java.lang.IllegalStateException r4 = new java.lang.IllegalStateException
r4.<init>(r3)
throw r4
L2b:
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.facebook.internal.Validate.a(android.content.Context, boolean):void");
}
public static boolean b(Context context) {
List<ResolveInfo> list;
a(context, "context");
PackageManager packageManager = context.getPackageManager();
if (packageManager != null) {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addCategory("android.intent.category.BROWSABLE");
intent.setData(Uri.parse("fb" + FacebookSdk.c() + "://authorize"));
list = packageManager.queryIntentActivities(intent, 64);
} else {
list = null;
}
if (list == null) {
return false;
}
Iterator<ResolveInfo> it = list.iterator();
boolean z = false;
while (it.hasNext()) {
if (!it.next().activityInfo.name.equals(CustomTabActivity.class.getName())) {
return false;
}
z = true;
}
return z;
}
public static void a(Context context) {
a(context, "context");
String a2 = a();
PackageManager packageManager = context.getPackageManager();
if (packageManager != null) {
String str = "com.facebook.app.FacebookContentProvider" + a2;
if (packageManager.resolveContentProvider(str, 0) == null) {
throw new IllegalStateException(String.format("A ContentProvider for this app was not set up in the AndroidManifest.xml, please add %s as a provider to your AndroidManifest.xml file. See https://developers.facebook.com/docs/sharing/android for more info.", str));
}
}
}
}