package com.google.android.gms.auth.api.signin;

import X.AnonymousClass9AP;
import X.C36088vf;
import X.C36158vm;
import X.C408197w;
import X.R6J;
import android.accounts.Account;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import com.bytedance.covode.number.Covode;
import com.google.android.gms.common.api.Scope;
import com.google.android.gms.common.internal.ReflectedParcelable;
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class GoogleSignInAccount extends AbstractSafeParcelable implements ReflectedParcelable {
    public static final Parcelable.Creator<GoogleSignInAccount> CREATOR = new C36158vm();
    public static R6J LIZ = AnonymousClass9AP.LIZ;
    public String LIZIZ;
    public String LIZJ;
    public String LIZLLL;
    public String LJ;
    public Uri LJFF;
    public String LJI;
    public String LJII;
    public String LJIIIIZZ;
    public String LJIIIZ;
    public final int LJIIJ;
    public long LJIIJJI;
    public List<Scope> LJIIL;
    public Set<Scope> LJIILIIL = new HashSet();

    public final Account LIZ() {
        if (this.LIZLLL == null) {
            return null;
        }
        return new Account(this.LIZLLL, "com.google");
    }

    public final Set<Scope> LIZIZ() {
        HashSet hashSet = new HashSet(this.LJIIL);
        hashSet.addAll(this.LJIILIIL);
        return hashSet;
    }

    static {
        Covode.recordClassIndex(42500);
    }

    public int hashCode() {
        return ((this.LJII.hashCode() + 527) * 31) + LIZIZ().hashCode();
    }

    public final JSONObject LIZJ() {
        JSONObject jSONObject = new JSONObject();
        try {
            String str = this.LIZIZ;
            if (str != null) {
                jSONObject.put("id", str);
            }
            String str2 = this.LIZJ;
            if (str2 != null) {
                jSONObject.put("tokenId", str2);
            }
            String str3 = this.LIZLLL;
            if (str3 != null) {
                jSONObject.put("email", str3);
            }
            String str4 = this.LJ;
            if (str4 != null) {
                jSONObject.put("displayName", str4);
            }
            String str5 = this.LJIIIIZZ;
            if (str5 != null) {
                jSONObject.put("givenName", str5);
            }
            String str6 = this.LJIIIZ;
            if (str6 != null) {
                jSONObject.put("familyName", str6);
            }
            Uri uri = this.LJFF;
            if (uri != null) {
                jSONObject.put("photoUrl", uri.toString());
            }
            String str7 = this.LJI;
            if (str7 != null) {
                jSONObject.put("serverAuthCode", str7);
            }
            jSONObject.put("expirationTime", this.LJIIJJI);
            jSONObject.put("obfuscatedIdentifier", this.LJII);
            JSONArray jSONArray = new JSONArray();
            List<Scope> list = this.LJIIL;
            Scope[] scopeArr = (Scope[]) list.toArray(new Scope[list.size()]);
            Arrays.sort(scopeArr, C408197w.LIZ);
            for (Scope scope : scopeArr) {
                jSONArray.put(scope.LIZ);
            }
            jSONObject.put("grantedScopes", jSONArray);
            return jSONObject;
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
    }

    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof GoogleSignInAccount)) {
            return false;
        }
        GoogleSignInAccount googleSignInAccount = (GoogleSignInAccount) obj;
        if (!googleSignInAccount.LJII.equals(this.LJII) || !googleSignInAccount.LIZIZ().equals(LIZIZ())) {
            return false;
        }
        return true;
    }

    public void writeToParcel(Parcel parcel, int i) {
        int LIZ2 = C36088vf.LIZ(parcel, 20293);
        C36088vf.LIZIZ(parcel, 1, this.LJIIJ);
        C36088vf.LIZ(parcel, 2, this.LIZIZ);
        C36088vf.LIZ(parcel, 3, this.LIZJ);
        C36088vf.LIZ(parcel, 4, this.LIZLLL);
        C36088vf.LIZ(parcel, 5, this.LJ);
        C36088vf.LIZ(parcel, 6, (Parcelable) this.LJFF, i);
        C36088vf.LIZ(parcel, 7, this.LJI);
        C36088vf.LIZ(parcel, 8, this.LJIIJJI);
        C36088vf.LIZ(parcel, 9, this.LJII);
        C36088vf.LIZIZ(parcel, 10, this.LJIIL);
        C36088vf.LIZ(parcel, 11, this.LJIIIIZZ);
        C36088vf.LIZ(parcel, 12, this.LJIIIZ);
        C36088vf.LIZIZ(parcel, LIZ2);
    }

    public GoogleSignInAccount(int i, String str, String str2, String str3, String str4, Uri uri, String str5, long j, String str6, List<Scope> list, String str7, String str8) {
        this.LJIIJ = i;
        this.LIZIZ = str;
        this.LIZJ = str2;
        this.LIZLLL = str3;
        this.LJ = str4;
        this.LJFF = uri;
        this.LJI = str5;
        this.LJIIJJI = j;
        this.LJII = str6;
        this.LJIIL = list;
        this.LJIIIIZZ = str7;
        this.LJIIIZ = str8;
    }
}
