Files
rr3-apk/decompiled/sources/com/facebook/gamingservices/ContextSwitchDialog.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

320 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.ContextSwitchDialog;
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.ContextSwitchContent;
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 ContextSwitchDialog extends FacebookDialogBase<ContextSwitchContent, Result> {
public static final Companion Companion = new Companion(null);
private static final int DEFAULT_REQUEST_CODE = CallbackManagerImpl.RequestCodeOffset.GamingContextSwitch.toRequestCode();
private FacebookCallback<Result> callback;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public ContextSwitchDialog(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 ContextSwitchDialog(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 ContextSwitchDialog(android.app.Fragment fragment) {
this(new FragmentWrapper(fragment));
Intrinsics.checkNotNullParameter(fragment, "fragment");
}
private ContextSwitchDialog(FragmentWrapper fragmentWrapper) {
super(fragmentWrapper, DEFAULT_REQUEST_CODE);
}
@Override // com.facebook.internal.FacebookDialogBase, com.facebook.FacebookDialog
public boolean canShow(ContextSwitchContent 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(ContextSwitchContent content, Object mode) {
Intrinsics.checkNotNullParameter(content, "content");
Intrinsics.checkNotNullParameter(mode, "mode");
if (CloudGameLoginHandler.isRunningInCloud()) {
showForCloud(content);
} else {
super.showImpl((ContextSwitchDialog) content, mode);
}
}
private final void showForCloud(ContextSwitchContent contextSwitchContent) {
AccessToken currentAccessToken = AccessToken.Companion.getCurrentAccessToken();
if (currentAccessToken == null || currentAccessToken.isExpired()) {
throw new FacebookException("Attempted to open ContextSwitchContent with an invalid access token");
}
DaemonRequest.Callback callback = new DaemonRequest.Callback() { // from class: com.facebook.gamingservices.ContextSwitchDialog$$ExternalSyntheticLambda1
@Override // com.facebook.gamingservices.cloudgaming.DaemonRequest.Callback
public final void onCompleted(GraphResponse graphResponse) {
ContextSwitchDialog.m549showForCloud$lambda2(ContextSwitchDialog.this, graphResponse);
}
};
String contextID = contextSwitchContent.getContextID();
if (contextID == null) {
FacebookCallback<Result> facebookCallback = this.callback;
if (facebookCallback == null) {
return;
}
facebookCallback.onError(new FacebookException("Required string contextID not provided."));
return;
}
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("id", contextID);
DaemonRequest.executeAsync(getActivityContext(), jSONObject, callback, SDKMessageEnum.CONTEXT_SWITCH);
} catch (JSONException unused) {
FacebookCallback<Result> facebookCallback2 = this.callback;
if (facebookCallback2 == null) {
return;
}
facebookCallback2.onError(new FacebookException("Couldn't prepare Context Switch Dialog"));
}
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: showForCloud$lambda-2, reason: not valid java name */
public static final void m549showForCloud$lambda2(ContextSwitchDialog 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.ContextSwitchDialog$registerCallbackImpl$resultProcessor$1
final /* synthetic */ FacebookCallback<ContextSwitchDialog.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 ContextSwitchDialog.Result(string));
} else if (string2 != null) {
GamingContext.Companion.setCurrentGamingContext(new GamingContext(string2));
this.$callback.onSuccess(new ContextSwitchDialog.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.ContextSwitchDialog$$ExternalSyntheticLambda0
@Override // com.facebook.internal.CallbackManagerImpl.Callback
public final boolean onActivityResult(int i, Intent intent) {
boolean m548registerCallbackImpl$lambda3;
m548registerCallbackImpl$lambda3 = ContextSwitchDialog.m548registerCallbackImpl$lambda3(ContextSwitchDialog.this, resultProcessor, i, intent);
return m548registerCallbackImpl$lambda3;
}
});
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: registerCallbackImpl$lambda-3, reason: not valid java name */
public static final boolean m548registerCallbackImpl$lambda3(ContextSwitchDialog 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<ContextSwitchContent, Result>.ModeHandler> getOrderedModeHandlers() {
List<FacebookDialogBase<ContextSwitchContent, 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<ContextSwitchContent, Result>.ModeHandler {
final /* synthetic */ ContextSwitchDialog this$0;
@Override // com.facebook.internal.FacebookDialogBase.ModeHandler
public boolean canShow(ContextSwitchContent 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(ContextSwitchDialog 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(ContextSwitchContent content) {
Intrinsics.checkNotNullParameter(content, "content");
AppCall createBaseAppCall = this.this$0.createBaseAppCall();
Bundle bundle = new Bundle();
bundle.putString(SDKConstants.PARAM_CONTEXT_CONTEXT_ID, content.getContextID());
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<ContextSwitchContent, Result>.ModeHandler {
final /* synthetic */ ContextSwitchDialog this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public FacebookAppHandler(ContextSwitchDialog 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(ContextSwitchContent 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(ContextSwitchContent 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_SWITCH");
if (currentAccessToken != null) {
bundle.putString("game_id", currentAccessToken.getApplicationId());
} else {
bundle.putString("game_id", FacebookSdk.getApplicationId());
}
if (content.getContextID() != null) {
bundle.putString("context_token_id", content.getContextID());
}
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() {
}
}
}