package com.tencent.mm.aj;

import android.content.ContentValues;
import android.database.Cursor;
import com.google.android.gms.common.internal.ImagesContract;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.g.c.ae;
import com.tencent.mm.sdk.e.c.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import java.lang.reflect.Field;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;

public final class d extends ae {
    protected static a ccO;
    public static int fuU = 1;
    public static int fuV = 0;
    public static int fuW = 1;
    private static int fuZ = 0;
    private static b fva = null;
    private List<a> fuX;
    public b fuY;

    static {
        AppMethodBeat.i(11321);
        a aVar = new a();
        aVar.xDb = new Field[20];
        aVar.columns = new String[21];
        StringBuilder stringBuilder = new StringBuilder();
        aVar.columns[0] = "username";
        aVar.xDd.put("username", "TEXT PRIMARY KEY ");
        stringBuilder.append(" username TEXT PRIMARY KEY ");
        stringBuilder.append(", ");
        aVar.xDc = "username";
        aVar.columns[1] = "appId";
        aVar.xDd.put("appId", "TEXT");
        stringBuilder.append(" appId TEXT");
        stringBuilder.append(", ");
        aVar.columns[2] = "brandList";
        aVar.xDd.put("brandList", "TEXT default '' ");
        stringBuilder.append(" brandList TEXT default '' ");
        stringBuilder.append(", ");
        aVar.columns[3] = "brandListVersion";
        aVar.xDd.put("brandListVersion", "TEXT");
        stringBuilder.append(" brandListVersion TEXT");
        stringBuilder.append(", ");
        aVar.columns[4] = "brandListContent";
        aVar.xDd.put("brandListContent", "TEXT");
        stringBuilder.append(" brandListContent TEXT");
        stringBuilder.append(", ");
        aVar.columns[5] = "brandFlag";
        aVar.xDd.put("brandFlag", "INTEGER");
        stringBuilder.append(" brandFlag INTEGER");
        stringBuilder.append(", ");
        aVar.columns[6] = "extInfo";
        aVar.xDd.put("extInfo", "TEXT");
        stringBuilder.append(" extInfo TEXT");
        stringBuilder.append(", ");
        aVar.columns[7] = "brandInfo";
        aVar.xDd.put("brandInfo", "TEXT");
        stringBuilder.append(" brandInfo TEXT");
        stringBuilder.append(", ");
        aVar.columns[8] = "brandIconURL";
        aVar.xDd.put("brandIconURL", "TEXT");
        stringBuilder.append(" brandIconURL TEXT");
        stringBuilder.append(", ");
        aVar.columns[9] = "updateTime";
        aVar.xDd.put("updateTime", "LONG");
        stringBuilder.append(" updateTime LONG");
        stringBuilder.append(", ");
        aVar.columns[10] = "hadAlert";
        aVar.xDd.put("hadAlert", "INTEGER");
        stringBuilder.append(" hadAlert INTEGER");
        stringBuilder.append(", ");
        aVar.columns[11] = "acceptType";
        aVar.xDd.put("acceptType", "INTEGER default '0' ");
        stringBuilder.append(" acceptType INTEGER default '0' ");
        stringBuilder.append(", ");
        aVar.columns[12] = "type";
        aVar.xDd.put("type", "INTEGER default '0' ");
        stringBuilder.append(" type INTEGER default '0' ");
        stringBuilder.append(", ");
        aVar.columns[13] = "status";
        aVar.xDd.put("status", "INTEGER default '0' ");
        stringBuilder.append(" status INTEGER default '0' ");
        stringBuilder.append(", ");
        aVar.columns[14] = "enterpriseFather";
        aVar.xDd.put("enterpriseFather", "TEXT");
        stringBuilder.append(" enterpriseFather TEXT");
        stringBuilder.append(", ");
        aVar.columns[15] = "kfWorkerId";
        aVar.xDd.put("kfWorkerId", "TEXT");
        stringBuilder.append(" kfWorkerId TEXT");
        stringBuilder.append(", ");
        aVar.columns[16] = "specialType";
        aVar.xDd.put("specialType", "INTEGER");
        stringBuilder.append(" specialType INTEGER");
        stringBuilder.append(", ");
        aVar.columns[17] = "attrSyncVersion";
        aVar.xDd.put("attrSyncVersion", "TEXT");
        stringBuilder.append(" attrSyncVersion TEXT");
        stringBuilder.append(", ");
        aVar.columns[18] = "incrementUpdateTime";
        aVar.xDd.put("incrementUpdateTime", "LONG");
        stringBuilder.append(" incrementUpdateTime LONG");
        stringBuilder.append(", ");
        aVar.columns[19] = "bitFlag";
        aVar.xDd.put("bitFlag", "INTEGER default '0' ");
        stringBuilder.append(" bitFlag INTEGER default '0' ");
        aVar.columns[20] = "rowid";
        aVar.sql = stringBuilder.toString();
        ccO = aVar;
        AppMethodBeat.o(11321);
    }

