TikTok.apk(点击下载) / C20320rN.java


package X;

import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.google.gson.Gson;
import com.google.gson.a.c;
import com.ss.android.ugc.aweme.profile.UserResponse;
import com.ss.android.ugc.aweme.profile.model.User;
import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.json.JSONException;
import org.json.JSONObject;

/* renamed from: X.0rN  reason: invalid class name and case insensitive filesystem */
public final class C20320rN {
    public static final String LIZ = "https://api-va.tiktokv.com/aweme/v1/commit/user/";
    public static final String LIZIZ = "https://api-va.tiktokv.com/passport/login_name/update/";

    static {
        Covode.recordClassIndex(109008);
    }

    public static UserResponse LIZ(Map<String, String> map) {
        UserResponse userResponse;
        User user;
        String str = LIZ;
        if (map.containsKey("mt_update_username")) {
            str = LIZIZ;
            map.remove("mt_update_username");
        }
        HashMap hashMap = new HashMap();
        hashMap.put("uid", AnonymousClass1GW.LJIIJ.LJ());
        hashMap.putAll(map);
        String LIZIZ2 = !str.equals(LIZIZ) ? C15570ji.LIZIZ.LIZIZ(str, hashMap) : C15570ji.LIZIZ.LIZ(str, hashMap);
        User LIZ2 = AnonymousClass1GW.LJIIJ.LIZ();
        if (LIZ(LIZ2, map, LIZIZ2)) {
            userResponse = new UserResponse();
            user = LIZ2.clone();
            userResponse.setUser(user);
        } else {
            userResponse = (UserResponse) C15570ji.LIZIZ.LIZ().fromJson(LIZIZ2, UserResponse.class);
            user = userResponse.getUser();
            HashSet hashSet = new HashSet(map.keySet());
            if (hashSet.contains("avatar_uri") || hashSet.contains("video_icon_virtual_URI")) {
                hashSet.remove("avatar_uri");
                hashSet.remove("video_icon_virtual_URI");
                hashSet.add("avatar_larger");
                hashSet.add("avatar_thumb");
                hashSet.add("avatar_medium");
                hashSet.add("video_icon");
            }
            LIZ(LIZ2, user, hashSet);
        }
        if (!(LIZ2 == null || user == null || (!TextUtils.isEmpty(LIZ2.getUid()) && !TextUtils.isEmpty(user.getUid())))) {
            C68742nH.LIZ("aweme_user_manager_null_uid", new C12720f7().LIZ("local_user_json", new Gson().toJson(LIZ2)).LIZ("server_user_json", new Gson().toJson(user)).LIZ("map", map.toString()).LIZ());
        }
        return userResponse;
    }

    public static User LIZ(String str, boolean z) {
        C11460d5 r2 = new C11460d5(str);
        r2.LIZ("is_after_login", z ? "1" : "0");
        return ((UserResponse) C15570ji.LIZIZ.LIZ().fromJson(C15570ji.LIZIZ.LIZ(r2.toString()), UserResponse.class)).getUser();
    }

    public static void LIZ(User user, User user2, Set<String> set) {
        if (!(user == null || TextUtils.isEmpty(user.getUid()))) {
            Field[] declaredFields = User.class.getDeclaredFields();
            for (Field field : declaredFields) {
                c cVar = (c) field.getAnnotation(c.class);
                if (cVar != null && !set.contains(cVar.LIZ())) {
                    try {
                        field.setAccessible(true);
                        field.set(user2, field.get(user));
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    public static boolean LIZ(User user, Map<String, String> map, String str) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (!map.containsKey("login_name")) {
                return false;
            }
            if (TextUtils.equals(jSONObject.optString("message").toLowerCase(), "success")) {
                map.put("unique_id", map.get("login_name"));
                map.remove("login_name");
                user.setUniqueId(jSONObject.getJSONObject("data").getString("login_name"));
                user.setHandleModified(new Date().getTime() / 1000);
                return true;
            } else if (!TextUtils.equals(jSONObject.optString("message").toLowerCase(), "error")) {
                return false;
            } else {
                throw new AnonymousClass1D8(jSONObject.getJSONObject("data").optInt("error_code")).setErrorMsg(jSONObject.getJSONObject("data").optString("description"));
            }
        } catch (JSONException unused) {
            return false;
        }
    }
}