- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
280 lines
15 KiB
Java
280 lines
15 KiB
Java
package com.facebook.internal;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import android.util.Pair;
|
|
import androidx.activity.result.ActivityResultCallback;
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
import androidx.activity.result.ActivityResultRegistry;
|
|
import androidx.activity.result.contract.ActivityResultContract;
|
|
import com.facebook.CallbackManager;
|
|
import com.facebook.CustomTabMainActivity;
|
|
import com.facebook.FacebookActivity;
|
|
import com.facebook.FacebookException;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.appevents.InternalAppEventsLogger;
|
|
import com.facebook.internal.FetchedAppSettings;
|
|
import com.facebook.internal.NativeProtocol;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.Ref;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class DialogPresenter {
|
|
public static final DialogPresenter INSTANCE = new DialogPresenter();
|
|
|
|
public interface ParameterProvider {
|
|
Bundle getLegacyParameters();
|
|
|
|
Bundle getParameters();
|
|
}
|
|
|
|
private DialogPresenter() {
|
|
}
|
|
|
|
public static final void setupAppCallForCannotShowError(AppCall appCall) {
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
setupAppCallForValidationError(appCall, new FacebookException("Unable to show the provided content via the web or the installed version of the Facebook app. Some dialogs are only supported starting API 14."));
|
|
}
|
|
|
|
public static final void setupAppCallForValidationError(AppCall appCall, FacebookException facebookException) {
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
setupAppCallForErrorResult(appCall, facebookException);
|
|
}
|
|
|
|
public static final void present(AppCall appCall, Activity activity) {
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
Intrinsics.checkNotNullParameter(activity, "activity");
|
|
activity.startActivityForResult(appCall.getRequestIntent(), appCall.getRequestCode());
|
|
appCall.setPending();
|
|
}
|
|
|
|
public static final void present(AppCall appCall, FragmentWrapper fragmentWrapper) {
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
Intrinsics.checkNotNullParameter(fragmentWrapper, "fragmentWrapper");
|
|
fragmentWrapper.startActivityForResult(appCall.getRequestIntent(), appCall.getRequestCode());
|
|
appCall.setPending();
|
|
}
|
|
|
|
public static final void present(AppCall appCall, ActivityResultRegistry registry, CallbackManager callbackManager) {
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
Intrinsics.checkNotNullParameter(registry, "registry");
|
|
Intent requestIntent = appCall.getRequestIntent();
|
|
if (requestIntent == null) {
|
|
return;
|
|
}
|
|
startActivityForResultWithAndroidX(registry, callbackManager, requestIntent, appCall.getRequestCode());
|
|
appCall.setPending();
|
|
}
|
|
|
|
/* JADX WARN: Type inference failed for: r4v1, types: [T, androidx.activity.result.ActivityResultLauncher] */
|
|
public static final void startActivityForResultWithAndroidX(ActivityResultRegistry registry, final CallbackManager callbackManager, Intent intent, final int i) {
|
|
Intrinsics.checkNotNullParameter(registry, "registry");
|
|
Intrinsics.checkNotNullParameter(intent, "intent");
|
|
final Ref.ObjectRef objectRef = new Ref.ObjectRef();
|
|
?? register = registry.register(Intrinsics.stringPlus("facebook-dialog-request-", Integer.valueOf(i)), new ActivityResultContract<Intent, Pair<Integer, Intent>>() { // from class: com.facebook.internal.DialogPresenter$startActivityForResultWithAndroidX$1
|
|
@Override // androidx.activity.result.contract.ActivityResultContract
|
|
public Intent createIntent(Context context, Intent input) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(input, "input");
|
|
return input;
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // androidx.activity.result.contract.ActivityResultContract
|
|
public Pair<Integer, Intent> parseResult(int i2, Intent intent2) {
|
|
Pair<Integer, Intent> create = Pair.create(Integer.valueOf(i2), intent2);
|
|
Intrinsics.checkNotNullExpressionValue(create, "create(resultCode, intent)");
|
|
return create;
|
|
}
|
|
}, new ActivityResultCallback() { // from class: com.facebook.internal.DialogPresenter$$ExternalSyntheticLambda0
|
|
@Override // androidx.activity.result.ActivityResultCallback
|
|
public final void onActivityResult(Object obj) {
|
|
DialogPresenter.m556startActivityForResultWithAndroidX$lambda2(CallbackManager.this, i, objectRef, (Pair) obj);
|
|
}
|
|
});
|
|
objectRef.element = register;
|
|
if (register == 0) {
|
|
return;
|
|
}
|
|
register.launch(intent);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* renamed from: startActivityForResultWithAndroidX$lambda-2, reason: not valid java name */
|
|
public static final void m556startActivityForResultWithAndroidX$lambda2(CallbackManager callbackManager, int i, Ref.ObjectRef launcher, Pair pair) {
|
|
Intrinsics.checkNotNullParameter(launcher, "$launcher");
|
|
if (callbackManager == null) {
|
|
callbackManager = new CallbackManagerImpl();
|
|
}
|
|
Object obj = pair.first;
|
|
Intrinsics.checkNotNullExpressionValue(obj, "result.first");
|
|
callbackManager.onActivityResult(i, ((Number) obj).intValue(), (Intent) pair.second);
|
|
ActivityResultLauncher activityResultLauncher = (ActivityResultLauncher) launcher.element;
|
|
if (activityResultLauncher == null) {
|
|
return;
|
|
}
|
|
synchronized (activityResultLauncher) {
|
|
activityResultLauncher.unregister();
|
|
launcher.element = null;
|
|
Unit unit = Unit.INSTANCE;
|
|
}
|
|
}
|
|
|
|
public static final boolean canPresentNativeDialogWithFeature(DialogFeature feature) {
|
|
Intrinsics.checkNotNullParameter(feature, "feature");
|
|
return getProtocolVersionForNativeDialog(feature).getProtocolVersion() != -1;
|
|
}
|
|
|
|
public static final boolean canPresentWebFallbackDialogWithFeature(DialogFeature feature) {
|
|
Intrinsics.checkNotNullParameter(feature, "feature");
|
|
return INSTANCE.getDialogWebFallbackUri(feature) != null;
|
|
}
|
|
|
|
public static final void setupAppCallForErrorResult(AppCall appCall, FacebookException facebookException) {
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
if (facebookException == null) {
|
|
return;
|
|
}
|
|
Validate validate = Validate.INSTANCE;
|
|
Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());
|
|
Intent intent = new Intent();
|
|
intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
|
|
intent.setAction(FacebookActivity.PASS_THROUGH_CANCEL_ACTION);
|
|
NativeProtocol nativeProtocol = NativeProtocol.INSTANCE;
|
|
NativeProtocol.setupProtocolRequestIntent(intent, appCall.getCallId().toString(), null, NativeProtocol.getLatestKnownVersion(), NativeProtocol.createBundleForException(facebookException));
|
|
appCall.setRequestIntent(intent);
|
|
}
|
|
|
|
public static final void setupAppCallForWebDialog(AppCall appCall, String str, Bundle bundle) {
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
Validate validate = Validate.INSTANCE;
|
|
Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());
|
|
Validate.hasInternetPermissions(FacebookSdk.getApplicationContext());
|
|
Bundle bundle2 = new Bundle();
|
|
bundle2.putString("action", str);
|
|
bundle2.putBundle("params", bundle);
|
|
Intent intent = new Intent();
|
|
NativeProtocol nativeProtocol = NativeProtocol.INSTANCE;
|
|
NativeProtocol.setupProtocolRequestIntent(intent, appCall.getCallId().toString(), str, NativeProtocol.getLatestKnownVersion(), bundle2);
|
|
intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
|
|
intent.setAction(FacebookDialogFragment.TAG);
|
|
appCall.setRequestIntent(intent);
|
|
}
|
|
|
|
public static final void setupAppCallForWebFallbackDialog(AppCall appCall, Bundle bundle, DialogFeature feature) {
|
|
Uri buildUri;
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
Intrinsics.checkNotNullParameter(feature, "feature");
|
|
Validate validate = Validate.INSTANCE;
|
|
Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());
|
|
Validate.hasInternetPermissions(FacebookSdk.getApplicationContext());
|
|
String name = feature.name();
|
|
Uri dialogWebFallbackUri = INSTANCE.getDialogWebFallbackUri(feature);
|
|
if (dialogWebFallbackUri == null) {
|
|
throw new FacebookException("Unable to fetch the Url for the DialogFeature : '" + name + '\'');
|
|
}
|
|
int latestKnownVersion = NativeProtocol.getLatestKnownVersion();
|
|
ServerProtocol serverProtocol = ServerProtocol.INSTANCE;
|
|
String uuid = appCall.getCallId().toString();
|
|
Intrinsics.checkNotNullExpressionValue(uuid, "appCall.callId.toString()");
|
|
Bundle queryParamsForPlatformActivityIntentWebFallback = ServerProtocol.getQueryParamsForPlatformActivityIntentWebFallback(uuid, latestKnownVersion, bundle);
|
|
if (queryParamsForPlatformActivityIntentWebFallback == null) {
|
|
throw new FacebookException("Unable to fetch the app's key-hash");
|
|
}
|
|
if (dialogWebFallbackUri.isRelative()) {
|
|
Utility utility = Utility.INSTANCE;
|
|
buildUri = Utility.buildUri(ServerProtocol.getDialogAuthority(), dialogWebFallbackUri.toString(), queryParamsForPlatformActivityIntentWebFallback);
|
|
} else {
|
|
Utility utility2 = Utility.INSTANCE;
|
|
buildUri = Utility.buildUri(dialogWebFallbackUri.getAuthority(), dialogWebFallbackUri.getPath(), queryParamsForPlatformActivityIntentWebFallback);
|
|
}
|
|
Bundle bundle2 = new Bundle();
|
|
bundle2.putString("url", buildUri.toString());
|
|
bundle2.putBoolean(NativeProtocol.WEB_DIALOG_IS_FALLBACK, true);
|
|
Intent intent = new Intent();
|
|
NativeProtocol.setupProtocolRequestIntent(intent, appCall.getCallId().toString(), feature.getAction(), NativeProtocol.getLatestKnownVersion(), bundle2);
|
|
intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
|
|
intent.setAction(FacebookDialogFragment.TAG);
|
|
appCall.setRequestIntent(intent);
|
|
}
|
|
|
|
public static final void setupAppCallForNativeDialog(AppCall appCall, ParameterProvider parameterProvider, DialogFeature feature) {
|
|
Bundle legacyParameters;
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
Intrinsics.checkNotNullParameter(parameterProvider, "parameterProvider");
|
|
Intrinsics.checkNotNullParameter(feature, "feature");
|
|
Context applicationContext = FacebookSdk.getApplicationContext();
|
|
String action = feature.getAction();
|
|
NativeProtocol.ProtocolVersionQueryResult protocolVersionForNativeDialog = getProtocolVersionForNativeDialog(feature);
|
|
int protocolVersion = protocolVersionForNativeDialog.getProtocolVersion();
|
|
if (protocolVersion == -1) {
|
|
throw new FacebookException("Cannot present this dialog. This likely means that the Facebook app is not installed.");
|
|
}
|
|
if (NativeProtocol.isVersionCompatibleWithBucketedIntent(protocolVersion)) {
|
|
legacyParameters = parameterProvider.getParameters();
|
|
} else {
|
|
legacyParameters = parameterProvider.getLegacyParameters();
|
|
}
|
|
if (legacyParameters == null) {
|
|
legacyParameters = new Bundle();
|
|
}
|
|
Intent createPlatformActivityIntent = NativeProtocol.createPlatformActivityIntent(applicationContext, appCall.getCallId().toString(), action, protocolVersionForNativeDialog, legacyParameters);
|
|
if (createPlatformActivityIntent == null) {
|
|
throw new FacebookException("Unable to create Intent; this likely means theFacebook app is not installed.");
|
|
}
|
|
appCall.setRequestIntent(createPlatformActivityIntent);
|
|
}
|
|
|
|
public static final void setupAppCallForCustomTabDialog(AppCall appCall, String str, Bundle bundle) {
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
Validate validate = Validate.INSTANCE;
|
|
Validate.hasCustomTabRedirectActivity(FacebookSdk.getApplicationContext(), CustomTabUtils.getDefaultRedirectURI());
|
|
Validate.hasInternetPermissions(FacebookSdk.getApplicationContext());
|
|
Intent intent = new Intent(FacebookSdk.getApplicationContext(), (Class<?>) CustomTabMainActivity.class);
|
|
intent.putExtra(CustomTabMainActivity.EXTRA_ACTION, str);
|
|
intent.putExtra(CustomTabMainActivity.EXTRA_PARAMS, bundle);
|
|
intent.putExtra(CustomTabMainActivity.EXTRA_CHROME_PACKAGE, CustomTabUtils.getChromePackage());
|
|
NativeProtocol nativeProtocol = NativeProtocol.INSTANCE;
|
|
NativeProtocol.setupProtocolRequestIntent(intent, appCall.getCallId().toString(), str, NativeProtocol.getLatestKnownVersion(), null);
|
|
appCall.setRequestIntent(intent);
|
|
}
|
|
|
|
private final Uri getDialogWebFallbackUri(DialogFeature dialogFeature) {
|
|
String name = dialogFeature.name();
|
|
String action = dialogFeature.getAction();
|
|
FetchedAppSettings.DialogFeatureConfig dialogFeatureConfig = FetchedAppSettings.Companion.getDialogFeatureConfig(FacebookSdk.getApplicationId(), action, name);
|
|
if (dialogFeatureConfig != null) {
|
|
return dialogFeatureConfig.getFallbackUrl();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static final NativeProtocol.ProtocolVersionQueryResult getProtocolVersionForNativeDialog(DialogFeature feature) {
|
|
Intrinsics.checkNotNullParameter(feature, "feature");
|
|
String applicationId = FacebookSdk.getApplicationId();
|
|
String action = feature.getAction();
|
|
return NativeProtocol.getLatestAvailableProtocolVersionForAction(action, INSTANCE.getVersionSpecForFeature(applicationId, action, feature));
|
|
}
|
|
|
|
private final int[] getVersionSpecForFeature(String str, String str2, DialogFeature dialogFeature) {
|
|
FetchedAppSettings.DialogFeatureConfig dialogFeatureConfig = FetchedAppSettings.Companion.getDialogFeatureConfig(str, str2, dialogFeature.name());
|
|
int[] versionSpec = dialogFeatureConfig == null ? null : dialogFeatureConfig.getVersionSpec();
|
|
return versionSpec == null ? new int[]{dialogFeature.getMinVersion()} : versionSpec;
|
|
}
|
|
|
|
public static final void logDialogActivity(Context context, String eventName, String outcome) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(eventName, "eventName");
|
|
Intrinsics.checkNotNullParameter(outcome, "outcome");
|
|
InternalAppEventsLogger internalAppEventsLogger = new InternalAppEventsLogger(context);
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
|
|
internalAppEventsLogger.logEventImplicitly(eventName, bundle);
|
|
}
|
|
}
|