    public final a Ag() {
        return ccO;
    }

    public final b cJ(boolean z) {
        b qH;
        AppMethodBeat.i(11302);
        if (this.fuY == null || z) {
            if (bo.isNullOrNil(this.field_extInfo) || fuZ != this.field_extInfo.hashCode()) {
                qH = b.qH(this.field_extInfo);
                this.fuY = qH;
                fva = qH;
                fuZ = bo.nullAsNil(this.field_extInfo).hashCode();
            } else {
                this.fuY = fva;
            }
        }
        qH = this.fuY;
        AppMethodBeat.o(11302);
        return qH;
    }

    public final boolean adH() {
        return (this.field_brandFlag & 1) == 0;
    }

    public final boolean adI() {
        return (this.field_brandFlag & 4) != 0;
    }

    public final boolean adJ() {
        AppMethodBeat.i(11303);
        if (System.currentTimeMillis() - this.field_updateTime > 86400000) {
            AppMethodBeat.o(11303);
            return true;
        }
        Calendar instance = Calendar.getInstance();
        instance.set(11, 0);
        instance.set(12, 0);
        instance.set(13, 0);
        if (this.field_updateTime < instance.getTimeInMillis()) {
            AppMethodBeat.o(11303);
            return true;
        }
        AppMethodBeat.o(11303);
        return false;
    }

    public final void d(Cursor cursor) {
        AppMethodBeat.i(11318);
        super.d(cursor);
        AppMethodBeat.o(11318);
    }

    public final ContentValues Hl() {
        AppMethodBeat.i(11319);
        ContentValues Hl = super.Hl();
        AppMethodBeat.o(11319);
        return Hl;
    }

    public final List<a> adY() {
        AppMethodBeat.i(11320);
        if (this.fuX != null) {
            List list = this.fuX;
            AppMethodBeat.o(11320);
            return list;
        }
        this.fuX = new LinkedList();
        List<a> list2;
        if (this.field_brandInfo == null || this.field_brandInfo.length() == 0) {
            list2 = this.fuX;
            AppMethodBeat.o(11320);
            return list2;
        }
        try {
            JSONArray optJSONArray = new JSONObject(this.field_brandInfo).optJSONArray("urls");
            for (int i = 0; i < optJSONArray.length(); i++) {
                a aVar = new a();
                JSONObject optJSONObject = optJSONArray.optJSONObject(i);
                aVar.title = optJSONObject.optString("title");
                aVar.url = optJSONObject.optString(ImagesContract.URL);
                aVar.fvb = optJSONObject.optString("title_key");
                aVar.description = optJSONObject.optString("description");
                this.fuX.add(aVar);
            }
        } catch (Exception e) {
            ab.e("MicroMsg.BizInfo", "exception:%s", new Object[]{bo.l(e)});
        }
        list2 = this.fuX;
        AppMethodBeat.o(11320);
        return list2;
    }

    private boolean lc(int i) {
        return (this.field_bitFlag & i) != 0;
    }

    private void ld(int i) {
        this.field_bitFlag |= i;
    }

    public final void adK() {
        AppMethodBeat.i(11304);
        cJ(false);
        b bVar = this.fuY;
        if (bVar.fvc != null) {
            bVar.fvq = bVar.fvc.optInt("ConnectorMsgType");
        }
        this.field_acceptType = bVar.fvq;
        this.field_type = cJ(false).getServiceType();
        if (adR()) {
            ld(1);
            AppMethodBeat.o(11304);
            return;
        }
        this.field_bitFlag &= -2;
        AppMethodBeat.o(11304);
    }

    public final boolean adL() {
        AppMethodBeat.i(11305);
        cJ(false);
        ab.i("MicroMsg.BizInfo", "is report location, user %s %B", new Object[]{this.field_username, Boolean.valueOf(this.fuY.adL())});
        boolean adL = this.fuY.adL();
        AppMethodBeat.o(11305);
        return adL;
    }

