大漢易經書院.apk(点击下载) / a.java


package com.baidu.techain.d;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Base64;
import com.baidu.techain.ac.F;
import com.baidu.techain.i.c;
import com.huawei.hms.push.e;
import com.umeng.analytics.pro.ak;
import java.util.ArrayList;
import java.util.List;

/* compiled from: ReportDb */
public final class a {
    private static a a;
    private C0047a b;
    private SQLiteDatabase c;
    private Context d;

    private a(Context context) {
        this.d = context;
        C0047a aVar = new C0047a(context);
        this.b = aVar;
        try {
            this.c = aVar.getWritableDatabase();
        } catch (Throwable unused) {
            c.a();
        }
    }

    public static synchronized a a(Context context) {
        a aVar;
        synchronized (a.class) {
            if (a == null) {
                a = new a(context);
            }
            aVar = a;
        }
        return aVar;
    }

    public final long a(com.baidu.techain.e.a aVar) {
        ContentValues contentValues = new ContentValues();
        contentValues.put("b", aVar.b);
        contentValues.put("c", Integer.valueOf(aVar.c));
        contentValues.put("d", Long.valueOf(aVar.e));
        contentValues.put(e.a, Integer.valueOf(aVar.g));
        contentValues.put("g", Integer.valueOf(aVar.f));
        contentValues.put("f", Integer.valueOf(aVar.h));
        contentValues.put("i", Integer.valueOf(aVar.i));
        contentValues.put("j", aVar.j);
        String str = aVar.d;
        try {
            str = Base64.encodeToString(F.getInstance().ae(str.getBytes(), "xVOTuxgN3lkRN2v4".getBytes("utf-8")), 0);
        } catch (Exception unused) {
            c.a();
        }
        contentValues.put("h", str);
        try {
            return this.c.insert("r", null, contentValues);
        } catch (Throwable unused2) {
            c.a();
            return -1;
        }
    }

