盛康基办.apk(点击下载) / e.java


package com.baidu.location.c;

import android.content.SharedPreferences;
import com.baidu.location.Jni;
import com.baidu.location.b.v;
import com.baidu.location.f;
import com.baidu.location.g.b;
import com.baidu.location.g.c;
import com.baidu.location.g.j;
import com.baidu.location.g.k;
import java.io.File;
import java.io.RandomAccessFile;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import org.json.JSONObject;

public class e {
    private static e i;
    private static final String l = (j.a + "/conlts.dat");
    private static int m = -1;
    private static int n = -1;
    private static int o = 0;
    public boolean a = true;
    public boolean b = true;
    public boolean c = false;
    public boolean d = true;
    public boolean e = true;
    public boolean f = true;
    public boolean g = true;
    public boolean h = false;
    private a j = null;
    private String k = "https://loc.map.baidu.com/cfgs/loc/commcfgs";

    /* access modifiers changed from: package-private */
    public class a extends com.baidu.location.g.e {
        String a = null;
        boolean b = false;
        boolean c = false;

        public a() {
            this.k = new HashMap();
        }

        @Override // com.baidu.location.g.e
        public void a() {
            String str;
            Map map;
            this.h = k.e();
            this.i = 2;
            String encode = Jni.encode(this.a);
            this.a = null;
            if (this.b) {
                map = this.k;
                str = "grid";
            } else {
                map = this.k;
                str = "conf";
            }
            map.put("qt", str);
            this.k.put("req", encode);
        }

        public void a(String str, boolean z) {
            if (!this.c) {
                this.c = true;
                this.a = str;
                this.b = z;
                ExecutorService c2 = v.a().c();
                if (z) {
                    a(c2, true, "loc.map.baidu.com");
                } else if (c2 != null) {
                    a(c2, e.this.k);
                } else {
                    c(e.this.k);
                }
            }
        }

        /* JADX WARNING: Removed duplicated region for block: B:11:0x0021  */
        @Override // com.baidu.location.g.e
        public void a(boolean z) {
            e eVar;
            String str;
            if (!z || this.j == null) {
                eVar = e.this;
                str = null;
            } else if (this.b) {
                e.this.a((e) this.m);
                if (this.k != null) {
                    this.k.clear();
                }
                this.c = false;
            } else {
                eVar = e.this;
                str = this.j;
            }
            eVar.b((e) str);
            if (this.k != null) {
            }
            this.c = false;
        }
    }

    private e() {
    }

    public static e a() {
        if (i == null) {
            i = new e();
        }
        return i;
    }

    private void a(int i2) {
        boolean z = true;
        this.a = (i2 & 1) == 1;
        this.b = (i2 & 2) == 2;
        this.c = (i2 & 4) == 4;
        this.d = (i2 & 8) == 8;
        this.f = (i2 & 65536) == 65536;
        if ((i2 & 131072) != 131072) {
            z = false;
        }
        this.g = z;
        if ((i2 & 16) == 16) {
            this.e = false;
        }
    }

