Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,394 @@
package com.facebook.login;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.fragment.app.DialogFragment;
import com.facebook.AccessToken;
import com.facebook.AccessTokenSource;
import com.facebook.FacebookActivity;
import com.facebook.FacebookException;
import com.facebook.FacebookRequestError;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.GraphRequestAsyncTask;
import com.facebook.GraphResponse;
import com.facebook.HttpMethod;
import com.facebook.R$id;
import com.facebook.R$layout;
import com.facebook.R$string;
import com.facebook.R$style;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.devicerequests.internal.DeviceRequestsHelper;
import com.facebook.internal.FetchedAppSettingsManager;
import com.facebook.internal.SmartLoginOption;
import com.facebook.internal.Utility;
import com.facebook.internal.Validate;
import com.facebook.login.LoginClient;
import com.ubt.jimu.base.entities.Course;
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
import com.unity3d.ads.metadata.MediationMetaData;
import java.util.Date;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes.dex */
public class DeviceAuthDialog extends DialogFragment {
private ProgressBar j;
private TextView k;
private DeviceAuthMethodHandler l;
private volatile GraphRequestAsyncTask n;
private volatile ScheduledFuture o;
private volatile RequestState p;
private Dialog q;
private AtomicBoolean m = new AtomicBoolean();
private boolean r = false;
private boolean s = false;
private LoginClient.Request t = null;
private static class RequestState implements Parcelable {
public static final Parcelable.Creator<RequestState> CREATOR = new Parcelable.Creator<RequestState>() { // from class: com.facebook.login.DeviceAuthDialog.RequestState.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public RequestState createFromParcel(Parcel parcel) {
return new RequestState(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public RequestState[] newArray(int i) {
return new RequestState[i];
}
};
private long interval;
private long lastPoll;
private String requestCode;
private String userCode;
RequestState() {
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public long getInterval() {
return this.interval;
}
public String getRequestCode() {
return this.requestCode;
}
public String getUserCode() {
return this.userCode;
}
public void setInterval(long j) {
this.interval = j;
}
public void setLastPoll(long j) {
this.lastPoll = j;
}
public void setRequestCode(String str) {
this.requestCode = str;
}
public void setUserCode(String str) {
this.userCode = str;
}
public boolean withinLastRefreshWindow() {
return this.lastPoll != 0 && (new Date().getTime() - this.lastPoll) - (this.interval * 1000) < 0;
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(this.userCode);
parcel.writeString(this.requestCode);
parcel.writeLong(this.interval);
parcel.writeLong(this.lastPoll);
}
protected RequestState(Parcel parcel) {
this.userCode = parcel.readString();
this.requestCode = parcel.readString();
this.interval = parcel.readLong();
this.lastPoll = parcel.readLong();
}
}
private GraphRequest o() {
Bundle bundle = new Bundle();
bundle.putString(Course.TYPE_BLOCKLY, this.p.getRequestCode());
return new GraphRequest(null, "device/login_status", bundle, HttpMethod.POST, new GraphRequest.Callback() { // from class: com.facebook.login.DeviceAuthDialog.4
@Override // com.facebook.GraphRequest.Callback
public void a(GraphResponse graphResponse) {
if (DeviceAuthDialog.this.m.get()) {
return;
}
FacebookRequestError a = graphResponse.a();
if (a == null) {
try {
DeviceAuthDialog.this.c(graphResponse.b().getString(AccessToken.ACCESS_TOKEN_KEY));
return;
} catch (JSONException e) {
DeviceAuthDialog.this.a(new FacebookException(e));
return;
}
}
int subErrorCode = a.getSubErrorCode();
if (subErrorCode != 1349152) {
switch (subErrorCode) {
case 1349172:
case 1349174:
DeviceAuthDialog.this.x();
break;
case 1349173:
break;
default:
DeviceAuthDialog.this.a(graphResponse.a().getException());
break;
}
return;
}
DeviceAuthDialog.this.q();
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public void q() {
if (this.m.compareAndSet(false, true)) {
if (this.p != null) {
DeviceRequestsHelper.a(this.p.getUserCode());
}
DeviceAuthMethodHandler deviceAuthMethodHandler = this.l;
if (deviceAuthMethodHandler != null) {
deviceAuthMethodHandler.onCancel();
}
this.q.dismiss();
}
}
/* JADX INFO: Access modifiers changed from: private */
public void v() {
this.p.setLastPoll(new Date().getTime());
this.n = o().b();
}
/* JADX INFO: Access modifiers changed from: private */
public void x() {
this.o = DeviceAuthMethodHandler.getBackgroundExecutor().schedule(new Runnable() { // from class: com.facebook.login.DeviceAuthDialog.3
@Override // java.lang.Runnable
public void run() {
DeviceAuthDialog.this.v();
}
}, this.p.getInterval(), TimeUnit.SECONDS);
}
@Override // androidx.fragment.app.Fragment
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
RequestState requestState;
View onCreateView = super.onCreateView(layoutInflater, viewGroup, bundle);
this.l = (DeviceAuthMethodHandler) ((LoginFragment) ((FacebookActivity) getActivity()).D0()).o().getCurrentHandler();
if (bundle != null && (requestState = (RequestState) bundle.getParcelable("request_state")) != null) {
a(requestState);
}
return onCreateView;
}
@Override // androidx.fragment.app.Fragment
public void onDestroy() {
this.r = true;
this.m.set(true);
super.onDestroy();
if (this.n != null) {
this.n.cancel(true);
}
if (this.o != null) {
this.o.cancel(true);
}
}
@Override // androidx.fragment.app.DialogFragment, android.content.DialogInterface.OnDismissListener
public void onDismiss(DialogInterface dialogInterface) {
super.onDismiss(dialogInterface);
if (this.r) {
return;
}
q();
}
@Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
public void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
if (this.p != null) {
bundle.putParcelable("request_state", this.p);
}
}
/* JADX INFO: Access modifiers changed from: private */
public View c(boolean z) {
LayoutInflater layoutInflater = getActivity().getLayoutInflater();
View inflate = z ? layoutInflater.inflate(R$layout.com_facebook_smart_device_dialog_fragment, (ViewGroup) null) : layoutInflater.inflate(R$layout.com_facebook_device_auth_dialog_fragment, (ViewGroup) null);
this.j = (ProgressBar) inflate.findViewById(R$id.progress_bar);
this.k = (TextView) inflate.findViewById(R$id.confirmation_code);
((Button) inflate.findViewById(R$id.cancel_button)).setOnClickListener(new View.OnClickListener() { // from class: com.facebook.login.DeviceAuthDialog.2
@Override // android.view.View.OnClickListener
public void onClick(View view) {
DeviceAuthDialog.this.q();
}
});
((TextView) inflate.findViewById(R$id.com_facebook_device_auth_instructions)).setText(Html.fromHtml(getString(R$string.com_facebook_device_auth_instructions)));
return inflate;
}
@Override // androidx.fragment.app.DialogFragment
public Dialog a(Bundle bundle) {
this.q = new Dialog(getActivity(), R$style.com_facebook_auth_dialog);
getActivity().getLayoutInflater();
this.q.setContentView(c(DeviceRequestsHelper.b() && !this.s));
return this.q;
}
/* JADX INFO: Access modifiers changed from: private */
public void c(final String str) {
Bundle bundle = new Bundle();
bundle.putString("fields", "id,permissions,name");
new GraphRequest(new AccessToken(str, FacebookSdk.c(), "0", null, null, null, null, null), "me", bundle, HttpMethod.GET, new GraphRequest.Callback() { // from class: com.facebook.login.DeviceAuthDialog.7
@Override // com.facebook.GraphRequest.Callback
public void a(GraphResponse graphResponse) {
if (DeviceAuthDialog.this.m.get()) {
return;
}
if (graphResponse.a() != null) {
DeviceAuthDialog.this.a(graphResponse.a().getException());
return;
}
try {
JSONObject b = graphResponse.b();
String string = b.getString(JockstickDataConverter.ID);
Utility.PermissionsPair a = Utility.a(b);
String string2 = b.getString(MediationMetaData.KEY_NAME);
DeviceRequestsHelper.a(DeviceAuthDialog.this.p.getUserCode());
if (!FetchedAppSettingsManager.c(FacebookSdk.c()).f().contains(SmartLoginOption.RequireConfirm) || DeviceAuthDialog.this.s) {
DeviceAuthDialog.this.a(string, a, str);
} else {
DeviceAuthDialog.this.s = true;
DeviceAuthDialog.this.a(string, a, str, string2);
}
} catch (JSONException e) {
DeviceAuthDialog.this.a(new FacebookException(e));
}
}
}).b();
}
public void a(LoginClient.Request request) {
this.t = request;
Bundle bundle = new Bundle();
bundle.putString("scope", TextUtils.join(",", request.getPermissions()));
String deviceRedirectUriString = request.getDeviceRedirectUriString();
if (deviceRedirectUriString != null) {
bundle.putString("redirect_uri", deviceRedirectUriString);
}
bundle.putString(AccessToken.ACCESS_TOKEN_KEY, Validate.a() + "|" + Validate.b());
bundle.putString("device_info", DeviceRequestsHelper.a());
new GraphRequest(null, "device/login", bundle, HttpMethod.POST, new GraphRequest.Callback() { // from class: com.facebook.login.DeviceAuthDialog.1
@Override // com.facebook.GraphRequest.Callback
public void a(GraphResponse graphResponse) {
if (DeviceAuthDialog.this.r) {
return;
}
if (graphResponse.a() != null) {
DeviceAuthDialog.this.a(graphResponse.a().getException());
return;
}
JSONObject b = graphResponse.b();
RequestState requestState = new RequestState();
try {
requestState.setUserCode(b.getString("user_code"));
requestState.setRequestCode(b.getString(Course.TYPE_BLOCKLY));
requestState.setInterval(b.getLong("interval"));
DeviceAuthDialog.this.a(requestState);
} catch (JSONException e) {
DeviceAuthDialog.this.a(new FacebookException(e));
}
}
}).b();
}
/* JADX INFO: Access modifiers changed from: private */
public void a(RequestState requestState) {
this.p = requestState;
this.k.setText(requestState.getUserCode());
this.k.setVisibility(0);
this.j.setVisibility(8);
if (!this.s && DeviceRequestsHelper.c(requestState.getUserCode())) {
AppEventsLogger.b(getContext()).a("fb_smart_login_service", (Double) null, (Bundle) null);
}
if (requestState.withinLastRefreshWindow()) {
x();
} else {
v();
}
}
/* JADX INFO: Access modifiers changed from: private */
public void a(final String str, final Utility.PermissionsPair permissionsPair, final String str2, String str3) {
String string = getResources().getString(R$string.com_facebook_smart_login_confirmation_title);
String string2 = getResources().getString(R$string.com_facebook_smart_login_confirmation_continue_as);
String string3 = getResources().getString(R$string.com_facebook_smart_login_confirmation_cancel);
String format = String.format(string2, str3);
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setMessage(string).setCancelable(true).setNegativeButton(format, new DialogInterface.OnClickListener() { // from class: com.facebook.login.DeviceAuthDialog.6
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
DeviceAuthDialog.this.a(str, permissionsPair, str2);
}
}).setPositiveButton(string3, new DialogInterface.OnClickListener() { // from class: com.facebook.login.DeviceAuthDialog.5
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
DeviceAuthDialog.this.q.setContentView(DeviceAuthDialog.this.c(false));
DeviceAuthDialog deviceAuthDialog = DeviceAuthDialog.this;
deviceAuthDialog.a(deviceAuthDialog.t);
}
});
builder.create().show();
}
/* JADX INFO: Access modifiers changed from: private */
public void a(String str, Utility.PermissionsPair permissionsPair, String str2) {
this.l.onSuccess(str2, FacebookSdk.c(), str, permissionsPair.b(), permissionsPair.a(), AccessTokenSource.DEVICE_AUTH, null, null);
this.q.dismiss();
}
/* JADX INFO: Access modifiers changed from: private */
public void a(FacebookException facebookException) {
if (this.m.compareAndSet(false, true)) {
if (this.p != null) {
DeviceRequestsHelper.a(this.p.getUserCode());
}
this.l.onError(facebookException);
this.q.dismiss();
}
}
}