Initial commit
This commit is contained in:
250
sources/com/facebook/login/CustomTabLoginMethodHandler.java
Normal file
250
sources/com/facebook/login/CustomTabLoginMethodHandler.java
Normal file
@@ -0,0 +1,250 @@
|
||||
package com.facebook.login;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import com.facebook.AccessTokenSource;
|
||||
import com.facebook.CustomTabMainActivity;
|
||||
import com.facebook.FacebookOperationCanceledException;
|
||||
import com.facebook.FacebookSdk;
|
||||
import com.facebook.internal.FetchedAppSettings;
|
||||
import com.facebook.internal.FetchedAppSettingsManager;
|
||||
import com.facebook.internal.Utility;
|
||||
import com.facebook.internal.Validate;
|
||||
import com.facebook.login.LoginClient;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CustomTabLoginMethodHandler extends WebLoginMethodHandler {
|
||||
private static final int API_EC_DIALOG_CANCEL = 4201;
|
||||
private static final int CHALLENGE_LENGTH = 20;
|
||||
private static final String[] CHROME_PACKAGES = {"com.android.chrome", "com.chrome.beta", "com.chrome.dev"};
|
||||
public static final Parcelable.Creator<CustomTabLoginMethodHandler> CREATOR = new Parcelable.Creator() { // from class: com.facebook.login.CustomTabLoginMethodHandler.1
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public CustomTabLoginMethodHandler createFromParcel(Parcel parcel) {
|
||||
return new CustomTabLoginMethodHandler(parcel);
|
||||
}
|
||||
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public CustomTabLoginMethodHandler[] newArray(int i) {
|
||||
return new CustomTabLoginMethodHandler[i];
|
||||
}
|
||||
};
|
||||
private static final String CUSTOM_TABS_SERVICE_ACTION = "android.support.customtabs.action.CustomTabsService";
|
||||
private static final int CUSTOM_TAB_REQUEST_CODE = 1;
|
||||
private String currentPackage;
|
||||
private String expectedChallenge;
|
||||
|
||||
CustomTabLoginMethodHandler(LoginClient loginClient) {
|
||||
super(loginClient);
|
||||
this.expectedChallenge = Utility.a(20);
|
||||
}
|
||||
|
||||
private String getChromePackage() {
|
||||
String str = this.currentPackage;
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
FragmentActivity activity = this.loginClient.getActivity();
|
||||
List<ResolveInfo> queryIntentServices = activity.getPackageManager().queryIntentServices(new Intent(CUSTOM_TABS_SERVICE_ACTION), 0);
|
||||
if (queryIntentServices == null) {
|
||||
return null;
|
||||
}
|
||||
HashSet hashSet = new HashSet(Arrays.asList(CHROME_PACKAGES));
|
||||
Iterator<ResolveInfo> it = queryIntentServices.iterator();
|
||||
while (it.hasNext()) {
|
||||
ServiceInfo serviceInfo = it.next().serviceInfo;
|
||||
if (serviceInfo != null && hashSet.contains(serviceInfo.packageName)) {
|
||||
this.currentPackage = serviceInfo.packageName;
|
||||
return this.currentPackage;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isCustomTabsAllowed() {
|
||||
return isCustomTabsEnabled() && getChromePackage() != null && Validate.b(FacebookSdk.b());
|
||||
}
|
||||
|
||||
private boolean isCustomTabsEnabled() {
|
||||
FetchedAppSettings c = FetchedAppSettingsManager.c(Utility.c(this.loginClient.getActivity()));
|
||||
return c != null && c.b();
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:36:0x009d */
|
||||
/* JADX WARN: Removed duplicated region for block: B:38:0x00a6 */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private void onCustomTabComplete(java.lang.String r7, com.facebook.login.LoginClient.Request r8) {
|
||||
/*
|
||||
r6 = this;
|
||||
if (r7 == 0) goto Lb3
|
||||
java.lang.String r0 = com.facebook.CustomTabMainActivity.a()
|
||||
boolean r0 = r7.startsWith(r0)
|
||||
if (r0 == 0) goto Lb3
|
||||
android.net.Uri r7 = android.net.Uri.parse(r7)
|
||||
java.lang.String r0 = r7.getQuery()
|
||||
android.os.Bundle r0 = com.facebook.internal.Utility.d(r0)
|
||||
java.lang.String r7 = r7.getFragment()
|
||||
android.os.Bundle r7 = com.facebook.internal.Utility.d(r7)
|
||||
r0.putAll(r7)
|
||||
boolean r7 = r6.validateChallengeParam(r0)
|
||||
r1 = 0
|
||||
if (r7 != 0) goto L35
|
||||
com.facebook.FacebookException r7 = new com.facebook.FacebookException
|
||||
java.lang.String r0 = "Invalid state parameter"
|
||||
r7.<init>(r0)
|
||||
super.onComplete(r8, r1, r7)
|
||||
return
|
||||
L35:
|
||||
java.lang.String r7 = "error"
|
||||
java.lang.String r7 = r0.getString(r7)
|
||||
if (r7 != 0) goto L43
|
||||
java.lang.String r7 = "error_type"
|
||||
java.lang.String r7 = r0.getString(r7)
|
||||
L43:
|
||||
java.lang.String r2 = "error_msg"
|
||||
java.lang.String r2 = r0.getString(r2)
|
||||
if (r2 != 0) goto L51
|
||||
java.lang.String r2 = "error_message"
|
||||
java.lang.String r2 = r0.getString(r2)
|
||||
L51:
|
||||
if (r2 != 0) goto L59
|
||||
java.lang.String r2 = "error_description"
|
||||
java.lang.String r2 = r0.getString(r2)
|
||||
L59:
|
||||
java.lang.String r3 = "error_code"
|
||||
java.lang.String r3 = r0.getString(r3)
|
||||
boolean r4 = com.facebook.internal.Utility.c(r3)
|
||||
r5 = -1
|
||||
if (r4 != 0) goto L6b
|
||||
int r3 = java.lang.Integer.parseInt(r3) // Catch: java.lang.NumberFormatException -> L6b
|
||||
goto L6c
|
||||
L6b:
|
||||
r3 = -1
|
||||
L6c:
|
||||
boolean r4 = com.facebook.internal.Utility.c(r7)
|
||||
if (r4 == 0) goto L7e
|
||||
boolean r4 = com.facebook.internal.Utility.c(r2)
|
||||
if (r4 == 0) goto L7e
|
||||
if (r3 != r5) goto L7e
|
||||
super.onComplete(r8, r0, r1)
|
||||
goto Lb3
|
||||
L7e:
|
||||
if (r7 == 0) goto L99
|
||||
java.lang.String r0 = "access_denied"
|
||||
boolean r0 = r7.equals(r0)
|
||||
if (r0 != 0) goto L90
|
||||
java.lang.String r0 = "OAuthAccessDeniedException"
|
||||
boolean r0 = r7.equals(r0)
|
||||
if (r0 == 0) goto L99
|
||||
L90:
|
||||
com.facebook.FacebookOperationCanceledException r7 = new com.facebook.FacebookOperationCanceledException
|
||||
r7.<init>()
|
||||
super.onComplete(r8, r1, r7)
|
||||
goto Lb3
|
||||
L99:
|
||||
r0 = 4201(0x1069, float:5.887E-42)
|
||||
if (r3 != r0) goto La6
|
||||
com.facebook.FacebookOperationCanceledException r7 = new com.facebook.FacebookOperationCanceledException
|
||||
r7.<init>()
|
||||
super.onComplete(r8, r1, r7)
|
||||
goto Lb3
|
||||
La6:
|
||||
com.facebook.FacebookRequestError r0 = new com.facebook.FacebookRequestError
|
||||
r0.<init>(r3, r7, r2)
|
||||
com.facebook.FacebookServiceException r7 = new com.facebook.FacebookServiceException
|
||||
r7.<init>(r0, r2)
|
||||
super.onComplete(r8, r1, r7)
|
||||
Lb3:
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.facebook.login.CustomTabLoginMethodHandler.onCustomTabComplete(java.lang.String, com.facebook.login.LoginClient$Request):void");
|
||||
}
|
||||
|
||||
private boolean validateChallengeParam(Bundle bundle) {
|
||||
try {
|
||||
String string = bundle.getString("state");
|
||||
if (string == null) {
|
||||
return false;
|
||||
}
|
||||
return new JSONObject(string).getString("7_challenge").equals(this.expectedChallenge);
|
||||
} catch (JSONException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.os.Parcelable
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // com.facebook.login.LoginMethodHandler
|
||||
String getNameForLogging() {
|
||||
return "custom_tab";
|
||||
}
|
||||
|
||||
@Override // com.facebook.login.WebLoginMethodHandler
|
||||
protected String getSSODevice() {
|
||||
return "chrome_custom_tab";
|
||||
}
|
||||
|
||||
@Override // com.facebook.login.WebLoginMethodHandler
|
||||
AccessTokenSource getTokenSource() {
|
||||
return AccessTokenSource.CHROME_CUSTOM_TAB;
|
||||
}
|
||||
|
||||
@Override // com.facebook.login.LoginMethodHandler
|
||||
boolean onActivityResult(int i, int i2, Intent intent) {
|
||||
if (i != 1) {
|
||||
return super.onActivityResult(i, i2, intent);
|
||||
}
|
||||
LoginClient.Request pendingRequest = this.loginClient.getPendingRequest();
|
||||
if (i2 == -1) {
|
||||
onCustomTabComplete(intent.getStringExtra(CustomTabMainActivity.e), pendingRequest);
|
||||
return true;
|
||||
}
|
||||
super.onComplete(pendingRequest, null, new FacebookOperationCanceledException());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.facebook.login.LoginMethodHandler
|
||||
protected void putChallengeParam(JSONObject jSONObject) throws JSONException {
|
||||
jSONObject.put("7_challenge", this.expectedChallenge);
|
||||
}
|
||||
|
||||
@Override // com.facebook.login.LoginMethodHandler
|
||||
boolean tryAuthorize(LoginClient.Request request) {
|
||||
if (!isCustomTabsAllowed()) {
|
||||
return false;
|
||||
}
|
||||
Bundle addExtraParameters = addExtraParameters(getParameters(request), request);
|
||||
Intent intent = new Intent(this.loginClient.getActivity(), (Class<?>) CustomTabMainActivity.class);
|
||||
intent.putExtra(CustomTabMainActivity.c, addExtraParameters);
|
||||
intent.putExtra(CustomTabMainActivity.d, getChromePackage());
|
||||
this.loginClient.getFragment().startActivityForResult(intent, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.facebook.login.LoginMethodHandler, android.os.Parcelable
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
super.writeToParcel(parcel, i);
|
||||
parcel.writeString(this.expectedChallenge);
|
||||
}
|
||||
|
||||
CustomTabLoginMethodHandler(Parcel parcel) {
|
||||
super(parcel);
|
||||
this.expectedChallenge = parcel.readString();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user