- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
345 lines
17 KiB
Java
345 lines
17 KiB
Java
package com.facebook.gamingservices;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Intent;
|
|
import android.content.pm.PackageManager;
|
|
import android.os.Bundle;
|
|
import androidx.fragment.app.Fragment;
|
|
import com.facebook.AccessToken;
|
|
import com.facebook.FacebookCallback;
|
|
import com.facebook.FacebookException;
|
|
import com.facebook.FacebookRequestError;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.GraphResponse;
|
|
import com.facebook.gamingservices.ContextChooseDialog;
|
|
import com.facebook.gamingservices.cloudgaming.CloudGameLoginHandler;
|
|
import com.facebook.gamingservices.cloudgaming.DaemonRequest;
|
|
import com.facebook.gamingservices.cloudgaming.internal.SDKConstants;
|
|
import com.facebook.gamingservices.cloudgaming.internal.SDKMessageEnum;
|
|
import com.facebook.gamingservices.model.ContextChooseContent;
|
|
import com.facebook.internal.AppCall;
|
|
import com.facebook.internal.CallbackManagerImpl;
|
|
import com.facebook.internal.CustomTabUtils;
|
|
import com.facebook.internal.DialogPresenter;
|
|
import com.facebook.internal.FacebookDialogBase;
|
|
import com.facebook.internal.FragmentWrapper;
|
|
import com.facebook.internal.NativeProtocol;
|
|
import com.facebook.internal.ServerProtocol;
|
|
import com.facebook.share.internal.ResultProcessor;
|
|
import com.facebook.share.internal.ShareInternalUtility;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import kotlin.Unit;
|
|
import kotlin.collections.CollectionsKt__CollectionsKt;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class ContextChooseDialog extends FacebookDialogBase<ContextChooseContent, Result> {
|
|
private static final String CONTEXT_CHOOSE_DIALOG = "context_choose";
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int DEFAULT_REQUEST_CODE = CallbackManagerImpl.RequestCodeOffset.GamingContextChoose.toRequestCode();
|
|
private FacebookCallback<Result> callback;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public ContextChooseDialog(Activity activity) {
|
|
super(activity, DEFAULT_REQUEST_CODE);
|
|
Intrinsics.checkNotNullParameter(activity, "activity");
|
|
}
|
|
|
|
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
|
|
public ContextChooseDialog(Fragment fragment) {
|
|
this(new FragmentWrapper(fragment));
|
|
Intrinsics.checkNotNullParameter(fragment, "fragment");
|
|
}
|
|
|
|
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
|
|
public ContextChooseDialog(android.app.Fragment fragment) {
|
|
this(new FragmentWrapper(fragment));
|
|
Intrinsics.checkNotNullParameter(fragment, "fragment");
|
|
}
|
|
|
|
private ContextChooseDialog(FragmentWrapper fragmentWrapper) {
|
|
super(fragmentWrapper, DEFAULT_REQUEST_CODE);
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase, com.facebook.FacebookDialog
|
|
public boolean canShow(ContextChooseContent content) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
return CloudGameLoginHandler.isRunningInCloud() || new FacebookAppHandler(this).canShow(content, true) || new ChromeCustomTabHandler(this).canShow(content, true);
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase
|
|
public void showImpl(ContextChooseContent content, Object mode) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
Intrinsics.checkNotNullParameter(mode, "mode");
|
|
if (CloudGameLoginHandler.isRunningInCloud()) {
|
|
showForCloud(content);
|
|
} else {
|
|
super.showImpl((ContextChooseDialog) content, mode);
|
|
}
|
|
}
|
|
|
|
private final void showForCloud(ContextChooseContent contextChooseContent) {
|
|
AccessToken currentAccessToken = AccessToken.Companion.getCurrentAccessToken();
|
|
if (currentAccessToken == null || currentAccessToken.isExpired()) {
|
|
throw new FacebookException("Attempted to open ContextChooseContent with an invalid access token");
|
|
}
|
|
DaemonRequest.Callback callback = new DaemonRequest.Callback() { // from class: com.facebook.gamingservices.ContextChooseDialog$$ExternalSyntheticLambda0
|
|
@Override // com.facebook.gamingservices.cloudgaming.DaemonRequest.Callback
|
|
public final void onCompleted(GraphResponse graphResponse) {
|
|
ContextChooseDialog.m544showForCloud$lambda2(ContextChooseDialog.this, graphResponse);
|
|
}
|
|
};
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("filters", contextChooseContent.getFilters());
|
|
jSONObject.put(SDKConstants.PARAM_CONTEXT_MIN_SIZE, contextChooseContent.getMinSize());
|
|
List<String> filters = contextChooseContent.getFilters();
|
|
if (filters != null) {
|
|
JSONArray jSONArray = new JSONArray();
|
|
Iterator<String> it = filters.iterator();
|
|
while (it.hasNext()) {
|
|
jSONArray.put(it.next());
|
|
}
|
|
jSONObject.put("filters", jSONArray);
|
|
}
|
|
DaemonRequest.executeAsync(getActivityContext(), jSONObject, callback, SDKMessageEnum.CONTEXT_CHOOSE);
|
|
} catch (JSONException unused) {
|
|
FacebookCallback<Result> facebookCallback = this.callback;
|
|
if (facebookCallback == null) {
|
|
return;
|
|
}
|
|
facebookCallback.onError(new FacebookException("Couldn't prepare Context Choose Dialog"));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: showForCloud$lambda-2, reason: not valid java name */
|
|
public static final void m544showForCloud$lambda2(ContextChooseDialog this$0, GraphResponse response) {
|
|
Unit unit;
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
FacebookCallback<Result> facebookCallback = this$0.callback;
|
|
if (facebookCallback == null) {
|
|
return;
|
|
}
|
|
FacebookRequestError error = response.getError();
|
|
if (error == null) {
|
|
unit = null;
|
|
} else {
|
|
facebookCallback.onError(new FacebookException(error.getErrorMessage()));
|
|
unit = Unit.INSTANCE;
|
|
}
|
|
if (unit == null) {
|
|
Intrinsics.checkNotNullExpressionValue(response, "response");
|
|
facebookCallback.onSuccess(new Result(response));
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Type inference failed for: r0v2, types: [com.facebook.gamingservices.ContextChooseDialog$registerCallbackImpl$resultProcessor$1] */
|
|
@Override // com.facebook.internal.FacebookDialogBase
|
|
public void registerCallbackImpl(CallbackManagerImpl callbackManager, final FacebookCallback<Result> callback) {
|
|
Intrinsics.checkNotNullParameter(callbackManager, "callbackManager");
|
|
Intrinsics.checkNotNullParameter(callback, "callback");
|
|
this.callback = callback;
|
|
final ?? r0 = new ResultProcessor(callback) { // from class: com.facebook.gamingservices.ContextChooseDialog$registerCallbackImpl$resultProcessor$1
|
|
final /* synthetic */ FacebookCallback<ContextChooseDialog.Result> $callback;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
{
|
|
super(callback);
|
|
this.$callback = callback;
|
|
}
|
|
|
|
@Override // com.facebook.share.internal.ResultProcessor
|
|
public void onSuccess(AppCall appCall, Bundle bundle) {
|
|
Intrinsics.checkNotNullParameter(appCall, "appCall");
|
|
if (bundle != null) {
|
|
if (bundle.getString("error_message") != null) {
|
|
this.$callback.onError(new FacebookException(bundle.getString("error_message")));
|
|
return;
|
|
}
|
|
String string = bundle.getString("id");
|
|
if (string != null) {
|
|
GamingContext.Companion.setCurrentGamingContext(new GamingContext(string));
|
|
this.$callback.onSuccess(new ContextChooseDialog.Result(bundle));
|
|
}
|
|
this.$callback.onError(new FacebookException(bundle.getString("Invalid response received from server.")));
|
|
return;
|
|
}
|
|
onCancel(appCall);
|
|
}
|
|
};
|
|
callbackManager.registerCallback(getRequestCode(), new CallbackManagerImpl.Callback() { // from class: com.facebook.gamingservices.ContextChooseDialog$$ExternalSyntheticLambda1
|
|
@Override // com.facebook.internal.CallbackManagerImpl.Callback
|
|
public final boolean onActivityResult(int i, Intent intent) {
|
|
boolean m543registerCallbackImpl$lambda4;
|
|
m543registerCallbackImpl$lambda4 = ContextChooseDialog.m543registerCallbackImpl$lambda4(ContextChooseDialog.this, r0, i, intent);
|
|
return m543registerCallbackImpl$lambda4;
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: registerCallbackImpl$lambda-4, reason: not valid java name */
|
|
public static final boolean m543registerCallbackImpl$lambda4(ContextChooseDialog this$0, ContextChooseDialog$registerCallbackImpl$resultProcessor$1 resultProcessor, int i, Intent intent) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
Intrinsics.checkNotNullParameter(resultProcessor, "$resultProcessor");
|
|
ShareInternalUtility shareInternalUtility = ShareInternalUtility.INSTANCE;
|
|
return ShareInternalUtility.handleActivityResult(this$0.getRequestCode(), i, intent, resultProcessor);
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase
|
|
public List<FacebookDialogBase<ContextChooseContent, Result>.ModeHandler> getOrderedModeHandlers() {
|
|
List<FacebookDialogBase<ContextChooseContent, Result>.ModeHandler> listOf;
|
|
listOf = CollectionsKt__CollectionsKt.listOf((Object[]) new FacebookDialogBase.ModeHandler[]{new FacebookAppHandler(this), new ChromeCustomTabHandler(this)});
|
|
return listOf;
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase
|
|
public AppCall createBaseAppCall() {
|
|
return new AppCall(getRequestCode(), null, 2, null);
|
|
}
|
|
|
|
public static final class Result {
|
|
private String contextID;
|
|
|
|
public final String getContextID() {
|
|
return this.contextID;
|
|
}
|
|
|
|
public final void setContextID(String str) {
|
|
this.contextID = str;
|
|
}
|
|
|
|
public Result(Bundle results) {
|
|
Intrinsics.checkNotNullParameter(results, "results");
|
|
this.contextID = results.getString("id");
|
|
}
|
|
|
|
public Result(GraphResponse response) {
|
|
JSONObject optJSONObject;
|
|
Intrinsics.checkNotNullParameter(response, "response");
|
|
try {
|
|
JSONObject jSONObject = response.getJSONObject();
|
|
if (jSONObject != null && (optJSONObject = jSONObject.optJSONObject("data")) != null) {
|
|
setContextID(optJSONObject.getString("id"));
|
|
}
|
|
} catch (JSONException unused) {
|
|
this.contextID = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final class FacebookAppHandler extends FacebookDialogBase<ContextChooseContent, Result>.ModeHandler {
|
|
final /* synthetic */ ContextChooseDialog this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public FacebookAppHandler(ContextChooseDialog this$0) {
|
|
super(this$0);
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
this.this$0 = this$0;
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase.ModeHandler
|
|
public boolean canShow(ContextChooseContent content, boolean z) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
Activity activityContext = this.this$0.getActivityContext();
|
|
PackageManager packageManager = activityContext == null ? null : activityContext.getPackageManager();
|
|
Intent intent = new Intent("com.facebook.games.gaming_services.DEEPLINK");
|
|
intent.setType("text/plain");
|
|
boolean z2 = (packageManager == null ? null : intent.resolveActivity(packageManager)) != null;
|
|
AccessToken currentAccessToken = AccessToken.Companion.getCurrentAccessToken();
|
|
return z2 && ((currentAccessToken != null ? currentAccessToken.getGraphDomain() : null) != null && Intrinsics.areEqual(FacebookSdk.GAMING, currentAccessToken.getGraphDomain()));
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase.ModeHandler
|
|
public AppCall createAppCall(ContextChooseContent content) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
AppCall createBaseAppCall = this.this$0.createBaseAppCall();
|
|
Intent intent = new Intent("com.facebook.games.gaming_services.DEEPLINK");
|
|
intent.setType("text/plain");
|
|
AccessToken currentAccessToken = AccessToken.Companion.getCurrentAccessToken();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString(SDKConstants.PARAM_TOURNAMENTS_DEEPLINK, "CONTEXT_CHOOSE");
|
|
if (currentAccessToken != null) {
|
|
bundle.putString("game_id", currentAccessToken.getApplicationId());
|
|
} else {
|
|
bundle.putString("game_id", FacebookSdk.getApplicationId());
|
|
}
|
|
if (content.getMinSize() != null) {
|
|
bundle.putString("min_thread_size", content.getMinSize().toString());
|
|
}
|
|
if (content.getMaxSize() != null) {
|
|
bundle.putString("max_thread_size", content.getMaxSize().toString());
|
|
}
|
|
if (content.getFilters() != null) {
|
|
bundle.putString("filters", new JSONArray((Collection) content.getFilters()).toString());
|
|
}
|
|
NativeProtocol nativeProtocol = NativeProtocol.INSTANCE;
|
|
NativeProtocol.setupProtocolRequestIntent(intent, createBaseAppCall.getCallId().toString(), "", NativeProtocol.getLatestKnownVersion(), bundle);
|
|
createBaseAppCall.setRequestIntent(intent);
|
|
return createBaseAppCall;
|
|
}
|
|
}
|
|
|
|
public final class ChromeCustomTabHandler extends FacebookDialogBase<ContextChooseContent, Result>.ModeHandler {
|
|
final /* synthetic */ ContextChooseDialog this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public ChromeCustomTabHandler(ContextChooseDialog this$0) {
|
|
super(this$0);
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
this.this$0 = this$0;
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase.ModeHandler
|
|
public boolean canShow(ContextChooseContent content, boolean z) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
return CustomTabUtils.getChromePackage() != null;
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase.ModeHandler
|
|
public AppCall createAppCall(ContextChooseContent content) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
AppCall createBaseAppCall = this.this$0.createBaseAppCall();
|
|
AccessToken currentAccessToken = AccessToken.Companion.getCurrentAccessToken();
|
|
Bundle bundle = new Bundle();
|
|
Bundle bundle2 = new Bundle();
|
|
Bundle bundle3 = new Bundle();
|
|
String applicationId = currentAccessToken == null ? null : currentAccessToken.getApplicationId();
|
|
if (applicationId == null) {
|
|
applicationId = FacebookSdk.getApplicationId();
|
|
}
|
|
bundle.putString("app_id", applicationId);
|
|
if (content.getMinSize() != null) {
|
|
bundle3.putString("min_size", content.getMinSize().toString());
|
|
}
|
|
if (content.getMaxSize() != null) {
|
|
bundle3.putString("max_size", content.getMaxSize().toString());
|
|
}
|
|
if (content.getFilters() != null) {
|
|
bundle3.putString("filters", new JSONArray((Collection) content.getFilters()).toString());
|
|
}
|
|
bundle2.putString("filters", bundle3.toString());
|
|
bundle.putString("payload", bundle2.toString());
|
|
bundle.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, CustomTabUtils.getDefaultRedirectURI());
|
|
DialogPresenter.setupAppCallForCustomTabDialog(createBaseAppCall, ContextChooseDialog.CONTEXT_CHOOSE_DIALOG, bundle);
|
|
return createBaseAppCall;
|
|
}
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
}
|
|
}
|