- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
313 lines
15 KiB
Java
313 lines
15 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.ContextCreateDialog;
|
|
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.ContextCreateContent;
|
|
import com.facebook.internal.AppCall;
|
|
import com.facebook.internal.CallbackManagerImpl;
|
|
import com.facebook.internal.DialogPresenter;
|
|
import com.facebook.internal.FacebookDialogBase;
|
|
import com.facebook.internal.FragmentWrapper;
|
|
import com.facebook.internal.NativeProtocol;
|
|
import com.facebook.share.internal.ResultProcessor;
|
|
import com.facebook.share.internal.ShareInternalUtility;
|
|
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.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class ContextCreateDialog extends FacebookDialogBase<ContextCreateContent, Result> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int DEFAULT_REQUEST_CODE = CallbackManagerImpl.RequestCodeOffset.GamingContextCreate.toRequestCode();
|
|
private FacebookCallback<Result> callback;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public ContextCreateDialog(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 ContextCreateDialog(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 ContextCreateDialog(android.app.Fragment fragment) {
|
|
this(new FragmentWrapper(fragment));
|
|
Intrinsics.checkNotNullParameter(fragment, "fragment");
|
|
}
|
|
|
|
private ContextCreateDialog(FragmentWrapper fragmentWrapper) {
|
|
super(fragmentWrapper, DEFAULT_REQUEST_CODE);
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase, com.facebook.FacebookDialog
|
|
public boolean canShow(ContextCreateContent content) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
return CloudGameLoginHandler.isRunningInCloud() || new FacebookAppHandler(this).canShow(content, true) || new WebHandler(this).canShow(content, true);
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase
|
|
public void showImpl(ContextCreateContent content, Object mode) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
Intrinsics.checkNotNullParameter(mode, "mode");
|
|
if (CloudGameLoginHandler.isRunningInCloud()) {
|
|
showForCloud(content);
|
|
} else {
|
|
super.showImpl((ContextCreateDialog) content, mode);
|
|
}
|
|
}
|
|
|
|
private final void showForCloud(ContextCreateContent contextCreateContent) {
|
|
AccessToken currentAccessToken = AccessToken.Companion.getCurrentAccessToken();
|
|
if (currentAccessToken == null || currentAccessToken.isExpired()) {
|
|
throw new FacebookException("Attempted to open ContextCreateContent with an invalid access token");
|
|
}
|
|
DaemonRequest.Callback callback = new DaemonRequest.Callback() { // from class: com.facebook.gamingservices.ContextCreateDialog$$ExternalSyntheticLambda1
|
|
@Override // com.facebook.gamingservices.cloudgaming.DaemonRequest.Callback
|
|
public final void onCompleted(GraphResponse graphResponse) {
|
|
ContextCreateDialog.m547showForCloud$lambda2(ContextCreateDialog.this, graphResponse);
|
|
}
|
|
};
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
if (contextCreateContent.getSuggestedPlayerID() != null) {
|
|
jSONObject.put("id", contextCreateContent.getSuggestedPlayerID());
|
|
}
|
|
DaemonRequest.executeAsync(getActivityContext(), jSONObject, callback, SDKMessageEnum.CONTEXT_CREATE);
|
|
} catch (JSONException unused) {
|
|
FacebookCallback<Result> facebookCallback = this.callback;
|
|
if (facebookCallback == null) {
|
|
return;
|
|
}
|
|
facebookCallback.onError(new FacebookException("Couldn't prepare Context Create Dialog"));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: showForCloud$lambda-2, reason: not valid java name */
|
|
public static final void m547showForCloud$lambda2(ContextCreateDialog 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));
|
|
}
|
|
}
|
|
|
|
@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 ResultProcessor resultProcessor = new ResultProcessor(callback) { // from class: com.facebook.gamingservices.ContextCreateDialog$registerCallbackImpl$resultProcessor$1
|
|
final /* synthetic */ FacebookCallback<ContextCreateDialog.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");
|
|
String string2 = bundle.getString(SDKConstants.PARAM_CONTEXT_CONTEXT_ID);
|
|
if (string != null) {
|
|
GamingContext.Companion.setCurrentGamingContext(new GamingContext(string));
|
|
this.$callback.onSuccess(new ContextCreateDialog.Result(string));
|
|
} else if (string2 != null) {
|
|
GamingContext.Companion.setCurrentGamingContext(new GamingContext(string2));
|
|
this.$callback.onSuccess(new ContextCreateDialog.Result(string2));
|
|
}
|
|
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.ContextCreateDialog$$ExternalSyntheticLambda0
|
|
@Override // com.facebook.internal.CallbackManagerImpl.Callback
|
|
public final boolean onActivityResult(int i, Intent intent) {
|
|
boolean m546registerCallbackImpl$lambda3;
|
|
m546registerCallbackImpl$lambda3 = ContextCreateDialog.m546registerCallbackImpl$lambda3(ContextCreateDialog.this, resultProcessor, i, intent);
|
|
return m546registerCallbackImpl$lambda3;
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: registerCallbackImpl$lambda-3, reason: not valid java name */
|
|
public static final boolean m546registerCallbackImpl$lambda3(ContextCreateDialog this$0, ResultProcessor 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<ContextCreateContent, Result>.ModeHandler> getOrderedModeHandlers() {
|
|
List<FacebookDialogBase<ContextCreateContent, Result>.ModeHandler> listOf;
|
|
listOf = CollectionsKt__CollectionsKt.listOf((Object[]) new FacebookDialogBase.ModeHandler[]{new FacebookAppHandler(this), new WebHandler(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(String contextID) {
|
|
Intrinsics.checkNotNullParameter(contextID, "contextID");
|
|
this.contextID = contextID;
|
|
}
|
|
|
|
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 WebHandler extends FacebookDialogBase<ContextCreateContent, Result>.ModeHandler {
|
|
final /* synthetic */ ContextCreateDialog this$0;
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase.ModeHandler
|
|
public boolean canShow(ContextCreateContent content, boolean z) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
return true;
|
|
}
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public WebHandler(ContextCreateDialog this$0) {
|
|
super(this$0);
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
this.this$0 = this$0;
|
|
}
|
|
|
|
@Override // com.facebook.internal.FacebookDialogBase.ModeHandler
|
|
public AppCall createAppCall(ContextCreateContent content) {
|
|
Intrinsics.checkNotNullParameter(content, "content");
|
|
AppCall createBaseAppCall = this.this$0.createBaseAppCall();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("player_id", content.getSuggestedPlayerID());
|
|
AccessToken currentAccessToken = AccessToken.Companion.getCurrentAccessToken();
|
|
if (currentAccessToken != null) {
|
|
bundle.putString("dialog_access_token", currentAccessToken.getToken());
|
|
}
|
|
DialogPresenter.setupAppCallForWebDialog(createBaseAppCall, "context", bundle);
|
|
return createBaseAppCall;
|
|
}
|
|
}
|
|
|
|
public final class FacebookAppHandler extends FacebookDialogBase<ContextCreateContent, Result>.ModeHandler {
|
|
final /* synthetic */ ContextCreateDialog this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public FacebookAppHandler(ContextCreateDialog 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(ContextCreateContent 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(ContextCreateContent 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_CREATE");
|
|
if (currentAccessToken != null) {
|
|
bundle.putString("game_id", currentAccessToken.getApplicationId());
|
|
} else {
|
|
bundle.putString("game_id", FacebookSdk.getApplicationId());
|
|
}
|
|
if (content.getSuggestedPlayerID() != null) {
|
|
bundle.putString("player_id", content.getSuggestedPlayerID());
|
|
}
|
|
NativeProtocol nativeProtocol = NativeProtocol.INSTANCE;
|
|
NativeProtocol.setupProtocolRequestIntent(intent, createBaseAppCall.getCallId().toString(), "", NativeProtocol.getLatestKnownVersion(), bundle);
|
|
createBaseAppCall.setRequestIntent(intent);
|
|
return createBaseAppCall;
|
|
}
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
}
|
|
}
|