导航菜单

页面标题

页面副标题

Fancy Optimizer v4.6.3 - PushUpdateUserInfoPeriodicWorker.java 源代码

正在查看: Fancy Optimizer v4.6.3 应用的 PushUpdateUserInfoPeriodicWorker.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.thinkyeah.common.push.work;

import android.content.Context;
import android.text.TextUtils;
import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.work.ListenableWorker;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import com.fancyclean.boost.application.MainApplication;
import com.fancyclean.boost.main.ui.activity.ChooseLanguageActivity;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.firebase.perf.network.FirebasePerfOkHttpClient;
import com.unity3d.services.core.device.reader.JsonStorageKeyNames;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
import kk.b;
import kk.d;
import mk.a;
import ml.o;
import no.MediaType;
import no.RequestBody;
import no.u;
import no.w;
import no.x;
import no.y;
import org.json.JSONException;
import org.json.JSONObject;
import vj.e;
import vj.h;

public class PushUpdateUserInfoPeriodicWorker extends Worker {
    public static final h c = new h("PushUpdateUserInfoPeriodicWorker");
    public static final AtomicInteger d = new AtomicInteger(0);

    public PushUpdateUserInfoPeriodicWorker(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
        super(context, workerParameters);
    }

    public static ListenableWorker.Result a() {
        AtomicInteger atomicInteger = d;
        if (atomicInteger.get() >= 3) {
            atomicInteger.set(0);
            return ListenableWorker.Result.failure();
        }
        atomicInteger.incrementAndGet();
        c.d("retry doWork: " + atomicInteger.get() + " time", null);
        return ListenableWorker.Result.retry();
    }

