导航菜单

页面标题

页面副标题

Minits v4.9.3.32 - ReplicatorIntentService.java 源代码

正在查看: Minits v4.9.3.32 应用的 ReplicatorIntentService.java JAVA 源代码文件

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


package com.xone.replicator;

import Na.c;
import Na.i;
import Na.j;
import Na.k;
import Na.l;
import Qa.e;
import android.app.AlarmManager;
import android.app.IntentService;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.PowerManager;
import android.os.SystemClock;
import android.text.TextUtils;
import com.xone.android.utils.Utils;
import com.xone.replicator.helpers.DatabaseFilesHelper;
import fb.AbstractC0698k;
import java.io.File;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Iterator;
import q3.f;
import z0.r;

public final class ReplicatorIntentService extends IntentService {
    public static final CharSequence l = "Replicator notification channel";

    public static class a {
        public static final int[] a;

        static {
            int[] iArr = new int[e.values().length];
            a = iArr;
            try {
                iArr[e.LOCKED.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[e.UNLOCKED.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[e.UNLOCKED_TEMPORARILY_BY_SECURE_PROVISIONING.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    public ReplicatorIntentService() {
        super("ReplicatorIntentService");
    }

    public final PowerManager.WakeLock a() {
        PowerManager.WakeLock newWakeLock = j().newWakeLock(1, getPackageName() + ":##XONEREPLICATORTAG##");
        newWakeLock.setReferenceCounted(false);
        newWakeLock.acquire();
        return newWakeLock;
    }

    public final void b(PendingIntent pendingIntent) {
        try {
            h().cancel(pendingIntent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void c(PowerManager.WakeLock wakeLock) {
        if (wakeLock == null) {
            return;
        }
        try {
            if (wakeLock.isHeld()) {
                wakeLock.release();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void d(long j, PendingIntent pendingIntent) {
        try {
            h().set(2, j, pendingIntent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void e(String str) {
        Context applicationContext = getApplicationContext();
        File[] listFiles = (str == null ? new File(Utils.F1(applicationContext)) : new File(str)).listFiles();
        if (listFiles == null) {
            return;
        }
        for (File file : listFiles) {
            if (!file.isFile()) {
                if (l(file)) {
                    try {
                        Na.a q = Na.a.q(applicationContext, Na.a.t(file));
                        if (q == null) {
                            Na.a.A0(applicationContext, file);
                        } else if (q.o0(file)) {
                            Na.a.j(applicationContext, q);
                            Na.a.A0(applicationContext, file);
                        }
                    } catch (Ra.a unused) {
                        j.a("*** RPL: Replica disabled for application " + file.getName());
                    } catch (Exception e) {
                        j.d("*** Error loading application descriptor for path " + file.getAbsolutePath() + "\n", e);
                    }
                } else if (file.isDirectory()) {
                    e(file.getAbsolutePath());
                }
            }
        }
    }

    public final void f(Na.a aVar, String str) {
        int N = aVar.N();
        try {
            k x = k.x(aVar);
            if (!x.H()) {
                int i = 0;
                if (!m(x, str)) {
                    j.b("Error running replica cycle for application: " + aVar.s());
                    int c = l.c(this, aVar.s(), "com.xone.replicator.common", "error_repeat", 0);
                    if (c >= 5 || N <= 5000) {
                        if (c < 10 && N > 120000) {
                            i = c;
                        } else if (c < 15 && N > 300000) {
                            i = c;
                            N = 300000;
                        } else if (!l.e(this)) {
                            i = c;
                        } else if (N > 120000) {
                        }
                        N = 120000;
                    } else {
                        i = c;
                        N = 5000;
                    }
                    j.b("New replica cycle scheduled in " + N + " milliseconds after an error happened.");
                    l.j(this, aVar, i + 1);
                } else if (l.c(this, aVar.s(), "com.xone.replicator.common", "error_repeat", 0) > 0) {
                    l.j(this, aVar, 0);
                }
            }
            try {
                aVar.T0();
            } catch (Exception e) {
                e.printStackTrace();
            }
            i.o(aVar);
        } catch (Exception e2) {
            j.d("*** RPL: Error running replica cycle:", e2);
        }
        n(aVar, N);
    }

    public final void g(String str, String str2) {
        if (!l.e(this)) {
            j.b("*** RPL SERVICE: Error connecting. Radio Off. Wifi Off ***");
            if (TextUtils.isEmpty(str)) {
                DatabaseFilesHelper.updateLogonStatusForAllApps(this, "radio off");
                return;
            } else {
                DatabaseFilesHelper.updateLogonStatus(this, "radio off", str);
                return;
            }
        }
        if (TextUtils.isEmpty(str)) {
            Iterator it = Na.a.r().iterator();
            while (it.hasNext()) {
                f((Na.a) it.next(), str2);
            }
            return;
        }
        Na.a q = Na.a.q(getApplicationContext(), str);
        if (q != null) {
            f(q, str2);
            return;
        }
        j.b("Received a new request to replicate for app " + str + ", but app descriptor was not found");
    }

    public final AlarmManager h() {
        Object systemService = getApplicationContext().getSystemService("alarm");
        if (systemService != null) {
            return (AlarmManager) systemService;
        }
        throw new NullPointerException("Cannot obtain AlarmManager instance");
    }

    public final NotificationManager i() {
        Object systemService = getApplicationContext().getSystemService("notification");
        if (systemService instanceof NotificationManager) {
            return (NotificationManager) systemService;
        }
        throw new NullPointerException("Cannot obtain notification service");
    }

    public final PowerManager j() {
        Object systemService = getApplicationContext().getSystemService("power");
        if (systemService != null) {
            return (PowerManager) systemService;
        }
        throw new NullPointerException("Cannot obtain PowerManager instance");
    }

    public final e k(Intent intent) {
        if (!getApplicationContext().getSharedPreferences("com.xone.live.SET_FRAMEWORK_LOCKED_BY_SECURE_PROVISIONING", 0).getBoolean("locked", false)) {
            return e.UNLOCKED;
        }
        String t = AbstractC0698k.t(intent, "com.xone.android.replicator.source", null);
        return TextUtils.isEmpty(t) ? e.LOCKED : t.compareTo("replicator-source-secure-provisioning") != 0 ? e.LOCKED : e.UNLOCKED_TEMPORARILY_BY_SECURE_PROVISIONING;
    }

    public final boolean l(File file) {
        if (file.exists() && file.isDirectory() && file.getName().startsWith("app_")) {
            return new File(file, "license.ini").exists();
        }
        return false;
    }

    public final boolean m(k kVar, String str) {
        try {
            return kVar.Q(new Qa.a(getApplicationContext()), str);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public final void n(Na.a aVar, int i) {
        Calendar calendar = Calendar.getInstance();
        if ((calendar.get(11) > 21 || calendar.get(11) < 6) && aVar.s0()) {
            i = (((30 - (calendar.get(11) <= 6 ? calendar.get(11) + 24 : calendar.get(11))) * 3600000) - (calendar.get(12) * 60000)) - (calendar.get(13) * 1000);
            j.f("Saving Battery mode active.");
        }
        calendar.add(14, i);
        j.f("Replica cycle scheduled for application " + aVar.s() + ". Next cycle in: " + DateFormat.getDateTimeInstance().format(calendar.getTime()));
        Intent intent = new Intent(getApplicationContext(), (Class<?>) ReplicatorIntentService.class);
        intent.setFlags(268435456);
        intent.putExtra("com.xone.android.framework.appname", aVar.s());
        long j = (long) i;
        intent.putExtra("com.xone.android.framework.nexttime", SystemClock.elapsedRealtime() + j);
        PendingIntent service = PendingIntent.getService(getApplicationContext(), 0, intent, Utils.l2(true, 1073741824));
        b(service);
        d(SystemClock.elapsedRealtime() + j, service);
        j.f("Intent: " + intent.toURI() + "\nInterval:" + i);
    }

    public final synchronized void o() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(14, 300000);
        j.f("Global Start. Next cycle in: " + DateFormat.getDateTimeInstance().format(calendar.getTime()));
        Intent intent = new Intent(getApplicationContext(), (Class<?>) ReplicatorIntentService.class);
        intent.setFlags(268435456);
        long j = (long) 300000;
        intent.putExtra("com.xone.android.framework.nexttime", SystemClock.elapsedRealtime() + j);
        PendingIntent service = PendingIntent.getService(getApplicationContext(), 0, intent, Utils.l2(true, 1073741824));
        b(service);
        d(SystemClock.elapsedRealtime() + j, service);
    }

    @Override
    public void onHandleIntent(Intent intent) {
        PowerManager.WakeLock a2;
        r.e eVar;
        String str = "";
        if (AbstractC0698k.b(intent, "").compareTo("clean-restart") == 0) {
            Na.a.k(getApplicationContext());
        }
        PowerManager.WakeLock wakeLock = null;
        try {
            try {
                if (AbstractC0698k.c(intent, "isForegroundService", false)) {
                    NotificationManager i = i();
                    if (Build.VERSION.SDK_INT >= 26) {
                        if (q3.e.a(i, "ReplicatorNotificationChannel") == null) {
                            W9.a.a();
                            f.a(i, q3.i.a("ReplicatorNotificationChannel", l, 2));
                        }
                        eVar = new r.e(getApplicationContext(), "ReplicatorNotificationChannel");
                    } else {
                        eVar = new r.e(getApplicationContext());
                    }
                    eVar.m(getString(Na.f.f));
                    eVar.l(getString(Na.f.j));
                    eVar.y(c.a);
                    startForeground(3501, eVar.c());
                }
                a2 = a();
            } catch (Exception e) {
                e = e;
            }
        } catch (Throwable th) {
            th = th;
        }
        try {
            j.f("*** Starting replica cycle.");
            String t = AbstractC0698k.t(intent, "com.xone.android.framework.appname", "");
            String t2 = AbstractC0698k.t(intent, "com.xone.android.replicator.source", "");
            if (t == null) {
                t = "";
            }
            if (t2 != null) {
                str = t2;
            }
            if (!TextUtils.isEmpty(t)) {
                j.f("*** Starting replica cycle for application " + t);
            }
            if (TextUtils.isEmpty(str)) {
                j.f("*** No source found.");
            } else {
                j.f("*** Started by: " + str);
            }
            int i2 = a.a[k(intent).ordinal()];
            if (i2 == 1) {
                j.f("*** Replicator is locked by secure provisioning. Cancelling cycle.");
                c(a2);
                return;
            }
            if (i2 == 2) {
                j.f("*** Replicator is unlocked. Proceeding to the next step.");
            } else if (i2 == 3) {
                j.f("*** Replicator is unlocked temporarily by secure provisioning. Proceeding to the next step.");
            }
            e(null);
            if (Na.a.r().isEmpty()) {
                j.f(" *** RPL: Could not load any applications yet.");
                c(a2);
            } else {
                g(t, str);
                c(a2);
            }
        } catch (Exception e2) {
            e = e2;
            wakeLock = a2;
            j.d(" *** RPL: Error running replica cycle: ", e);
            o();
            c(wakeLock);
        } catch (Throwable th2) {
            th = th2;
            wakeLock = a2;
            c(wakeLock);
            throw th;
        }
    }
}