2021-12-17 21:59:34 +00:00
|
|
|
package b.i.a.f.c.a.f.b;
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
import android.accounts.Account;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import androidx.annotation.Nullable;
|
2021-08-09 22:51:56 +00:00
|
|
|
import androidx.core.app.NotificationCompat;
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.i.a.f.c.a.f.c;
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
|
|
|
|
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
|
|
|
|
import com.google.android.gms.common.api.Scope;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
import org.json.JSONArray;
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
/* compiled from: com.google.android.gms:play-services-base@@17.3.0 */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
public class a {
|
|
|
|
public static final Lock a = new ReentrantLock();
|
|
|
|
@Nullable
|
|
|
|
|
2021-12-17 21:59:34 +00:00
|
|
|
/* renamed from: b reason: collision with root package name */
|
2022-01-27 07:52:47 +00:00
|
|
|
public static a f1332b;
|
2021-12-17 21:59:34 +00:00
|
|
|
public final Lock c = new ReentrantLock();
|
2021-08-03 07:33:18 +00:00
|
|
|
public final SharedPreferences d;
|
|
|
|
|
|
|
|
public a(Context context) {
|
|
|
|
this.d = context.getSharedPreferences("com.google.android.gms.signin", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static a a(Context context) {
|
|
|
|
Objects.requireNonNull(context, "null reference");
|
|
|
|
Lock lock = a;
|
|
|
|
lock.lock();
|
|
|
|
try {
|
2022-01-27 07:52:47 +00:00
|
|
|
if (f1332b == null) {
|
|
|
|
f1332b = new a(context.getApplicationContext());
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2022-01-27 07:52:47 +00:00
|
|
|
a aVar = f1332b;
|
2021-08-03 07:33:18 +00:00
|
|
|
lock.unlock();
|
|
|
|
return aVar;
|
|
|
|
} catch (Throwable th) {
|
|
|
|
a.unlock();
|
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String f(String str, String str2) {
|
2021-12-17 21:59:34 +00:00
|
|
|
return b.d.b.a.a.j(b.d.b.a.a.b(str2, str.length() + 1), str, ":", str2);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public GoogleSignInAccount b() {
|
|
|
|
String g;
|
|
|
|
String g2 = g("defaultGoogleSignInAccount");
|
|
|
|
if (TextUtils.isEmpty(g2) || (g = g(f("googleSignInAccount", g2))) == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
try {
|
2021-11-05 06:48:17 +00:00
|
|
|
return GoogleSignInAccount.x0(g);
|
2021-08-03 07:33:18 +00:00
|
|
|
} catch (JSONException unused) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public GoogleSignInOptions c() {
|
|
|
|
String g;
|
|
|
|
String g2 = g("defaultGoogleSignInAccount");
|
|
|
|
if (TextUtils.isEmpty(g2) || (g = g(f("googleSignInOptions", g2))) == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
try {
|
2021-11-05 06:48:17 +00:00
|
|
|
return GoogleSignInOptions.x0(g);
|
2021-08-03 07:33:18 +00:00
|
|
|
} catch (JSONException unused) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void d(GoogleSignInAccount googleSignInAccount, GoogleSignInOptions googleSignInOptions) {
|
|
|
|
Objects.requireNonNull(googleSignInAccount, "null reference");
|
|
|
|
Objects.requireNonNull(googleSignInOptions, "null reference");
|
2021-12-02 18:53:44 +00:00
|
|
|
e("defaultGoogleSignInAccount", googleSignInAccount.r);
|
|
|
|
String str = googleSignInAccount.r;
|
2021-08-03 07:33:18 +00:00
|
|
|
String f = f("googleSignInAccount", str);
|
|
|
|
JSONObject jSONObject = new JSONObject();
|
|
|
|
try {
|
2021-12-02 18:53:44 +00:00
|
|
|
String str2 = googleSignInAccount.k;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (str2 != null) {
|
2021-08-09 22:51:56 +00:00
|
|
|
jSONObject.put(ModelAuditLogEntry.CHANGE_KEY_ID, str2);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
String str3 = googleSignInAccount.l;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (str3 != null) {
|
|
|
|
jSONObject.put("tokenId", str3);
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
String str4 = googleSignInAccount.m;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (str4 != null) {
|
2021-08-09 22:51:56 +00:00
|
|
|
jSONObject.put(NotificationCompat.CATEGORY_EMAIL, str4);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
String str5 = googleSignInAccount.n;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (str5 != null) {
|
|
|
|
jSONObject.put("displayName", str5);
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
String str6 = googleSignInAccount.t;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (str6 != null) {
|
|
|
|
jSONObject.put("givenName", str6);
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
String str7 = googleSignInAccount.u;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (str7 != null) {
|
|
|
|
jSONObject.put("familyName", str7);
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
Uri uri = googleSignInAccount.o;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (uri != null) {
|
|
|
|
jSONObject.put("photoUrl", uri.toString());
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
String str8 = googleSignInAccount.p;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (str8 != null) {
|
|
|
|
jSONObject.put("serverAuthCode", str8);
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
jSONObject.put("expirationTime", googleSignInAccount.q);
|
|
|
|
jSONObject.put("obfuscatedIdentifier", googleSignInAccount.r);
|
2021-08-03 07:33:18 +00:00
|
|
|
JSONArray jSONArray = new JSONArray();
|
2022-03-11 01:19:06 +00:00
|
|
|
List<Scope> list = googleSignInAccount.f2969s;
|
2021-08-03 07:33:18 +00:00
|
|
|
Scope[] scopeArr = (Scope[]) list.toArray(new Scope[list.size()]);
|
2021-12-02 18:53:44 +00:00
|
|
|
Arrays.sort(scopeArr, c.j);
|
2021-08-03 07:33:18 +00:00
|
|
|
int i = 0;
|
|
|
|
for (Scope scope : scopeArr) {
|
2021-12-02 18:53:44 +00:00
|
|
|
jSONArray.put(scope.k);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
jSONObject.put("grantedScopes", jSONArray);
|
|
|
|
jSONObject.remove("serverAuthCode");
|
|
|
|
e(f, jSONObject.toString());
|
|
|
|
String f2 = f("googleSignInOptions", str);
|
|
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
|
|
try {
|
|
|
|
JSONArray jSONArray2 = new JSONArray();
|
2021-12-02 18:53:44 +00:00
|
|
|
Collections.sort(googleSignInOptions.q, GoogleSignInOptions.o);
|
|
|
|
ArrayList<Scope> arrayList = googleSignInOptions.q;
|
2021-08-03 07:33:18 +00:00
|
|
|
int size = arrayList.size();
|
|
|
|
while (i < size) {
|
|
|
|
Scope scope2 = arrayList.get(i);
|
|
|
|
i++;
|
2021-12-02 18:53:44 +00:00
|
|
|
jSONArray2.put(scope2.k);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
jSONObject2.put("scopes", jSONArray2);
|
2021-12-02 18:53:44 +00:00
|
|
|
Account account = googleSignInOptions.r;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (account != null) {
|
|
|
|
jSONObject2.put("accountName", account.name);
|
|
|
|
}
|
2022-03-11 01:19:06 +00:00
|
|
|
jSONObject2.put("idTokenRequested", googleSignInOptions.f2970s);
|
2021-12-02 18:53:44 +00:00
|
|
|
jSONObject2.put("forceCodeForRefreshToken", googleSignInOptions.u);
|
|
|
|
jSONObject2.put("serverAuthRequested", googleSignInOptions.t);
|
2021-08-03 07:33:18 +00:00
|
|
|
if (!TextUtils.isEmpty(googleSignInOptions.v)) {
|
2021-12-02 18:53:44 +00:00
|
|
|
jSONObject2.put("serverClientId", googleSignInOptions.v);
|
|
|
|
}
|
|
|
|
if (!TextUtils.isEmpty(googleSignInOptions.w)) {
|
|
|
|
jSONObject2.put("hostedDomain", googleSignInOptions.w);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
e(f2, jSONObject2.toString());
|
|
|
|
} catch (JSONException e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
} catch (JSONException e2) {
|
|
|
|
throw new RuntimeException(e2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void e(String str, String str2) {
|
2021-12-17 21:59:34 +00:00
|
|
|
this.c.lock();
|
2021-08-03 07:33:18 +00:00
|
|
|
try {
|
|
|
|
this.d.edit().putString(str, str2).apply();
|
|
|
|
} finally {
|
2021-12-17 21:59:34 +00:00
|
|
|
this.c.unlock();
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public final String g(String str) {
|
2021-12-17 21:59:34 +00:00
|
|
|
this.c.lock();
|
2021-08-03 07:33:18 +00:00
|
|
|
try {
|
|
|
|
return this.d.getString(str, null);
|
|
|
|
} finally {
|
2021-12-17 21:59:34 +00:00
|
|
|
this.c.unlock();
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|