    public final boolean adM() {
        AppMethodBeat.i(11306);
        cJ(false);
        if (this.field_type == 1) {
            AppMethodBeat.o(11306);
            return true;
        }
        AppMethodBeat.o(11306);
        return false;
    }

    public final boolean adN() {
        AppMethodBeat.i(11307);
        cJ(false);
        if (this.field_type == 0) {
            AppMethodBeat.o(11307);
            return true;
        }
        AppMethodBeat.o(11307);
        return false;
    }

    public final boolean adO() {
        AppMethodBeat.i(11308);
        cJ(false);
        if (this.field_type == 2 || this.field_type == 3) {
            AppMethodBeat.o(11308);
            return true;
        }
        AppMethodBeat.o(11308);
        return false;
    }

    public final boolean adP() {
        AppMethodBeat.i(11309);
        cJ(false);
        if (this.field_type == 2) {
            AppMethodBeat.o(11309);
            return true;
        }
        AppMethodBeat.o(11309);
        return false;
    }

    public final boolean adQ() {
        AppMethodBeat.i(11310);
        cJ(false);
        if (this.field_type == 3) {
            AppMethodBeat.o(11310);
            return true;
        }
        AppMethodBeat.o(11310);
        return false;
    }

    public final boolean adR() {
        boolean z;
        AppMethodBeat.i(11311);
        cJ(false);
        if (this.fuY == null || this.fuY.aer() == null) {
            z = false;
        } else {
            z = this.fuY.fvn.fvO == 1;
            if (z && !lc(1)) {
                ld(1);
                z.aeR().e(this);
            }
            if (z) {
                ab.d("MicroMsg.BizInfo", "EnterpriseChat,userName : %s", new Object[]{this.field_username});
            }
        }
        AppMethodBeat.o(11311);
        return z;
    }

    public final boolean adS() {
        boolean z;
        AppMethodBeat.i(11312);
        cJ(false);
        if (this.fuY == null || this.fuY.aer() == null) {
            z = false;
        } else {
            z = this.fuY.fvn.fvO == 2;
            if (z && !lc(2)) {
                ld(2);
                z.aeR().e(this);
            }
            if (z) {
                ab.d("MicroMsg.BizInfo", "EnterpriseWeb,userName : %s", new Object[]{this.field_username});
            }
        }
        AppMethodBeat.o(11312);
        return z;
    }

    public final String adT() {
        AppMethodBeat.i(11313);
        cJ(false);
        if (this.fuY != null) {
            d$b$c$a aer = this.fuY.aer();
            if (!(aer == null || aer.fvP == null || aer.fvP.isEmpty())) {
                String str = aer.fvP;
                AppMethodBeat.o(11313);
                return str;
            }
        }
        AppMethodBeat.o(11313);
        return null;
    }

    public final long adU() {
        AppMethodBeat.i(11314);
        cJ(false);
        if (this.fuY != null) {
            d$b$c$a aer = this.fuY.aer();
            if (!(aer == null || aer.appid == 0)) {
                long j = aer.appid;
                AppMethodBeat.o(11314);
                return j;
            }
        }
        AppMethodBeat.o(11314);
        return 0;
    }

    public final boolean adV() {
        AppMethodBeat.i(11315);
        cJ(false);
        if (this.fuY == null) {
            ab.i("MicroMsg.BizInfo", "isShowUserName bizInfo.getExtInfo() null");
            AppMethodBeat.o(11315);
            return true;
        } else if (this.fuY.ael() == null) {
            ab.i("MicroMsg.BizInfo", "isShowUserName bizInfo.getExtInfo().getRegisterSource() null");
            AppMethodBeat.o(11315);
            return true;
        } else if (this.fuY.ael().fwd) {
            AppMethodBeat.o(11315);
            return false;
        } else {
            AppMethodBeat.o(11315);
            return true;
        }
    }

    public final String adW() {
        AppMethodBeat.i(11316);
        cJ(false);
        if (this.fuY != null) {
            d$b$c$a aer = this.fuY.aer();
            if (aer != null) {
                String str = aer.fvQ;
                AppMethodBeat.o(11316);
                return str;
            }
        }
        AppMethodBeat.o(11316);
        return null;
    }

    public final String adX() {
        AppMethodBeat.i(11317);
        String str = cJ(false).aer().fvM;
        if (bo.isNullOrNil(str)) {
            ab.e("MicroMsg.BizInfo", "check father: %s, %s", new Object[]{this.field_username, str});
        }
        AppMethodBeat.o(11317);
        return str;
    }
}