    public final long a(String str) {
        ContentValues contentValues = new ContentValues();
        contentValues.put("b", str);
        try {
            return this.c.insert("c", null, contentValues);
        } catch (Throwable unused) {
            c.a();
            return -1;
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:10:?, code lost:
        r11.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:11:0x0023, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:?, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:17:0x002b, code lost:
        if (r11 == null) goto L_0x002e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:0x002f, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x0030, code lost:
        if (r11 != null) goto L_0x0032;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:22:?, code lost:
        r11.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x0036, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:25:0x003a, code lost:
        throw r0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:8:0x001d, code lost:
        if (r11 != null) goto L_0x001f;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:15:0x0028 */
    public final boolean b(String str) {
        Cursor cursor;
        boolean z = true;
        try {
            cursor = this.c.query("c", null, "b=?", new String[]{str}, null, null, null);
            if (cursor != null) {
                if (cursor.getCount() > 0) {
                    z = false;
                }
            }
        } catch (Throwable unused) {
            cursor = null;
        }
        return z;
    }

    private int b(int i) {
        try {
            return this.c.delete("r", "a=?", new String[]{String.valueOf(i)});
        } catch (Throwable unused) {
            c.a();
            return -1;
        }
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(6:16|17|18|19|20|(2:21|22)) */
    /* JADX WARNING: Can't wrap try/catch for region: R(7:16|17|18|19|20|21|22) */
    /* JADX WARNING: Code restructure failed: missing block: B:17:?, code lost:
        com.baidu.techain.g.a.d = java.lang.System.currentTimeMillis();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:?, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x004a, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:22:?, code lost:
        r3.c.endTransaction();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x0053, code lost:
        com.baidu.techain.g.a.d = java.lang.System.currentTimeMillis();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:26:0x005b, code lost:
        r4 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:28:?, code lost:
        r3.c.endTransaction();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:30:?, code lost:
        com.baidu.techain.g.a.d = java.lang.System.currentTimeMillis();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:31:0x0069, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0032 */
    /* JADX WARNING: Missing exception handler attribute for start block: B:16:0x0040 */
    /* JADX WARNING: Missing exception handler attribute for start block: B:18:0x0047 */
    /* JADX WARNING: Missing exception handler attribute for start block: B:29:0x0062 */
    public final int a(List<Integer> list) {
        int i = -1;
        this.c.beginTransaction();
        for (Integer num : list) {
            i = b(num.intValue());
            if (i <= 0) {
                com.baidu.techain.g.a.d = System.currentTimeMillis();
            }
        }
        this.c.setTransactionSuccessful();
        this.c.endTransaction();
        try {
            com.baidu.techain.g.a.d = System.currentTimeMillis();
        } catch (Throwable unused) {
            c.a();
        }
        c.a();
        return i;
        c.a();
        throw th;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:20:0x012b, code lost:
        if (r3 != null) goto L_0x0135;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:21:0x012e, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:?, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:30:0x013d, code lost:
        if (r3 != null) goto L_0x013f;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:32:?, code lost:
        r3.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:33:0x0143, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:0x0147, code lost:
        throw r0;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:22:0x0130 */
    public final List<com.baidu.techain.e.a> a(int i) {
        String str;
        Cursor query;
        ArrayList arrayList = new ArrayList();
        long currentTimeMillis = System.currentTimeMillis();
        com.baidu.techain.h.a a2 = com.baidu.techain.h.a.a(this.d);
        int i2 = a2.e.getInt("re_net_wt", 3) * 3600000;
        if (i == 2) {
            str = "(d <= (" + currentTimeMillis + "-e*3600000) or e=0 )";
        } else {
            str = "(d <= (" + currentTimeMillis + "-e*3600000) or e=0 ) and (g!=2 or d<=" + (currentTimeMillis - ((long) i2)) + ")";
        }
        Cursor cursor = null;
        if (i == 2) {
            query = this.c.query("r", null, str, null, null, null, "d desc", Integer.toString(100));
        } else {
            query = this.c.query("r", null, str, null, null, null, "d desc", Integer.toString(a2.v()));
        }
        cursor = query;
        if (cursor != null) {
            while (cursor.moveToNext()) {
                com.baidu.techain.e.a aVar = new com.baidu.techain.e.a();
                aVar.a = cursor.getInt(cursor.getColumnIndex(ak.av));
                aVar.b = cursor.getString(cursor.getColumnIndex("b"));
                aVar.c = cursor.getInt(cursor.getColumnIndex("c"));
                aVar.e = cursor.getLong(cursor.getColumnIndex("d"));
                aVar.f = cursor.getInt(cursor.getColumnIndex("g"));
                aVar.g = cursor.getInt(cursor.getColumnIndex(e.a));
                aVar.h = cursor.getInt(cursor.getColumnIndex("f"));
                aVar.i = cursor.getInt(cursor.getColumnIndex("i"));
                aVar.j = cursor.getString(cursor.getColumnIndex("j"));
                String string = cursor.getString(cursor.getColumnIndex("h"));
                try {
                    string = new String(F.getInstance().ad(Base64.decode(string, 0), "xVOTuxgN3lkRN2v4".getBytes("utf-8")));
                } catch (Exception unused) {
                    c.a();
                }
                aVar.d = string;
                arrayList.add(aVar);
            }
        }
        return arrayList;
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(2:15|16) */
    /* JADX WARNING: Code restructure failed: missing block: B:13:0x00c1, code lost:
        if (r10 != null) goto L_0x00cb;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:14:0x00c4, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:?, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x00d3, code lost:
        if (r10 != null) goto L_0x00d5;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:25:?, code lost:
        r10.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:26:0x00d9, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:28:0x00dd, code lost:
        throw r0;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:15:0x00c6 */
    public final List<com.baidu.techain.e.a> a() {
        ArrayList arrayList = new ArrayList();
        Cursor cursor = null;
        cursor = this.c.query("r", null, "i=5", null, null, null, "d desc", "100");
        if (cursor != null) {
            while (cursor.moveToNext()) {
                com.baidu.techain.e.a aVar = new com.baidu.techain.e.a();
                aVar.a = cursor.getInt(cursor.getColumnIndex(ak.av));
                aVar.b = cursor.getString(cursor.getColumnIndex("b"));
                aVar.c = cursor.getInt(cursor.getColumnIndex("c"));
                aVar.e = cursor.getLong(cursor.getColumnIndex("d"));
                aVar.f = cursor.getInt(cursor.getColumnIndex("g"));
                aVar.g = cursor.getInt(cursor.getColumnIndex(e.a));
                aVar.h = cursor.getInt(cursor.getColumnIndex("f"));
                aVar.i = cursor.getInt(cursor.getColumnIndex("i"));
                aVar.j = cursor.getString(cursor.getColumnIndex("j"));
                String string = cursor.getString(cursor.getColumnIndex("h"));
                try {
                    string = new String(F.getInstance().ad(Base64.decode(string, 0), "xVOTuxgN3lkRN2v4".getBytes("utf-8")));
                } catch (Exception unused) {
                    c.a();
                }
                aVar.d = string;
                arrayList.add(aVar);
            }
        }
        return arrayList;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:19:0x010a, code lost:
        if (r11 != null) goto L_0x0114;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x010d, code lost:
        r12 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:22:?, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:29:0x011c, code lost:
        if (r11 != null) goto L_0x011e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:31:?, code lost:
        r11.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:32:0x0122, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:34:0x0126, code lost:
        throw r12;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:21:0x010f */
    public final List<com.baidu.techain.e.a> a(boolean z, int i) {
        String str;
        ArrayList arrayList = new ArrayList();
        long currentTimeMillis = System.currentTimeMillis();
        if (z) {
            str = "(d < (" + currentTimeMillis + "-f*3600000) and f!= 0)";
        } else {
            str = "d<=" + (currentTimeMillis - 259200000);
        }
        Cursor cursor = null;
        if (i == 2) {
            cursor = this.c.query("r", null, str, null, null, null, "d desc", "100");
        } else {
            cursor = this.c.query("r", null, str, null, null, null, "d desc", Integer.toString(com.baidu.techain.h.a.a(this.d).v()));
        }
        if (cursor != null) {
            while (cursor.moveToNext()) {
                com.baidu.techain.e.a aVar = new com.baidu.techain.e.a();
                aVar.a = cursor.getInt(cursor.getColumnIndex(ak.av));
                aVar.b = cursor.getString(cursor.getColumnIndex("b"));
                aVar.c = cursor.getInt(cursor.getColumnIndex("c"));
                aVar.e = cursor.getLong(cursor.getColumnIndex("d"));
                aVar.f = cursor.getInt(cursor.getColumnIndex("g"));
                aVar.g = cursor.getInt(cursor.getColumnIndex(e.a));
                aVar.h = cursor.getInt(cursor.getColumnIndex("f"));
                aVar.i = cursor.getInt(cursor.getColumnIndex("i"));
                aVar.j = cursor.getString(cursor.getColumnIndex("j"));
                String string = cursor.getString(cursor.getColumnIndex("h"));
                try {
                    string = new String(F.getInstance().ad(Base64.decode(string, 0), "xVOTuxgN3lkRN2v4".getBytes("utf-8")));
                } catch (Exception unused) {
                    c.a();
                }
                aVar.d = string;
                arrayList.add(aVar);
            }
        }
        return arrayList;
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(2:11|12) */
    /* JADX WARNING: Code restructure failed: missing block: B:10:0x0021, code lost:
        r1 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:12:?, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:13:0x0026, code lost:
        if (0 == 0) goto L_0x0029;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:15:0x002a, code lost:
        if (0 != 0) goto L_0x002c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:17:?, code lost:
        r0.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:18:0x0030, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x0034, code lost:
        throw r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:5:0x0017, code lost:
        if (r0 != null) goto L_0x0019;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:7:?, code lost:
        r0.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:8:0x001d, code lost:
        com.baidu.techain.i.c.a();
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0023 */
    public final int b() {
        Cursor cursor = null;
        int i = 0;
        cursor = this.c.query("r", null, null, null, null, null, null, null);
        if (cursor != null) {
            i = cursor.getCount();
        }
        return i;
    }

    public final int c() {
        com.baidu.techain.h.a a2 = com.baidu.techain.h.a.a(this.d);
        long currentTimeMillis = System.currentTimeMillis();
        int i = a2.e.getInt("re_net_over", 7) * 86400000;
        try {
            return this.c.delete("r", "(d <= ? or (d < (" + currentTimeMillis + "-f*3600000) and f!= 0)) and b != '1001001'and i != 5 ", new String[]{String.valueOf(currentTimeMillis - ((long) i))});
        } catch (Exception unused) {
            c.a();
            return -1;
        }
    }

    /* renamed from: com.baidu.techain.d.a$a  reason: collision with other inner class name */
    /* compiled from: ReportDb */
    class C0047a extends SQLiteOpenHelper {
        public C0047a(Context context) {
            super(context, "techain_d.db", (SQLiteDatabase.CursorFactory) null, 3);
        }

        public final void onCreate(SQLiteDatabase sQLiteDatabase) {
            sQLiteDatabase.execSQL("create table if not exists r(a integer primary key autoincrement, b text, c integer, e integer,f integer,h text, g integer, i integer, j text, d long);");
            sQLiteDatabase.execSQL("create table if not exists c(a integer primary key autoincrement, b text); ");
        }

        public final void onUpgrade(SQLiteDatabase sQLiteDatabase, int i, int i2) {
            if (i <= 1) {
                sQLiteDatabase.execSQL("alter table r add i integer default 0;");
            }
            if (i <= 2) {
                sQLiteDatabase.execSQL("ALTER TABLE r ADD COLUMN j TEXT");
            }
        }
    }
}