    private void a(JSONObject jSONObject) {
        if (jSONObject != null) {
            boolean z = true;
            int i2 = 14400000;
            int i3 = 10;
            try {
                if (jSONObject.has("ipen") && jSONObject.getInt("ipen") == 0) {
                    z = false;
                }
                if (jSONObject.has("ipvt")) {
                    i2 = jSONObject.getInt("ipvt");
                }
                if (jSONObject.has("ipvn")) {
                    i3 = jSONObject.getInt("ipvn");
                }
                SharedPreferences.Editor edit = f.getServiceContext().getSharedPreferences("MapCoreServicePre", 0).edit();
                edit.putBoolean("ipLocInfoUpload", z);
                edit.putInt("ipValidTime", i2);
                edit.putInt("ipLocInfoUploadTimesPerDay", i3);
                edit.commit();
            } catch (Exception unused) {
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(byte[] bArr) {
        int i2 = 0;
        if (bArr != null) {
            try {
                if (bArr.length < 640) {
                    k.x = false;
                    k.u = k.s + 0.025d;
                    k.t = k.r - 0.025d;
                } else {
                    k.x = true;
                    k.t = Double.longBitsToDouble(((((long) bArr[7]) & 255) << 56) | ((((long) bArr[6]) & 255) << 48) | ((((long) bArr[5]) & 255) << 40) | ((((long) bArr[4]) & 255) << 32) | ((((long) bArr[3]) & 255) << 24) | ((((long) bArr[2]) & 255) << 16) | ((((long) bArr[1]) & 255) << 8) | (((long) bArr[0]) & 255));
                    k.u = Double.longBitsToDouble(((((long) bArr[15]) & 255) << 56) | ((((long) bArr[14]) & 255) << 48) | ((((long) bArr[13]) & 255) << 40) | ((((long) bArr[12]) & 255) << 32) | ((((long) bArr[11]) & 255) << 24) | ((((long) bArr[10]) & 255) << 16) | ((((long) bArr[9]) & 255) << 8) | (255 & ((long) bArr[8])));
                    k.w = new byte[625];
                    while (i2 < 625) {
                        k.w[i2] = bArr[i2 + 16];
                        i2++;
                    }
                }
                i2 = 1;
            } catch (Exception unused) {
                return;
            }
        }
        if (i2 != 0) {
            g();
        }
    }

    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:12:0x0032 */
    /* JADX WARNING: Removed duplicated region for block: B:15:0x0038 A[SYNTHETIC, Splitter:B:15:0x0038] */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x004f  */
    private boolean a(String str) {
        int parseInt;
        boolean z = true;
        if (str != null) {
            try {
                JSONObject jSONObject = new JSONObject(str);
                if (jSONObject.has("ipconf")) {
                    try {
                        a(jSONObject.getJSONObject("ipconf"));
                    } catch (Exception unused) {
                    }
                    if (jSONObject.has("is_check_Per")) {
                        try {
                            if (jSONObject.getInt("is_check_Per") > 0) {
                                k.ay = true;
                            }
                        } catch (Exception unused2) {
                        }
                    }
                    parseInt = Integer.parseInt(jSONObject.getString("ver"));
                    if (parseInt > k.y) {
                        k.y = parseInt;
                        if (jSONObject.has("gps")) {
                            String[] split = jSONObject.getString("gps").split("\\|");
                            if (split.length > 10) {
                                if (split[0] != null && !split[0].equals("")) {
                                    k.z = Float.parseFloat(split[0]);
                                }
                                if (split[1] != null && !split[1].equals("")) {
                                    k.A = Float.parseFloat(split[1]);
                                }
                                if (split[2] != null && !split[2].equals("")) {
                                    k.B = Float.parseFloat(split[2]);
                                }
                                if (split[3] != null && !split[3].equals("")) {
                                    k.C = Float.parseFloat(split[3]);
                                }
                                if (split[4] != null && !split[4].equals("")) {
                                    k.D = Integer.parseInt(split[4]);
                                }
                                if (split[5] != null && !split[5].equals("")) {
                                    k.E = Integer.parseInt(split[5]);
                                }
                                if (split[6] != null && !split[6].equals("")) {
                                    k.F = Integer.parseInt(split[6]);
                                }
                                if (split[7] != null && !split[7].equals("")) {
                                    k.G = Integer.parseInt(split[7]);
                                }
                                if (split[8] != null && !split[8].equals("")) {
                                    k.H = Integer.parseInt(split[8]);
                                }
                                if (split[9] != null && !split[9].equals("")) {
                                    k.I = Integer.parseInt(split[9]);
                                }
                                if (split[10] != null && !split[10].equals("")) {
                                    k.J = Integer.parseInt(split[10]);
                                }
                            }
                        }
                        if (jSONObject.has("up")) {
                            String[] split2 = jSONObject.getString("up").split("\\|");
                            if (split2.length > 3) {
                                if (split2[0] != null && !split2[0].equals("")) {
                                    k.K = Float.parseFloat(split2[0]);
                                }
                                if (split2[1] != null && !split2[1].equals("")) {
                                    k.L = Float.parseFloat(split2[1]);
                                }
                                if (split2[2] != null && !split2[2].equals("")) {
                                    k.M = Float.parseFloat(split2[2]);
                                }
                                if (split2[3] != null && !split2[3].equals("")) {
                                    k.N = Float.parseFloat(split2[3]);
                                }
                            }
                        }
                        if (jSONObject.has("wf")) {
                            String[] split3 = jSONObject.getString("wf").split("\\|");
                            if (split3.length > 3) {
                                if (split3[0] != null && !split3[0].equals("")) {
                                    k.O = Integer.parseInt(split3[0]);
                                }
                                if (split3[1] != null && !split3[1].equals("")) {
                                    k.Q = Float.parseFloat(split3[1]);
                                }
                                if (split3[2] != null && !split3[2].equals("")) {
                                    k.R = Integer.parseInt(split3[2]);
                                }
                                if (split3[3] != null && !split3[3].equals("")) {
                                    k.S = Float.parseFloat(split3[3]);
                                }
                            }
                        }
                        if (jSONObject.has("ab")) {
                            String[] split4 = jSONObject.getString("ab").split("\\|");
                            if (split4.length > 3) {
                                if (split4[0] != null && !split4[0].equals("")) {
                                    k.T = Float.parseFloat(split4[0]);
                                }
                                if (split4[1] != null && !split4[1].equals("")) {
                                    k.U = Float.parseFloat(split4[1]);
                                }
                                if (split4[2] != null && !split4[2].equals("")) {
                                    k.V = Integer.parseInt(split4[2]);
                                }
                                if (split4[3] != null && !split4[3].equals("")) {
                                    k.W = Integer.parseInt(split4[3]);
                                }
                            }
                        }
                        if (jSONObject.has("zxd")) {
                            String[] split5 = jSONObject.getString("zxd").split("\\|");
                            if (split5.length > 4) {
                                if (split5[0] != null && !split5[0].equals("")) {
                                    k.as = Float.parseFloat(split5[0]);
                                }
                                if (split5[1] != null && !split5[1].equals("")) {
                                    k.at = Float.parseFloat(split5[1]);
                                }
                                if (split5[2] != null && !split5[2].equals("")) {
                                    k.au = Integer.parseInt(split5[2]);
                                }
                                if (split5[3] != null && !split5[3].equals("")) {
                                    k.av = Integer.parseInt(split5[3]);
                                }
                                if (split5[4] != null && !split5[4].equals("")) {
                                    k.aw = Integer.parseInt(split5[4]);
                                }
                            }
                        }
                        if (jSONObject.has("gpc")) {
                            String[] split6 = jSONObject.getString("gpc").split("\\|");
                            if (split6.length > 5) {
                                if (split6[0] != null && !split6[0].equals("")) {
                                    if (Integer.parseInt(split6[0]) > 0) {
                                        k.ab = true;
                                    } else {
                                        k.ab = false;
                                    }
                                }
                                if (split6[1] != null && !split6[1].equals("")) {
                                    if (Integer.parseInt(split6[1]) > 0) {
                                        k.ac = true;
                                    } else {
                                        k.ac = false;
                                    }
                                }
                                if (split6[2] != null && !split6[2].equals("")) {
                                    k.ad = Integer.parseInt(split6[2]);
                                }
                                if (split6[3] != null && !split6[3].equals("")) {
                                    k.af = Integer.parseInt(split6[3]);
                                }
                                if (split6[4] != null && !split6[4].equals("")) {
                                    int parseInt2 = Integer.parseInt(split6[4]);
                                    if (parseInt2 > 0) {
                                        k.al = (long) parseInt2;
                                        k.ah = k.al * 1000 * 60;
                                        k.am = k.ah >> 2;
                                    } else {
                                        k.p = false;
                                    }
                                }
                                if (split6[5] != null && !split6[5].equals("")) {
                                    k.ao = Integer.parseInt(split6[5]);
                                }
                            }
                        }
                        if (jSONObject.has("shak")) {
                            String[] split7 = jSONObject.getString("shak").split("\\|");
                            if (split7.length > 2) {
                                if (split7[0] != null && !split7[0].equals("")) {
                                    k.ap = Integer.parseInt(split7[0]);
                                }
                                if (split7[1] != null && !split7[1].equals("")) {
                                    k.aq = Integer.parseInt(split7[1]);
                                }
                                if (split7[2] != null && !split7[2].equals("")) {
                                    k.ar = Float.parseFloat(split7[2]);
                                }
                            }
                        }
                        if (jSONObject.has("dmx")) {
                            k.an = jSONObject.getInt("dmx");
                        }
                        return z;
                    }
                }
                try {
                    if (jSONObject.has("is_check_Per")) {
                    }
                    parseInt = Integer.parseInt(jSONObject.getString("ver"));
                    if (parseInt > k.y) {
                    }
                } catch (Exception unused3) {
                    return false;
                }
            } catch (Exception unused4) {
                return false;
            }
        }
        z = false;
        return z;
    }

    private void b(int i2) {
        File file = new File(l);
        if (!file.exists()) {
            i();
        }
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
            randomAccessFile.seek(4);
            int readInt = randomAccessFile.readInt();
            int readInt2 = randomAccessFile.readInt();
            randomAccessFile.seek((long) ((readInt * o) + 128));
            byte[] bytes = (b.e + (char) 0).getBytes();
            randomAccessFile.writeInt(bytes.length);
            randomAccessFile.write(bytes, 0, bytes.length);
            randomAccessFile.writeInt(i2);
            if (readInt2 == o) {
                randomAccessFile.seek(8);
                randomAccessFile.writeInt(readInt2 + 1);
            }
            randomAccessFile.close();
        } catch (Exception unused) {
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Can't wrap try/catch for region: R(10:2|3|(1:5)|6|7|(1:9)|10|11|(1:13)(2:14|(1:16)(1:17))|(2:19|21)(1:24)) */
    /* JADX WARNING: Code restructure failed: missing block: B:22:?, code lost:
        return;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:10:0x0025 */
    /* JADX WARNING: Missing exception handler attribute for start block: B:6:0x0010 */
    /* JADX WARNING: Removed duplicated region for block: B:13:0x002c A[Catch:{ Exception -> 0x0041 }] */
    /* JADX WARNING: Removed duplicated region for block: B:14:0x0034 A[Catch:{ Exception -> 0x0041 }] */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x003e A[Catch:{ Exception -> 0x0041 }] */
    /* JADX WARNING: Removed duplicated region for block: B:24:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:9:0x001b A[Catch:{ Exception -> 0x0025 }] */
    private void b(String str) {
        int i2;
        n = -1;
        if (str != null) {
            if (a(str)) {
                f();
            }
            JSONObject jSONObject = new JSONObject(str);
            if (jSONObject.has("ctr")) {
                n = Integer.parseInt(jSONObject.getString("ctr"));
            }
            j();
            if (n != -1) {
                i2 = n;
                b(n);
            } else {
                i2 = m != -1 ? m : -1;
            }
            if (i2 != -1) {
                a(i2);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void e() {
        String str = "&ver=" + k.y + "&usr=" + b.a().b() + "&app=" + b.e + "&prod=" + b.f;
        if (this.j == null) {
            this.j = new a();
        }
        if (!k.b()) {
            this.j.a(str, false);
        }
    }

    private void f() {
        String str = j.a + "/config.dat";
        byte[] bytes = String.format(Locale.CHINA, "{\"ver\":\"%d\",\"gps\":\"%.1f|%.1f|%.1f|%.1f|%d|%d|%d|%d|%d|%d|%d\",\"up\":\"%.1f|%.1f|%.1f|%.1f\",\"wf\":\"%d|%.1f|%d|%.1f\",\"ab\":\"%.2f|%.2f|%d|%d\",\"gpc\":\"%d|%d|%d|%d|%d|%d\",\"zxd\":\"%.1f|%.1f|%d|%d|%d\",\"shak\":\"%d|%d|%.1f\",\"dmx\":%d}", Integer.valueOf(k.y), Float.valueOf(k.z), Float.valueOf(k.A), Float.valueOf(k.B), Float.valueOf(k.C), Integer.valueOf(k.D), Integer.valueOf(k.E), Integer.valueOf(k.F), Integer.valueOf(k.G), Integer.valueOf(k.H), Integer.valueOf(k.I), Integer.valueOf(k.J), Float.valueOf(k.K), Float.valueOf(k.L), Float.valueOf(k.M), Float.valueOf(k.N), Integer.valueOf(k.O), Float.valueOf(k.Q), Integer.valueOf(k.R), Float.valueOf(k.S), Float.valueOf(k.T), Float.valueOf(k.U), Integer.valueOf(k.V), Integer.valueOf(k.W), Integer.valueOf(k.ab ? 1 : 0), Integer.valueOf(k.ac ? 1 : 0), Integer.valueOf(k.ad), Integer.valueOf(k.af), Long.valueOf(k.al), Integer.valueOf(k.ao), Float.valueOf(k.as), Float.valueOf(k.at), Integer.valueOf(k.au), Integer.valueOf(k.av), Integer.valueOf(k.aw), Integer.valueOf(k.ap), Integer.valueOf(k.aq), Float.valueOf(k.ar), Integer.valueOf(k.an)).getBytes();
        try {
            File file = new File(str);
            if (!file.exists()) {
                File file2 = new File(j.a);
                if (!file2.exists()) {
                    file2.mkdirs();
                }
                if (file.createNewFile()) {
                    RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
                    randomAccessFile.seek(0);
                    randomAccessFile.writeBoolean(false);
                    randomAccessFile.writeBoolean(false);
                    randomAccessFile.close();
                } else {
                    return;
                }
            }
            RandomAccessFile randomAccessFile2 = new RandomAccessFile(file, "rw");
            randomAccessFile2.seek(0);
            randomAccessFile2.writeBoolean(true);
            randomAccessFile2.seek(2);
            randomAccessFile2.writeInt(bytes.length);
            randomAccessFile2.write(bytes);
            randomAccessFile2.close();
        } catch (Exception unused) {
        }
    }

    private void g() {
        try {
            File file = new File(j.a + "/config.dat");
            if (!file.exists()) {
                File file2 = new File(j.a);
                if (!file2.exists()) {
                    file2.mkdirs();
                }
                if (file.createNewFile()) {
                    RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
                    randomAccessFile.seek(0);
                    randomAccessFile.writeBoolean(false);
                    randomAccessFile.writeBoolean(false);
                    randomAccessFile.close();
                } else {
                    return;
                }
            }
            RandomAccessFile randomAccessFile2 = new RandomAccessFile(file, "rw");
            randomAccessFile2.seek(1);
            randomAccessFile2.writeBoolean(true);
            randomAccessFile2.seek(1024);
            randomAccessFile2.writeDouble(k.t);
            randomAccessFile2.writeDouble(k.u);
            randomAccessFile2.writeBoolean(k.x);
            if (k.x && k.w != null) {
                randomAccessFile2.write(k.w);
            }
            randomAccessFile2.close();
        } catch (Exception unused) {
        }
    }

    private void h() {
        try {
            File file = new File(j.a + "/config.dat");
            if (file.exists()) {
                RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
                if (randomAccessFile.readBoolean()) {
                    randomAccessFile.seek(2);
                    int readInt = randomAccessFile.readInt();
                    byte[] bArr = new byte[readInt];
                    randomAccessFile.read(bArr, 0, readInt);
                    a(new String(bArr));
                }
                randomAccessFile.seek(1);
                if (randomAccessFile.readBoolean()) {
                    randomAccessFile.seek(1024);
                    k.t = randomAccessFile.readDouble();
                    k.u = randomAccessFile.readDouble();
                    k.x = randomAccessFile.readBoolean();
                    if (k.x) {
                        k.w = new byte[625];
                        randomAccessFile.read(k.w, 0, 625);
                    }
                }
                randomAccessFile.close();
            }
        } catch (Exception unused) {
        }
        if (k.p) {
            boolean z = f.isServing;
        }
    }

    private void i() {
        try {
            File file = new File(l);
            if (!file.exists()) {
                File file2 = new File(j.a);
                if (!file2.exists()) {
                    file2.mkdirs();
                }
                if (!file.createNewFile()) {
                    file = null;
                }
                RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
                randomAccessFile.seek(0);
                randomAccessFile.writeInt(0);
                randomAccessFile.writeInt(128);
                randomAccessFile.writeInt(0);
                randomAccessFile.close();
            }
        } catch (Exception unused) {
        }
    }

    private void j() {
        try {
            File file = new File(l);
            if (file.exists()) {
                RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
                randomAccessFile.seek(4);
                int readInt = randomAccessFile.readInt();
                if (readInt > 3000) {
                    randomAccessFile.close();
                    o = 0;
                    i();
                    return;
                }
                int readInt2 = randomAccessFile.readInt();
                randomAccessFile.seek(128);
                byte[] bArr = new byte[readInt];
                int i2 = 0;
                while (true) {
                    if (i2 >= readInt2) {
                        break;
                    }
                    randomAccessFile.seek((long) ((readInt * i2) + 128));
                    int readInt3 = randomAccessFile.readInt();
                    if (readInt3 > 0 && readInt3 < readInt) {
                        randomAccessFile.read(bArr, 0, readInt3);
                        int i3 = readInt3 - 1;
                        if (bArr[i3] == 0) {
                            String str = new String(bArr, 0, i3);
                            b.a();
                            if (str.equals(b.e)) {
                                m = randomAccessFile.readInt();
                                o = i2;
                                break;
                            }
                        } else {
                            continue;
                        }
                    }
                    i2++;
                }
                if (i2 == readInt2) {
                    o = readInt2;
                }
                randomAccessFile.close();
            }
        } catch (Exception unused) {
        }
    }

    public void b() {
        h();
    }

    public void c() {
    }

    public void d() {
        if (System.currentTimeMillis() - c.a().d() > 604800000) {
            c.a().c(System.currentTimeMillis());
            com.baidu.location.f.a.a().postDelayed(new f(this), 1000);
        }
    }
}