package com.google.android.gms.auth.api.signin; import android.accounts.Account; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import androidx.collection.ArraySet; import com.google.android.gms.common.api.Scope; import com.google.android.gms.common.internal.AccountType; import com.google.android.gms.common.internal.Preconditions; import com.google.android.gms.common.internal.ReflectedParcelable; import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable; import com.google.android.gms.common.internal.safeparcel.SafeParcelWriter; import com.google.android.gms.common.util.Clock; import com.google.android.gms.common.util.DefaultClock; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* JADX INFO: compiled from: com.google.android.gms:play-services-base@@18.4.0 */ /* JADX INFO: loaded from: classes2.dex */ @Deprecated public class GoogleSignInAccount extends AbstractSafeParcelable implements ReflectedParcelable { public static final Parcelable.Creator CREATOR = new zab(); public static final Clock zaa = DefaultClock.getInstance(); final int zab; final List zac; private final String zad; private final String zae; private final String zaf; private final String zag; private final Uri zah; private String zai; private final long zaj; private final String zak; private final String zal; private final String zam; private final Set zan = new HashSet(); GoogleSignInAccount(int i, String str, String str2, String str3, String str4, Uri uri, String str5, long j, String str6, List list, String str7, String str8) { this.zab = i; this.zad = str; this.zae = str2; this.zaf = str3; this.zag = str4; this.zah = uri; this.zai = str5; this.zaj = j; this.zak = str6; this.zac = list; this.zal = str7; this.zam = str8; } public static GoogleSignInAccount createDefault() { return zae(new Account("<>", AccountType.GOOGLE), new HashSet()); } public static GoogleSignInAccount fromAccount(Account account) { return zae(account, new ArraySet()); } public static GoogleSignInAccount fromAccountAndScopes(Account account, Scope scope, Scope... scopeArr) { Preconditions.checkNotNull(account); Preconditions.checkNotNull(scope); HashSet hashSet = new HashSet(); hashSet.add(scope); hashSet.addAll(Arrays.asList(scopeArr)); return zae(account, hashSet); } public static GoogleSignInAccount zaa(String str, String str2, String str3, String str4, String str5, String str6, Uri uri, Long l, String str7, Set set) { return new GoogleSignInAccount(3, str, str2, str3, str4, uri, null, l.longValue(), Preconditions.checkNotEmpty(str7), new ArrayList((Collection) Preconditions.checkNotNull(set)), str5, str6); } public static GoogleSignInAccount zab(String str) throws JSONException { if (TextUtils.isEmpty(str)) { return null; } JSONObject jSONObject = new JSONObject(str); String strOptString = jSONObject.optString("photoUrl"); Uri uri = !TextUtils.isEmpty(strOptString) ? Uri.parse(strOptString) : null; long j = Long.parseLong(jSONObject.getString("expirationTime")); HashSet hashSet = new HashSet(); JSONArray jSONArray = jSONObject.getJSONArray("grantedScopes"); int length = jSONArray.length(); for (int i = 0; i < length; i++) { hashSet.add(new Scope(jSONArray.getString(i))); } GoogleSignInAccount googleSignInAccountZaa = zaa(jSONObject.optString("id"), jSONObject.has("tokenId") ? jSONObject.optString("tokenId") : null, jSONObject.has("email") ? jSONObject.optString("email") : null, jSONObject.has("displayName") ? jSONObject.optString("displayName") : null, jSONObject.has("givenName") ? jSONObject.optString("givenName") : null, jSONObject.has("familyName") ? jSONObject.optString("familyName") : null, uri, Long.valueOf(j), jSONObject.getString("obfuscatedIdentifier"), hashSet); googleSignInAccountZaa.zai = jSONObject.has("serverAuthCode") ? jSONObject.optString("serverAuthCode") : null; return googleSignInAccountZaa; } private static GoogleSignInAccount zae(Account account, Set set) { return zaa(null, null, account.name, null, null, null, null, 0L, account.name, set); } public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof GoogleSignInAccount)) { return false; } GoogleSignInAccount googleSignInAccount = (GoogleSignInAccount) obj; return googleSignInAccount.zak.equals(this.zak) && googleSignInAccount.getRequestedScopes().equals(getRequestedScopes()); } public Account getAccount() { String str = this.zaf; if (str == null) { return null; } return new Account(str, AccountType.GOOGLE); } public String getDisplayName() { return this.zag; } public String getEmail() { return this.zaf; } public String getFamilyName() { return this.zam; } public String getGivenName() { return this.zal; } public Set getGrantedScopes() { return new HashSet(this.zac); } public String getId() { return this.zad; } public String getIdToken() { return this.zae; } public Uri getPhotoUrl() { return this.zah; } public Set getRequestedScopes() { HashSet hashSet = new HashSet(this.zac); hashSet.addAll(this.zan); return hashSet; } public String getServerAuthCode() { return this.zai; } public int hashCode() { return ((this.zak.hashCode() + 527) * 31) + getRequestedScopes().hashCode(); } public boolean isExpired() { return zaa.currentTimeMillis() / 1000 >= this.zaj + (-300); } public GoogleSignInAccount requestExtraScopes(Scope... scopeArr) { if (scopeArr != null) { Collections.addAll(this.zan, scopeArr); } return this; } @Override // android.os.Parcelable public void writeToParcel(Parcel parcel, int i) { int iBeginObjectHeader = SafeParcelWriter.beginObjectHeader(parcel); SafeParcelWriter.writeInt(parcel, 1, this.zab); SafeParcelWriter.writeString(parcel, 2, getId(), false); SafeParcelWriter.writeString(parcel, 3, getIdToken(), false); SafeParcelWriter.writeString(parcel, 4, getEmail(), false); SafeParcelWriter.writeString(parcel, 5, getDisplayName(), false); SafeParcelWriter.writeParcelable(parcel, 6, getPhotoUrl(), i, false); SafeParcelWriter.writeString(parcel, 7, getServerAuthCode(), false); SafeParcelWriter.writeLong(parcel, 8, this.zaj); SafeParcelWriter.writeString(parcel, 9, this.zak, false); SafeParcelWriter.writeTypedList(parcel, 10, this.zac, false); SafeParcelWriter.writeString(parcel, 11, getGivenName(), false); SafeParcelWriter.writeString(parcel, 12, getFamilyName(), false); SafeParcelWriter.finishObjectHeader(parcel, iBeginObjectHeader); } public final String zac() { return this.zak; } public final String zad() { JSONObject jSONObject = new JSONObject(); try { if (getId() != null) { jSONObject.put("id", getId()); } if (getIdToken() != null) { jSONObject.put("tokenId", getIdToken()); } if (getEmail() != null) { jSONObject.put("email", getEmail()); } if (getDisplayName() != null) { jSONObject.put("displayName", getDisplayName()); } if (getGivenName() != null) { jSONObject.put("givenName", getGivenName()); } if (getFamilyName() != null) { jSONObject.put("familyName", getFamilyName()); } Uri photoUrl = getPhotoUrl(); if (photoUrl != null) { jSONObject.put("photoUrl", photoUrl.toString()); } if (getServerAuthCode() != null) { jSONObject.put("serverAuthCode", getServerAuthCode()); } jSONObject.put("expirationTime", this.zaj); jSONObject.put("obfuscatedIdentifier", this.zak); JSONArray jSONArray = new JSONArray(); List list = this.zac; Scope[] scopeArr = (Scope[]) list.toArray(new Scope[list.size()]); Arrays.sort(scopeArr, new Comparator() { // from class: com.google.android.gms.auth.api.signin.zaa @Override // java.util.Comparator public final int compare(Object obj, Object obj2) { Parcelable.Creator creator = GoogleSignInAccount.CREATOR; return ((Scope) obj).getScopeUri().compareTo(((Scope) obj2).getScopeUri()); } }); for (Scope scope : scopeArr) { jSONArray.put(scope.getScopeUri()); } jSONObject.put("grantedScopes", jSONArray); jSONObject.remove("serverAuthCode"); return jSONObject.toString(); } catch (JSONException e) { throw new RuntimeException(e); } } }