山海小管家.apk(点击下载) / q.java


package a.d.a.a;

import android.content.ContentValues;
import android.database.Cursor;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.optimizer.Codegen;

public final class q {

    /* renamed from: a  reason: collision with root package name */
    public static final a f1910a = a.EXPONENTIAL;

    /* renamed from: b  reason: collision with root package name */
    public static final d f1911b = d.ANY;

    /* renamed from: c  reason: collision with root package name */
    public static final long f1912c = TimeUnit.MINUTES.toMillis(15);

    /* renamed from: d  reason: collision with root package name */
    public static final long f1913d = TimeUnit.MINUTES.toMillis(5);

    /* renamed from: e  reason: collision with root package name */
    public static final a.d.a.a.b.d f1914e = new a.d.a.a.b.d("JobRequest", true);

    /* renamed from: f  reason: collision with root package name */
    public final b f1915f;

    /* renamed from: g  reason: collision with root package name */
    public int f1916g;

    /* renamed from: h  reason: collision with root package name */
    public long f1917h;
    public boolean i;
    public boolean j;
    public long k;

    public enum a {
        LINEAR,
        EXPONENTIAL
    }

    public interface c {
        void onJobScheduled(int i, @NonNull String str, @Nullable Exception exc);
    }

    public enum d {
        ANY,
        CONNECTED,
        UNMETERED,
        NOT_ROAMING,
        METERED
    }

    public /* synthetic */ q(b bVar, o oVar) {
        this.f1915f = bVar;
    }

    public static long c() {
        return f.f1874c && Build.VERSION.SDK_INT < 24 ? TimeUnit.SECONDS.toMillis(30) : f1913d;
    }

    public static long d() {
        return f.f1874c && Build.VERSION.SDK_INT < 24 ? TimeUnit.MINUTES.toMillis(1) : f1912c;
    }

    public b a() {
        long j2 = this.f1917h;
        k.b().a(this.f1915f.f1921a);
        b bVar = new b(this.f1915f, false);
        this.i = false;
        if (!f()) {
            long a2 = ((a.d.a.a.b.b) f.i).a() - j2;
            bVar.a(Math.max(1L, this.f1915f.f1923c - a2), Math.max(1L, this.f1915f.f1924d - a2));
        }
        return bVar;
    }

    public d b() {
        if (this.f1915f.n) {
            return d.V_14;
        }
        return d.b(k.b().f1898c);
    }

    public void b(boolean z) {
        this.i = z;
        ContentValues contentValues = new ContentValues();
        contentValues.put("started", Boolean.valueOf(this.i));
        k.b().a().a(this, contentValues);
    }