    @NonNull
    public final ListenableWorker.Result doWork() {
        String str;
        AdvertisingIdClient.Info info;
        boolean z;
        Pair create;
        Pair a;
        JSONObject optJSONObject;
        Pair create2;
        AdvertisingIdClient.Info info2;
        boolean z2 = false;
        boolean z3 = d.g != null;
        h hVar = c;
        if (!z3) {
            hVar.d("PushManager is not initialized, skip the push token register doWork", null);
            return ListenableWorker.Result.failure();
        }
        d c2 = d.c(getApplicationContext());
        c2.getClass();
        h hVar2 = d.e;
        hVar2.c("==> updatePushUserProperties");
        Context context = c2.d;
        ArrayList a2 = b.a(context);
        if (a2.size() > 0) {
            hVar2.c("Unsubscribe last failed topic, size: " + a2.size());
            Iterator it = a2.iterator();
            while (it.hasNext()) {
                String str2 = (String) it.next();
                if (!TextUtils.isEmpty(str2)) {
                    c2.h(str2);
                }
            }
            b.c(context, "");
        }
        f5.b bVar = d.g;
        c2.d(bVar != null && pl.h.b(bVar.a).c());
        String lowerCase = ml.b.h(context).toLowerCase();
        String c3 = a.c(context, lowerCase);
        String lowerCase2 = Locale.getDefault().getLanguage().trim().toLowerCase();
        d.c(context).getClass();
        d.g.getClass();
        String[] strArr = ChooseLanguageActivity.n;
        if (Arrays.asList(strArr).subList(1, strArr.length).contains(lowerCase2)) {
            str = android.support.v4.media.b.C(lowerCase2, "_", lowerCase);
        } else {
            lowerCase2 = "misc";
            str = "misc";
        }
        if (lowerCase2.startsWith("zh")) {
            str = o.b(ml.d.c().getLanguage() + "_" + ml.d.c().getCountry());
            lowerCase2 = str;
        }
        StringBuilder q = android.support.v4.media.b.q("refreshLanguageRegionLocaleTopics. Original Region: ", lowerCase, ", Region: ", c3, ", lan: ");
        q.append(lowerCase2);
        q.append(", locale:");
        q.append(str);
        hVar2.c(q.toString());
        String l = android.support.v4.media.b.l("region_", c3);
        e eVar = b.a;
        String f = eVar.f(context, "dc_region", "");
        hVar2.c("regionTopic: " + l + ", oldRegionTopic:" + f);
        if (!TextUtils.isEmpty(f) && !l.equals(f)) {
            c2.h(f);
        }
        c2.g(l);
        eVar.k(context, "dc_region", l);
        String str3 = "lang_" + lowerCase2;
        String f2 = eVar.f(context, "dc_language", "");
        hVar2.c("languageTopic: " + str3 + ", oldLanguageTopic:" + f2);
        if (!TextUtils.isEmpty(f2) && !str3.equals(f2)) {
            c2.h(f2);
        }
        c2.g(str3);
        eVar.k(context, "dc_language", str3);
        String str4 = "locale_id_" + str;
        String f3 = eVar.f(context, "dc_locale", "");
        hVar2.c("localeTopic: " + str4 + ", oldLocaleTopic:" + f3);
        if (!TextUtils.isEmpty(f3) && !str4.equals(f3)) {
            c2.h(f3);
        }
        c2.g(str4);
        eVar.k(context, "dc_locale", str4);
        hVar2.c("refreshTimezoneTopics");
        String d2 = a.d();
        String f4 = eVar.f(context, "dc_timezone", "");
        hVar2.c("timezoneTopic: " + d2 + ", oldTimezoneTopic:" + f4);
        if (!TextUtils.isEmpty(f4) && !d2.equals(f4)) {
            c2.h(f4);
        }
        c2.g(d2);
        eVar.k(context, "dc_timezone", d2);
        Context applicationContext = getApplicationContext();
        String f5 = eVar.f(applicationContext, "firebase_token", null);
        if (f5 == null || f5.isEmpty()) {
            hVar.d("token == null", null);
            return ListenableWorker.Result.failure();
        }
        if (lk.b.c == null) {
            synchronized (lk.b.class) {
                if (lk.b.c == null) {
                    lk.b.c = new lk.b(applicationContext);
                }
            }
        }
        lk.b bVar2 = lk.b.c;
        bVar2.getClass();
        String concat = "==> requestRegisterUser, token: ".concat(f5);
        h hVar3 = lk.b.b;
        hVar3.c(concat);
        Context context2 = bVar2.a;
        String f6 = eVar.f(context2, "uid", null);
        if (f6 == null || f6.isEmpty()) {
            Boolean bool = Boolean.TRUE;
            d.c(context2).getClass();
            f5.b bVar3 = d.g;
            bVar3.getClass();
            MainApplication mainApplication = bVar3.a;
            h hVar4 = y7.a.a;
            try {
                info = AdvertisingIdClient.getAdvertisingIdInfo(mainApplication);
            } catch (Exception e) {
                y7.a.a.d(null, e);
                info = null;
            }
            String b = o.b(info != null ? info.getId() : null);
            try {
                u uVar = lk.a.a().a;
                x.a aVar = new x.a();
                aVar.d("https://pushapi.thinkyeah.com/api/v1/installation/register");
                aVar.b("POST", RequestBody.create(MediaType.b("application/json; charset=utf-8"), bVar2.e(f5, b).toString()));
                x a3 = aVar.a();
                uVar.getClass();
                y execute = FirebasePerfOkHttpClient.execute(w.c(uVar, a3, false));
                hVar3.c("requestRegisterUser: enter");
                a = lk.b.a(execute);
            } catch (IOException e2) {
                hVar3.d("requestRegisterUser: " + e2.getMessage(), null);
            }
            if (((Boolean) a.first).booleanValue()) {
                try {
                    optJSONObject = new JSONObject((String) a.second).optJSONObject(JsonStorageKeyNames.DATA_KEY);
                } catch (JSONException e3) {
                    hVar3.d("requestRegisterUser: " + e3.getMessage(), null);
                }
                if (optJSONObject != null) {
                    eVar.k(context2, "uid", optJSONObject.optString("uid"));
                    b.a.i(System.currentTimeMillis(), context2, "updated_register_user_info_time");
                    hVar3.c("requestRegisterUser: success");
                    z = true;
                    create = Pair.create(bool, Boolean.valueOf(z));
                }
            }
            z = false;
            create = Pair.create(bool, Boolean.valueOf(z));
        } else {
            Boolean bool2 = Boolean.FALSE;
            create = Pair.create(bool2, bool2);
        }
        if (((Boolean) create.first).booleanValue()) {
            hVar.c("requestRegisterUser has called");
            if (((Boolean) create.second).booleanValue()) {
                hVar.c("requestRegisterUser execute success");
                return ListenableWorker.Result.success();
            }
            hVar.c("requestRegisterUser execute failure");
            return a();
        }
        hVar.c("requestRegisterUser not need execute");
        lk.b b2 = lk.b.b(applicationContext);
        b2.getClass();
        h hVar5 = lk.b.b;
        hVar5.c("requestUpdateUser enter");
        Context context3 = b2.a;
        e eVar2 = b.a;
        String f7 = eVar2.f(context3, "uid", null);
        if (f7 == null || f7.isEmpty()) {
            hVar5.c("uid == null || uid.isEmpty()");
            Boolean bool3 = Boolean.FALSE;
            create2 = Pair.create(bool3, bool3);
        } else {
            long currentTimeMillis = System.currentTimeMillis();
            long e4 = eVar2.e(0L, context3, "updated_register_user_info_time");
            if (e4 == 0 || Math.abs(currentTimeMillis - e4) < 86400000) {
                hVar5.c("lastTime is not need update");
                Boolean bool4 = Boolean.FALSE;
                create2 = Pair.create(bool4, bool4);
            } else {
                Boolean bool5 = Boolean.TRUE;
                d.c(context3).getClass();
                f5.b bVar4 = d.g;
                bVar4.getClass();
                MainApplication mainApplication2 = bVar4.a;
                h hVar6 = y7.a.a;
                try {
                    info2 = AdvertisingIdClient.getAdvertisingIdInfo(mainApplication2);
                } catch (Exception e5) {
                    y7.a.a.d(null, e5);
                    info2 = null;
                }
                JSONObject e6 = b2.e(f5, o.b(info2 == null ? null : info2.getId()));
                try {
                    e6.put("uid", b.a.f(context3, "uid", null));
                } catch (JSONException e7) {
                    hVar5.d("requestUpdateUserInternal: " + e7.getMessage(), null);
                }
                try {
                    u uVar2 = lk.a.a().a;
                    x.a aVar2 = new x.a();
                    aVar2.d("https://pushapi.thinkyeah.com/api/v1/installation/update");
                    aVar2.b("POST", RequestBody.create(MediaType.b("application/json; charset=utf-8"), e6.toString()));
                    x a4 = aVar2.a();
                    uVar2.getClass();
                    y execute2 = FirebasePerfOkHttpClient.execute(w.c(uVar2, a4, false));
                    hVar5.c("requestUpdateUser: enter");
                    if (((Boolean) lk.b.a(execute2).first).booleanValue()) {
                        b.a.i(System.currentTimeMillis(), context3, "updated_register_user_info_time");
                        hVar5.c("requestUpdateUser: success");
                        z2 = true;
                    }
                } catch (IOException e8) {
                    hVar5.d("requestUpdateUser: " + e8.getMessage(), null);
                }
                create2 = Pair.create(bool5, Boolean.valueOf(z2));
            }
        }
        if (!((Boolean) create2.first).booleanValue()) {
            hVar.c("requestUpdateUser not need execute");
            return ListenableWorker.Result.success();
        }
        hVar.c("requestUpdateUser has called");
        if (((Boolean) create2.second).booleanValue()) {
            hVar.c("requestUpdateUser execute success");
            return ListenableWorker.Result.success();
        }
        hVar.c("requestUpdateUser execute failure");
        return a();
    }
}