    public boolean e() {
        return this.f1915f.n;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || q.class != obj.getClass()) {
            return false;
        }
        return this.f1915f.equals(((q) obj).f1915f);
    }

    public boolean f() {
        return this.f1915f.f1927g > 0;
    }

    public int g() {
        k.b().b(this);
        return this.f1915f.f1921a;
    }

    public ContentValues h() {
        String str;
        ContentValues contentValues = new ContentValues();
        b bVar = this.f1915f;
        contentValues.put(Codegen.ID_FIELD_NAME, Integer.valueOf(bVar.f1921a));
        contentValues.put("tag", bVar.f1922b);
        contentValues.put("startMs", Long.valueOf(bVar.f1923c));
        contentValues.put("endMs", Long.valueOf(bVar.f1924d));
        contentValues.put("backoffMs", Long.valueOf(bVar.f1925e));
        contentValues.put("backoffPolicy", bVar.f1926f.toString());
        contentValues.put("intervalMs", Long.valueOf(bVar.f1927g));
        contentValues.put("flexMs", Long.valueOf(bVar.f1928h));
        contentValues.put("requirementsEnforced", Boolean.valueOf(bVar.i));
        contentValues.put("requiresCharging", Boolean.valueOf(bVar.j));
        contentValues.put("requiresDeviceIdle", Boolean.valueOf(bVar.k));
        contentValues.put("requiresBatteryNotLow", Boolean.valueOf(bVar.l));
        contentValues.put("requiresStorageNotLow", Boolean.valueOf(bVar.m));
        contentValues.put("exact", Boolean.valueOf(bVar.n));
        contentValues.put("networkType", bVar.o.toString());
        a.d.a.a.b.a.b bVar2 = bVar.p;
        if (bVar2 != null) {
            str = bVar2.a();
        } else {
            if (!TextUtils.isEmpty(bVar.q)) {
                str = bVar.q;
            }
            contentValues.put("transient", Boolean.valueOf(bVar.s));
            contentValues.put("numFailures", Integer.valueOf(this.f1916g));
            contentValues.put("scheduledAt", Long.valueOf(this.f1917h));
            contentValues.put("started", Boolean.valueOf(this.i));
            contentValues.put("flexSupport", Boolean.valueOf(this.j));
            contentValues.put("lastRun", Long.valueOf(this.k));
            return contentValues;
        }
        contentValues.put("extras", str);
        contentValues.put("transient", Boolean.valueOf(bVar.s));
        contentValues.put("numFailures", Integer.valueOf(this.f1916g));
        contentValues.put("scheduledAt", Long.valueOf(this.f1917h));
        contentValues.put("started", Boolean.valueOf(this.i));
        contentValues.put("flexSupport", Boolean.valueOf(this.j));
        contentValues.put("lastRun", Long.valueOf(this.k));
        return contentValues;
    }

    public int hashCode() {
        return this.f1915f.f1921a;
    }

    public String toString() {
        StringBuilder b2 = a.b.c.a.a.b("request{id=");
        b2.append(this.f1915f.f1921a);
        b2.append(", tag=");
        b2.append(this.f1915f.f1922b);
        b2.append(", transient=");
        b2.append(this.f1915f.s);
        b2.append('}');
        return b2.toString();
    }

    public static final class b {

        /* renamed from: a  reason: collision with root package name */
        public int f1921a;

        /* renamed from: b  reason: collision with root package name */
        public final String f1922b;

        /* renamed from: c  reason: collision with root package name */
        public long f1923c;

        /* renamed from: d  reason: collision with root package name */
        public long f1924d;

        /* renamed from: e  reason: collision with root package name */
        public long f1925e;

        /* renamed from: f  reason: collision with root package name */
        public a f1926f;

        /* renamed from: g  reason: collision with root package name */
        public long f1927g;

        /* renamed from: h  reason: collision with root package name */
        public long f1928h;
        public boolean i;
        public boolean j;
        public boolean k;
        public boolean l;
        public boolean m;
        public boolean n;
        public d o;
        public a.d.a.a.b.a.b p;
        public String q;
        public boolean r;
        public boolean s;
        public Bundle t = Bundle.EMPTY;

        public b(@NonNull b bVar, boolean z) {
            this.f1921a = z ? -8765 : bVar.f1921a;
            this.f1922b = bVar.f1922b;
            this.f1923c = bVar.f1923c;
            this.f1924d = bVar.f1924d;
            this.f1925e = bVar.f1925e;
            this.f1926f = bVar.f1926f;
            this.f1927g = bVar.f1927g;
            this.f1928h = bVar.f1928h;
            this.i = bVar.i;
            this.j = bVar.j;
            this.k = bVar.k;
            this.l = bVar.l;
            this.m = bVar.m;
            this.n = bVar.n;
            this.o = bVar.o;
            this.p = bVar.p;
            this.q = bVar.q;
            this.r = bVar.r;
            this.s = bVar.s;
            this.t = bVar.t;
        }

        public /* synthetic */ b(Cursor cursor, o oVar) {
            this.f1921a = cursor.getInt(cursor.getColumnIndex(Codegen.ID_FIELD_NAME));
            this.f1922b = cursor.getString(cursor.getColumnIndex("tag"));
            this.f1923c = cursor.getLong(cursor.getColumnIndex("startMs"));
            this.f1924d = cursor.getLong(cursor.getColumnIndex("endMs"));
            this.f1925e = cursor.getLong(cursor.getColumnIndex("backoffMs"));
            try {
                this.f1926f = a.valueOf(cursor.getString(cursor.getColumnIndex("backoffPolicy")));
            } catch (Throwable th) {
                q.f1914e.a(th);
                this.f1926f = q.f1910a;
            }
            this.f1927g = cursor.getLong(cursor.getColumnIndex("intervalMs"));
            this.f1928h = cursor.getLong(cursor.getColumnIndex("flexMs"));
            boolean z = false;
            this.i = cursor.getInt(cursor.getColumnIndex("requirementsEnforced")) > 0;
            this.j = cursor.getInt(cursor.getColumnIndex("requiresCharging")) > 0;
            this.k = cursor.getInt(cursor.getColumnIndex("requiresDeviceIdle")) > 0;
            this.l = cursor.getInt(cursor.getColumnIndex("requiresBatteryNotLow")) > 0;
            this.m = cursor.getInt(cursor.getColumnIndex("requiresStorageNotLow")) > 0;
            this.n = cursor.getInt(cursor.getColumnIndex("exact")) > 0;
            try {
                this.o = d.valueOf(cursor.getString(cursor.getColumnIndex("networkType")));
            } catch (Throwable th2) {
                q.f1914e.a(th2);
                this.o = q.f1911b;
            }
            this.q = cursor.getString(cursor.getColumnIndex("extras"));
            this.s = cursor.getInt(cursor.getColumnIndex("transient")) > 0 ? true : z;
        }

        public q a() {
            if (TextUtils.isEmpty(this.f1922b)) {
                throw new IllegalArgumentException();
            } else if (this.f1925e > 0) {
                a.a.a.d.a(this.f1926f);
                a.a.a.d.a(this.o);
                long j2 = this.f1927g;
                if (j2 > 0) {
                    a.a.a.d.a(j2, q.d(), (long) RecyclerView.FOREVER_NS, "intervalMs");
                    a.a.a.d.a(this.f1928h, q.c(), this.f1927g, "flexMs");
                    if (this.f1927g < q.f1912c || this.f1928h < q.f1913d) {
                        a.d.a.a.b.d dVar = q.f1914e;
                        dVar.a(5, dVar.f1841c, String.format("AllowSmallerIntervals enabled, this will crash on Android N and later, interval %d (minimum is %d), flex %d (minimum is %d)", Long.valueOf(this.f1927g), Long.valueOf(q.f1912c), Long.valueOf(this.f1928h), Long.valueOf(q.f1913d)), null);
                    }
                }
                if (this.n && this.f1927g > 0) {
                    throw new IllegalArgumentException("Can't call setExact() on a periodic job.");
                } else if (this.n && this.f1923c != this.f1924d) {
                    throw new IllegalArgumentException("Can't call setExecutionWindow() for an exact job.");
                } else if (this.n && (this.i || this.k || this.j || !q.f1911b.equals(this.o) || this.l || this.m)) {
                    throw new IllegalArgumentException("Can't require any condition for an exact job.");
                } else if (this.f1927g <= 0 && (this.f1923c == -1 || this.f1924d == -1)) {
                    throw new IllegalArgumentException("You're trying to build a job with no constraints, this is not allowed.");
                } else if (this.f1927g > 0 && (this.f1923c != -1 || this.f1924d != -1)) {
                    throw new IllegalArgumentException("Can't call setExecutionWindow() on a periodic job.");
                } else if (this.f1927g <= 0 || (this.f1925e == 30000 && q.f1910a.equals(this.f1926f))) {
                    if (this.f1927g <= 0 && (this.f1923c > 3074457345618258602L || this.f1924d > 3074457345618258602L)) {
                        a.d.a.a.b.d dVar2 = q.f1914e;
                        dVar2.a(5, dVar2.f1841c, "Attention: your execution window is too large. This could result in undesired behavior, see https://github.com/evernote/android-job/wiki/FAQ", null);
                    }
                    if (this.f1927g <= 0 && this.f1923c > TimeUnit.DAYS.toMillis(365)) {
                        a.d.a.a.b.d dVar3 = q.f1914e;
                        dVar3.a(5, dVar3.f1841c, String.format("Warning: job with tag %s scheduled over a year in the future", this.f1922b), null);
                    }
                    int i2 = this.f1921a;
                    if (i2 != -8765) {
                        a.a.a.d.a(i2, "id can't be negative");
                    }
                    b bVar = new b(this, false);
                    if (this.f1921a == -8765) {
                        bVar.f1921a = k.b().a().c();
                        a.a.a.d.a(bVar.f1921a, "id can't be negative");
                    }
                    return new q(bVar, null);
                } else {
                    throw new IllegalArgumentException("A periodic job will not respect any back-off policy, so calling setBackoffCriteria() with setPeriodic() is an error.");
                }
            } else {
                throw new IllegalArgumentException("backoffMs must be > 0");
            }
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            return obj != null && b.class == obj.getClass() && this.f1921a == ((b) obj).f1921a;
        }

        public int hashCode() {
            return this.f1921a;
        }

        public b(@NonNull String str) {
            if (!TextUtils.isEmpty(str)) {
                this.f1922b = str;
                this.f1921a = -8765;
                this.f1923c = -1;
                this.f1924d = -1;
                this.f1925e = 30000;
                this.f1926f = q.f1910a;
                this.o = q.f1911b;
                return;
            }
            throw new IllegalArgumentException();
        }

        public b a(long j2, long j3) {
            if (j2 > 0) {
                this.f1923c = j2;
                a.a.a.d.a(j3, j2, (long) RecyclerView.FOREVER_NS, "endInMs");
                this.f1924d = j3;
                long j4 = this.f1923c;
                if (j4 > 6148914691236517204L) {
                    a.d.a.a.b.d dVar = q.f1914e;
                    dVar.a(4, dVar.f1841c, String.format("startInMs reduced from %d days to %d days", Long.valueOf(TimeUnit.MILLISECONDS.toDays(j4)), Long.valueOf(TimeUnit.MILLISECONDS.toDays(6148914691236517204L))), null);
                    this.f1923c = 6148914691236517204L;
                }
                long j5 = this.f1924d;
                if (j5 > 6148914691236517204L) {
                    a.d.a.a.b.d dVar2 = q.f1914e;
                    dVar2.a(4, dVar2.f1841c, String.format("endInMs reduced from %d days to %d days", Long.valueOf(TimeUnit.MILLISECONDS.toDays(j5)), Long.valueOf(TimeUnit.MILLISECONDS.toDays(6148914691236517204L))), null);
                    this.f1924d = 6148914691236517204L;
                }
                return this;
            }
            throw new IllegalArgumentException("startInMs must be greater than 0");
        }
    }

    public void b(boolean z, boolean z2) {
        ContentValues contentValues = new ContentValues();
        if (z) {
            this.f1916g++;
            contentValues.put("numFailures", Integer.valueOf(this.f1916g));
        }
        if (z2) {
            this.k = ((a.d.a.a.b.b) f.i).a();
            contentValues.put("lastRun", Long.valueOf(this.k));
        }
        k.b().a().a(this, contentValues);
    }

    public static q a(Cursor cursor) {
        q a2 = new b(cursor, (o) null).a();
        a2.f1916g = cursor.getInt(cursor.getColumnIndex("numFailures"));
        a2.f1917h = cursor.getLong(cursor.getColumnIndex("scheduledAt"));
        boolean z = true;
        a2.i = cursor.getInt(cursor.getColumnIndex("started")) > 0;
        if (cursor.getInt(cursor.getColumnIndex("flexSupport")) <= 0) {
            z = false;
        }
        a2.j = z;
        a2.k = cursor.getLong(cursor.getColumnIndex("lastRun"));
        a.a.a.d.a(a2.f1916g, "failure count can't be negative");
        if (a2.f1917h >= 0) {
            return a2;
        }
        throw new IllegalArgumentException("scheduled at can't be negative");
    }

    public long a(boolean z) {
        long j2 = 0;
        if (f()) {
            return 0;
        }
        int ordinal = this.f1915f.f1926f.ordinal();
        if (ordinal == 0) {
            j2 = this.f1915f.f1925e * ((long) this.f1916g);
        } else if (ordinal == 1) {
            int i2 = this.f1916g;
            if (i2 != 0) {
                double d2 = (double) this.f1915f.f1925e;
                double pow = Math.pow(2.0d, (double) (i2 - 1));
                Double.isNaN(d2);
                Double.isNaN(d2);
                j2 = (long) (pow * d2);
            }
        } else {
            throw new IllegalStateException("not implemented");
        }
        if (z && !e()) {
            j2 = (long) (((float) j2) * 1.2f);
        }
        return Math.min(j2, TimeUnit.HOURS.toMillis(5));
    }

    public q a(boolean z, boolean z2) {
        q a2 = new b(this.f1915f, z2).a();
        if (z) {
            a2.f1916g = this.f1916g + 1;
        }
        try {
            a2.g();
        } catch (Exception e2) {
            f1914e.a(e2);
        }
        return a2;
    }

    public void a(@NonNull c cVar) {
        if (cVar != null) {
            f.j.execute(new p(this, cVar));
            return;
        }
        throw new NullPointerException();
    }
}